Skip to content

Commit

Permalink
Merge pull request #1979 from hydephp/improve-documentation-generator…
Browse files Browse the repository at this point in the history
…-script

Internal: Improve documentation generator script to update the kernel overview page
  • Loading branch information
caendesilva authored Oct 5, 2024
2 parents 876e36e + 8a385e5 commit f694dff
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
26 changes: 19 additions & 7 deletions docs/architecture-concepts/the-hydekernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ You can read all about it in the [Autodiscovery Documentation](autodiscovery).
Since the most common way to interact with the kernel is through the Hyde facade, we will use that for the examples.
But you could just as well chain the methods on the accessed kernel singleton instance if you wanted.

<!-- Start generated docs for the HydeKernel -->

<section id="hyde-kernel-base-methods">

<!-- Start generated docs for Hyde\Foundation\HydeKernel -->
<!-- Generated by HydePHP DocGen script at 2023-03-11 11:09:45 in 2.53ms -->
<!-- Generated by HydePHP DocGen script at 2024-07-08 20:47:38 in 2.89ms -->

#### `version()`

Expand Down Expand Up @@ -87,7 +89,7 @@ Hyde::features(): Hyde\Facades\Features
No description provided.

```php
Hyde::hasFeature(string $feature): bool
Hyde::hasFeature(Hyde\Enums\Feature|string $feature): bool
```

#### `toArray()`
Expand All @@ -105,30 +107,30 @@ Hyde::toArray(): array<TKey, TValue>
<section id="hyde-kernel-foundation-methods">

<!-- Start generated docs for Hyde\Foundation\Concerns\HandlesFoundationCollections -->
<!-- Generated by HydePHP DocGen script at 2023-03-11 11:14:55 in 0.06ms -->
<!-- Generated by HydePHP DocGen script at 2024-07-17 15:27:42 in 0.04ms -->

#### `files()`

No description provided.

```php
Hyde::files(): \Hyde\Foundation\Kernel\FileCollection<string, \Hyde\Support\Filesystem\ProjectFile>
Hyde::files(): Hyde\Foundation\Kernel\FileCollection
```

#### `pages()`

No description provided.

```php
Hyde::pages(): \Hyde\Foundation\Kernel\PageCollection<string, \Hyde\Pages\Concerns\HydePage>
Hyde::pages(): Hyde\Foundation\Kernel\PageCollection
```

#### `routes()`

No description provided.

```php
Hyde::routes(): \Hyde\Foundation\Kernel\RouteCollection<string, \Hyde\Support\Models\Route>
Hyde::routes(): Hyde\Foundation\Kernel\RouteCollection
```

<!-- End generated docs for Hyde\Foundation\Concerns\HandlesFoundationCollections -->
Expand Down Expand Up @@ -187,7 +189,7 @@ Hyde::markdown(string $text, bool $normalizeIndentation): Illuminate\Support\Htm
<section id="hyde-kernel-hyperlink-methods">

<!-- Start generated docs for Hyde\Foundation\Concerns\ForwardsHyperlinks -->
<!-- Generated by HydePHP DocGen script at 2023-03-11 11:17:34 in 0.09ms -->
<!-- Generated by HydePHP DocGen script at 2024-02-25 19:02:29 in 0.09ms -->

#### `formatLink()`

Expand Down Expand Up @@ -229,6 +231,14 @@ No description provided.
Hyde::url(string $path): string
```

#### `route()`

No description provided.

```php
Hyde::route(string $key): Hyde\Support\Models\Route
```

#### `hasSiteUrl()`

No description provided.
Expand Down Expand Up @@ -557,3 +567,5 @@ Hyde::booted(callable(\Hyde\Foundation\HydeKernel): void): void
<!-- End generated docs for Hyde\Foundation\Concerns\BootsHydeKernel -->

</section>

<!-- End generated docs for the HydeKernel -->
39 changes: 39 additions & 0 deletions monorepo/scripts/docs/DocGen.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,45 @@
generate($options);
}

// Update the HydeKernel page
(function (): void {
echo "\n\033[33mUpdating the HydeKernel page...\033[0m";

$pages = [
'hyde-kernel-base-methods',
'hyde-kernel-foundation-methods',
'hyde-kernel-string-methods',
'hyde-kernel-hyperlink-methods',
'hyde-kernel-filesystem-methods',
'hyde-kernel-kernel-methods',
'hyde-kernel-extensions-methods',
'hyde-kernel-view-methods',
'hyde-kernel-boot-methods',
];

$page = 'docs/architecture-concepts/the-hydekernel.md';

// Replace everything between <!-- Start generated docs for the HydeKernel --> and <!-- End generated docs for the HydeKernel -->
// With the concatenated content of the partials

$startMarker = '<!-- Start generated docs for the HydeKernel -->';
$endMarker = '<!-- End generated docs for the HydeKernel -->';

$rootPath = realpath(__DIR__.'/../../../');

$content = '';
foreach ($pages as $partial) {
$content .= trim(file_get_contents($rootPath.'/docs/_data/partials/hyde-pages-api/'.$partial.'.md'))."\n\n";
}

$file = file_get_contents($page);
$file = preg_replace('/<!-- Start generated docs for the HydeKernel -->.*<!-- End generated docs for the HydeKernel -->/s', $startMarker."\n\n".$content.$endMarker, $file);

file_put_contents($page, $file);

echo " \033[37mDone!\033[0m\n";
})();

// Assemble end time in milliseconds
$timeEnd = microtime(true);
$time = number_format(($timeEnd - $timeStart) * 1000, 2);
Expand Down

0 comments on commit f694dff

Please sign in to comment.