Skip to content

Commit

Permalink
Merge remote-tracking branch 'template/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Nov 3, 2024
2 parents 2dbce4f + e8e7c19 commit 4456732
Show file tree
Hide file tree
Showing 14 changed files with 2,942 additions and 2,608 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ["8.0"]
php-versions: ["8.2"]
env:
extensions: opcache, mbstring, ds, pcov
tools: composer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.4.1-draft
uses: AndreasAugustin/actions-template-sync@v1.1.8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: chevere/docs-deploy
Expand Down
14 changes: 12 additions & 2 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const project = require('./config-project')

project.theme = 'default-prefers-color-scheme';
project.head.push(
['meta', {
['meta', {
name: 'viewport',
content: 'width=device-width, initial-scale=1.0'
}]
Expand All @@ -21,11 +21,21 @@ project.plugins.push(
if (!project.themeConfig.nav) {
project.themeConfig.nav = [];
}
if (project.themeConfig.nav_before) {
project.themeConfig.nav.unshift(
...project.themeConfig.nav_before
);
}
project.themeConfig.nav.push(
...require('./nav/en')
);
if (project.themeConfig.nav_after) {
project.themeConfig.nav.push(
...project.themeConfig.nav_after
);
}
if (!project.themeConfig.sidebar) {
project.themeConfig.sidebar = [];
}
project.themeConfig.sidebar = require('./sidebar/en');
module.exports = project
module.exports = project
41 changes: 40 additions & 1 deletion .vuepress/styles/default-index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,43 @@ h1, h2, h3, h4, h5, h6,
font-size 0.93em

code, kbd, .line-number
font-family "FiraCode Nerd Font", "Operator Mono", Inconsolata, source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace
font-family "FiraCode Nerd Font", "Operator Mono", Inconsolata, source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace

.embed-responsive {
position: relative;
display: block;
width: 100%;
padding: 0;
overflow: hidden
}

.embed-responsive:before {
display: block;
content: ""
}

.embed-responsive .embed-responsive-item,.embed-responsive embed,.embed-responsive iframe,.embed-responsive object,.embed-responsive video {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
border: 0
}

.embed-responsive-21by9:before {
padding-top: 42.857143%
}

.embed-responsive-16by9:before {
padding-top: 56.25%
}

.embed-responsive-4by3:before {
padding-top: 75%
}

.embed-responsive-1by1:before {
padding-top: 100%
}
9 changes: 4 additions & 5 deletions build.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

use DocsDeploy\BuildController;

use function Chevere\Parameter\arguments;

require 'vendor/autoload.php';

(new BuildController())
->run(
(new BuildController())
->getArguments(
dir: getcwd() . '/docs/',
stream: 'php://stdout',
)
dir: getcwd() . '/docs/',
stream: 'php://stdout',
);
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
}
},
"require": {
"chevere/chevere": "^0.3"
"chevere/chevere": "^3.2"
},
"require-dev": {
"symplify/easy-coding-standard": "^9.1",
"chevere/var-dump": "^0.9.0",
"phpunit/phpunit": "^9.5",
"chevere/xr": "^0.1"
"symplify/easy-coding-standard": "^9.1"
},
"config": {
"optimize-autoloader": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "DocsDeploy",
"name": "docs-deploy",
"version": "0.0.1",
"description": "Chevere VuePress Deploy Template",
"main": "index.js",
Expand Down
31 changes: 13 additions & 18 deletions src/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@
namespace DocsDeploy;

use Chevere\Controller\Controller;
use Chevere\Filesystem\Interfaces\DirectoryInterface;

use function Chevere\Filesystem\directoryForPath;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Filesystem\fileForPath;
use function Chevere\Parameter\null;
use function Chevere\Parameter\parameters;
use function Chevere\Parameter\string;
use function Chevere\Parameter\stringParameter;
use Chevere\Parameter\Parameters;
use Chevere\Parameter\StringParameter;
use function Chevere\Writer\streamFor;
use Chevere\Writer\StreamWriter;
use Chevere\Filesystem\Interfaces\DirInterface;
use Chevere\Parameter\Interfaces\ArgumentsInterface;
use Chevere\Parameter\Interfaces\CastArgumentInterface;
use Chevere\Parameter\Interfaces\ParameterInterface;
use Chevere\Parameter\Interfaces\ParametersInterface;
use Chevere\Response\Interfaces\ResponseInterface;
use Chevere\Writer\Interfaces\WriterInterface;
Expand All @@ -32,35 +39,23 @@ class BuildController extends Controller
{
private WriterInterface $writer;

private DirInterface $dir;
private DirectoryInterface $dir;

private string $vuePressPath = '';

public function getParameters(): ParametersInterface
public static function acceptResponse(): ParameterInterface
{
return parameters(
dir: stringParameter(
description: 'Directory for VuePress-based documentation',
),
stream: stringParameter(
description: 'Stream to write log (w)',
default: 'php://stdout',
)
);
return null();
}

public function run(ArgumentsInterface $arguments): ResponseInterface
public function run(string $dir, string $stream): void
{
$dir = $arguments->getString('dir');
$this->dir = dirForPath($dir);
$stream = $arguments->getString('stream');
$this->dir = directoryForPath($dir);
$this->writer = new StreamWriter(streamFor($stream, 'w'));
$this->vuePressPath = "${dir}.vuepress/";
$this->vuePressPath = "{$dir}.vuepress/";
$this->processModules();
$this->processStyles();
$this->writer->write("\n✨ Complete");

return $this->getResponse();
}

private function processStyles(): void
Expand Down
7 changes: 4 additions & 3 deletions src/Flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

namespace DocsDeploy;

use Chevere\Filesystem\Interfaces\DirectoryInterface;
use Chevere\Filesystem\Interfaces\DirInterface;
use Countable;

class Flags implements Countable
{
private DirInterface $dir;
private DirectoryInterface $dir;

private bool $hasNested = false;

Expand All @@ -30,12 +31,12 @@ class Flags implements Countable

private int $count = 0;

public function __construct(DirInterface $dir)
public function __construct(DirectoryInterface $dir)
{
$this->dir = $dir;
}

public function dir(): DirInterface
public function dir(): DirectoryInterface
{
return $this->dir;
}
Expand Down
15 changes: 10 additions & 5 deletions src/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@

namespace DocsDeploy;

use function Chevere\Filesystem\directoryForPath;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Filesystem\filePhpReturnForPath;

use Chevere\Filesystem\Interfaces\DirectoryInterface;
use Chevere\Filesystem\Interfaces\DirInterface;
use Chevere\Writer\Interfaces\WriterInterface;
use RecursiveDirectoryIterator;
Expand All @@ -29,7 +32,7 @@ final class Iterator

public const SORTING = ['README.md'];

private DirInterface $dir;
private DirectoryInterface $dir;

private WriterInterface $writer;

Expand All @@ -47,12 +50,14 @@ final class Iterator

private SplFileinfo $current;

private int $chop;

/**
* @var Flags[]
*/
private array $flags = [];

public function __construct(DirInterface $dir, WriterInterface $writer)
public function __construct(DirectoryInterface $dir, WriterInterface $writer)
{
$dir->assertExists();
$this->dir = $dir;
Expand All @@ -79,7 +84,7 @@ public function __construct(DirInterface $dir, WriterInterface $writer)
$this->iterate();
}

public function dir(): DirInterface
public function dir(): DirectoryInterface
{
return $this->dir;
}
Expand Down Expand Up @@ -157,7 +162,7 @@ private function getDirFlags(Flags $flags): Flags
$return = null;
if ($filepath->exists()) {
$filePhp = filePhpReturnForPath($filepath->__toString());
$return = $filePhp->var();
$return = $filePhp->get();
}
$values[$flagger] = $return;
}
Expand Down Expand Up @@ -191,7 +196,7 @@ private function getFlags(): Flags
}
if ($this->current->isFile()) {
if (! isset($this->flags[$parent])) {
$this->flags[$parent] = new Flags(dirForPath($parent));
$this->flags[$parent] = new Flags(directoryForPath($parent));
}
$this->flags[$parent] = $this->flags[$parent]
->withAddedMarkdown();
Expand Down
10 changes: 5 additions & 5 deletions src/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function execute(): void

continue;
}
$rootNode = "/${node}";
$rootNode = "/{$node}";
if (! isset($this->iterator->flags()[$rootNode])) {
continue;
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public function getUsableNode(string $node): string
private function setSideFor(string $node): void
{
$side = 'auto';
$rootNode = "/${node}";
$rootNode = "/{$node}";
$flags = $this->iterator->flags()[$rootNode] ?? null;
if ($flags === null) {
return;
Expand All @@ -92,18 +92,18 @@ private function setSideFor(string $node): void
$filepath = $flags->dir()->path()->getChild('sidebar.php');
if ($filepath->exists()) {
$filePhp = filePhpReturnForPath($filepath->__toString());
$side = $filePhp->var();
$side = $filePhp->get();
} elseif ($flags->hasNested() || $flags->hasReadme()) {
$side = $this->getSide($rootNode, $flags, $contents);
}
$this->side["/${node}"] = $side;
$this->side["/{$node}"] = $side;
}

private function setNavFor(string $node): void
{
$title = $this->iterator->flags()['/']->naming()[$node]
?? $this->getTitle($node);
$rootNode = "/${node}";
$rootNode = "/{$node}";
$flags = $this->iterator->flags()[$rootNode];
$contents = $this->iterator->contents()[$rootNode];
if ($flags !== null && $flags->hasReadme()) {
Expand Down
5 changes: 3 additions & 2 deletions tests/IteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Chevere\Tests;

use function Chevere\Filesystem\directoryForPath;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Writer\streamTemp;
use Chevere\Writer\StreamWriter;
Expand All @@ -24,7 +25,7 @@ final class IteratorTest extends TestCase
{
public function testConstruct(): void
{
$dir = dirForPath(__DIR__ . '/_resources/docs/');
$dir = directoryForPath(__DIR__ . '/_resources/docs/');
$writer = new StreamWriter(streamTemp(''));
$iterator = new Iterator($dir, $writer);
$this->assertSame($dir, $iterator->dir());
Expand Down Expand Up @@ -145,7 +146,7 @@ public function testSubFolders(): void
private function getIterator(string $path, WriterInterface $writer = null): Iterator
{
return new Iterator(
dirForPath(__DIR__ . '/_resources/docs/' . $path),
directoryForPath(__DIR__ . '/_resources/docs/' . $path),
$writer ?? new StreamWriter(streamTemp(''))
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/ModulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Chevere\Tests;

use function Chevere\Filesystem\directoryForPath;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Writer\streamTemp;
use Chevere\Writer\StreamWriter;
Expand All @@ -24,7 +25,7 @@ final class ModulesTest extends TestCase
{
public function testConstruct(): void
{
$dir = dirForPath(__DIR__ . '/_resources/docs/');
$dir = directoryForPath(__DIR__ . '/_resources/docs/');
$writer = new StreamWriter(streamTemp(''));
$iterator = new Iterator($dir, $writer);
$modules = new Modules($iterator);
Expand Down
Loading

0 comments on commit 4456732

Please sign in to comment.