From 4ba0ef0e96b38127d8dd6489f8155e24347aeaea Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 18:56:46 +0200 Subject: [PATCH 01/15] Rename config keys to use snake_case --- config/hyde.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config/hyde.php b/config/hyde.php index 8c6bb5cc..12e0a5d3 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -58,9 +58,9 @@ 'site_url' => env('SITE_URL', null), - 'prettyUrls' => false, + 'pretty_urls' => false, - 'generateSitemap' => true, + 'generate_sitemap' => true, /* |-------------------------------------------------------------------------- @@ -141,8 +141,8 @@ | */ - 'loadHydeAssetsUsingCDN' => true, - // 'cdnVersionOverride' => 'v1.0.0', + 'load_hyde_assets_using_cdn' => true, + // 'cdn_version_override' => 'v1.0.0', /* |-------------------------------------------------------------------------- @@ -178,7 +178,7 @@ | */ - 'navigationMenuLinks' => [ + 'navigation_menu_links' => [ // [ // 'title' => 'GitHub', // 'destination' => 'https://github.com/hydephp/hyde', @@ -199,7 +199,7 @@ | */ - 'navigationMenuBlacklist' => [ + 'navigation_menu_blacklist' => [ '404', ], @@ -213,7 +213,7 @@ | */ - 'docsSidebarHeaderTitle' => $siteName.' Docs', + 'docs_sidebar_header_title' => $siteName.' Docs', /* |-------------------------------------------------------------------------- @@ -234,7 +234,7 @@ /** * @deprecated version 0.25.0, will be renamed to documentationOutputPath */ - 'docsDirectory' => 'docs', + 'docs_directory' => 'docs', /* |-------------------------------------------------------------------------- @@ -249,7 +249,7 @@ | */ - 'siteOutputPath' => Hyde\Framework\Hyde::path('_site'), + 'site_output_path' => Hyde\Framework\Hyde::path('_site'), /* |-------------------------------------------------------------------------- @@ -264,7 +264,7 @@ | */ - 'documentationPageOrder' => [ + 'documentation_page_order' => [ 'readme', 'installation', 'getting-started', @@ -281,7 +281,7 @@ | */ - 'documentationPageTableOfContents' => [ + 'documentation_page_table_of_contents' => [ 'enabled' => true, 'minHeadingLevel' => 2, 'maxHeadingLevel' => 4, @@ -298,6 +298,6 @@ | */ - 'warnAboutOutdatedConfig' => true, + 'warn_about_outdated_config' => true, ]; From 95075144e8d0dcceff56bae61b6ce51ef754e039 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 19:17:57 +0200 Subject: [PATCH 02/15] Remove "Asset Locations and Versions" config setting --- .github/dev-docs/managing-assets.md | 2 +- config/hyde.php | 21 --------------------- src/Concerns/Internal/AssetManager.php | 6 +++--- src/Services/AssetService.php | 2 +- tests/Feature/AssetServiceTest.php | 15 --------------- 5 files changed, 5 insertions(+), 41 deletions(-) diff --git a/.github/dev-docs/managing-assets.md b/.github/dev-docs/managing-assets.md index eaacde2a..8093a36d 100644 --- a/.github/dev-docs/managing-assets.md +++ b/.github/dev-docs/managing-assets.md @@ -14,7 +14,7 @@ But as always with Hyde, you can customize everything if you want to. Hyde ships with a complete frontend where base styles and scripts are included through [HydeFront](https://github.com/hydephp/hydefront) which adds accessibility and mobile support as well as interactions for dark mode switching and navigation and sidebar interactions. -HydeFront is split into two files, `hyde.css` and `hyde.js`. These are loaded in the default Blade views using the [jsDelivr CDN](https://www.jsdelivr.com/package/npm/hydefront). This is the recommended way to load the base styles as the [Hyde Framework](https://github.com/hydephp/framework) automatically makes sure that the correct HydeFront version for the current version of Hyde is loaded. You can disable the CDN in the `config/hyde.php` file by setting `'loadHydeAssetsUsingCDN'` to `false`. +HydeFront is split into two files, `hyde.css` and `hyde.js`. These are loaded in the default Blade views using the [jsDelivr CDN](https://www.jsdelivr.com/package/npm/hydefront). This is the recommended way to load the base styles as the [Hyde Framework](https://github.com/hydephp/framework) automatically makes sure that the correct HydeFront version for the current version of Hyde is loaded. If you don't want to use HydeFribtm you can customize the `styles.blade.php` file. The bulk of the frontend is built with [TailwindCSS](https://tailwindcss.com/). To get you started, when installing Hyde, all the Tailwind styles you need come precompiled and minified into `_media/app.css`. diff --git a/config/hyde.php b/config/hyde.php index 12e0a5d3..ad261246 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -123,27 +123,6 @@ Features::torchlight(), ], - /* - |-------------------------------------------------------------------------- - | Asset Locations and Versions - |-------------------------------------------------------------------------- - | - | Since v0.15.0, the default Hyde styles are no longer included as - | publishable resources. This is to make updating easier, and to - | reduce complexity. Instead, the assets are loaded through the - | jsDelivr CDN. - | - | The CDN version is defined in the AssetService class, - | but can be changed here to a valid HydeFront tag. - | - | If you load HydeFront through Laravel Mix using the NPM package, - | you should disable the HydeFront CDN feature. - | - */ - - 'load_hyde_assets_using_cdn' => true, - // 'cdn_version_override' => 'v1.0.0', - /* |-------------------------------------------------------------------------- | Footer Text diff --git a/src/Concerns/Internal/AssetManager.php b/src/Concerns/Internal/AssetManager.php index c49242c8..2e521a7d 100644 --- a/src/Concerns/Internal/AssetManager.php +++ b/src/Concerns/Internal/AssetManager.php @@ -24,9 +24,9 @@ public static function assetManager(): AssetServiceContract /** * Return the Hyde stylesheet. */ - public static function styles(): string|false + public static function styles(): string { - return config('hyde.loadHydeAssetsUsingCDN', true) ? static::assetManager()->stylePath() : false; + return static::assetManager()->stylePath(); } /** @@ -34,6 +34,6 @@ public static function styles(): string|false */ public static function scripts(): string { - return config('hyde.loadHydeAssetsUsingCDN', true) ? static::assetManager()->scriptPath() : false; + return static::assetManager()->scriptPath(); } } diff --git a/src/Services/AssetService.php b/src/Services/AssetService.php index 5a039bc8..119b2111 100644 --- a/src/Services/AssetService.php +++ b/src/Services/AssetService.php @@ -16,7 +16,7 @@ class AssetService implements AssetServiceContract public function version(): string { - return config('hyde.cdnVersionOverride', $this->version); + return $this->version; } public function stylePath(): string diff --git a/tests/Feature/AssetServiceTest.php b/tests/Feature/AssetServiceTest.php index 0ae37a18..7e1f06da 100644 --- a/tests/Feature/AssetServiceTest.php +++ b/tests/Feature/AssetServiceTest.php @@ -3,7 +3,6 @@ namespace Tests\Feature; use Hyde\Framework\Services\AssetService; -use Illuminate\Support\Facades\Config; use Tests\TestCase; /** @@ -30,13 +29,6 @@ public function test_version_method_returns_version_property_when_config_overrid $this->assertEquals($service->version, $service->version()); } - public function test_can_change_version_in_config() - { - $service = new AssetService(); - Config::set('hyde.cdnVersionOverride', '2.0.0'); - $this->assertEquals('2.0.0', $service->version()); - } - public function test_style_path_method_returns_cdn_path() { $service = new AssetService(); @@ -57,11 +49,4 @@ public function test_cdn_path_constructor_returns_cdn_uri() $this->assertIsString($path = $service->constructCdnPath('styles.css')); $this->assertStringContainsString('styles.css', $path); } - - public function test_cdn_path_constructor_uses_selected_version() - { - $service = new AssetService(); - Config::set('hyde.cdnVersionOverride', '1.2.3'); - $this->assertStringContainsString('@1.2.3', $service->constructCdnPath('styles.css')); - } } From 2e890658da27d65d646d4c41df7f1f84a252ac31 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 19:56:43 +0200 Subject: [PATCH 03/15] Change config keys to lowercase --- .github/dev-docs/documentation-pages.md | 16 ++++++++-------- config/hyde.php | 4 ++-- src/Actions/GeneratesTableOfContents.php | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/dev-docs/documentation-pages.md b/.github/dev-docs/documentation-pages.md index 095b97ad..8ab3b162 100644 --- a/.github/dev-docs/documentation-pages.md +++ b/.github/dev-docs/documentation-pages.md @@ -165,8 +165,8 @@ If you want to store the compiled documentation pages in a different directory t for example to specify a version like the Hyde docs does, you can specify the output directory in the Hyde configuration file. ```php -'docsDirectory' => 'docs' // Default -'docsDirectory' => 'docs/master' // What the Hyde docs use +'docs_directory' => 'docs' // default +'docs_directory' => 'docs/master' // What the Hyde docs use ``` ### Sidebar header name @@ -175,7 +175,7 @@ By default, the site title shown in the sidebar header is generated from the con You can change this in the Hyde configuration file. ```php -'docsSidebarHeaderTitle' => 'API Documentation', +'docs_sidebar_header_title' => 'API Documentation', ``` ### Sidebar page order @@ -184,7 +184,7 @@ To quickly arrange the order of items in the sidebar, you can reorder the page s Link items without an entry here will have fall back to the default priority of 999, putting them last. ```php -'documentationPageOrder' => [ +'documentation_page_order' => [ 'readme', 'installation', 'getting-started', @@ -200,10 +200,10 @@ In the Hyde config you can configure the behavior, content, and the look and fee You can also disable the feature completely. ```php -'documentationPageTableOfContents' => [ +'documentation_page_table_of_contents' => [ 'enabled' => true, - 'minHeadingLevel' => 2, - 'maxHeadingLevel' => 4, - 'smoothPageScrolling' => true, + 'min_heading_level' => 2, + 'max_heading_level' => 4, + 'smooth_page_scrolling' => true, ], ``` diff --git a/config/hyde.php b/config/hyde.php index ad261246..0d8c208e 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -262,8 +262,8 @@ 'documentation_page_table_of_contents' => [ 'enabled' => true, - 'minHeadingLevel' => 2, - 'maxHeadingLevel' => 4, + 'min_heading_level' => 2, + 'max_heading_level' => 4, 'smoothPageScrolling' => true, ], diff --git a/src/Actions/GeneratesTableOfContents.php b/src/Actions/GeneratesTableOfContents.php index 66b6bd42..ae939194 100644 --- a/src/Actions/GeneratesTableOfContents.php +++ b/src/Actions/GeneratesTableOfContents.php @@ -30,8 +30,8 @@ public function execute(): string 'html_class' => 'table-of-contents', 'position' => 'top', 'style' => 'bullet', - 'min_heading_level' => config('hyde.documentationPageTableOfContents.minHeadingLevel', 2), - 'max_heading_level' => config('hyde.documentationPageTableOfContents.maxHeadingLevel', 4), + 'min_heading_level' => config('hyde.documentation_page_table_of_contents.min_heading_level', 2), + 'max_heading_level' => config('hyde.documentation_page_table_of_contents.max_heading_level', 4), 'normalize' => 'relative', ], 'heading_permalink' => [ From 8ebdef3de9fd6a97ae39792491ebb678f9a67c56 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 19:56:58 +0200 Subject: [PATCH 04/15] Remove unused "smoothPageScrolling" config option --- config/hyde.php | 1 - 1 file changed, 1 deletion(-) diff --git a/config/hyde.php b/config/hyde.php index 0d8c208e..f9640f53 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -264,7 +264,6 @@ 'enabled' => true, 'min_heading_level' => 2, 'max_heading_level' => 4, - 'smoothPageScrolling' => true, ], /* From ea5d2204d500c49342c7e9e93379051b29a2c676 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:18:24 +0200 Subject: [PATCH 05/15] Fix wrong variable name causing TOC not to show --- .../components/docs/labeled-sidebar-navigation-menu.blade.php | 4 ++-- .../views/components/docs/sidebar-navigation-menu.blade.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/components/docs/labeled-sidebar-navigation-menu.blade.php b/resources/views/components/docs/labeled-sidebar-navigation-menu.blade.php index 38390492..dc698430 100644 --- a/resources/views/components/docs/labeled-sidebar-navigation-menu.blade.php +++ b/resources/views/components/docs/labeled-sidebar-navigation-menu.blade.php @@ -7,9 +7,9 @@
  • $item->destination === basename($currentPage)]) role="listitem"> @if($item->destination === basename($currentPage)) {{ $item->label }} - @if(isset($docs->tableOfContents)) + @if(isset($page->tableOfContents)) Table of contents - {!! ($docs->tableOfContents) !!} + {!! ($page->tableOfContents) !!} @endif @else {{ $item->label }} diff --git a/resources/views/components/docs/sidebar-navigation-menu.blade.php b/resources/views/components/docs/sidebar-navigation-menu.blade.php index 8d22fd47..1bef7f07 100644 --- a/resources/views/components/docs/sidebar-navigation-menu.blade.php +++ b/resources/views/components/docs/sidebar-navigation-menu.blade.php @@ -5,9 +5,9 @@ {{ $item->label }} - @if(isset($docs->tableOfContents)) + @if(isset($page->tableOfContents)) Table of contents - {!! ($docs->tableOfContents) !!} + {!! ($page->tableOfContents) !!} @endif @else {{ $item->label }} From 62bc5c3c0abd77f82d0c589bfd60de7f8c5dda55 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:18:32 +0200 Subject: [PATCH 06/15] Change config key case to snake_case --- resources/views/layouts/docs.blade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/layouts/docs.blade.php b/resources/views/layouts/docs.blade.php index ab210d41..a6def2f7 100644 --- a/resources/views/layouts/docs.blade.php +++ b/resources/views/layouts/docs.blade.php @@ -15,10 +15,10 @@ @if(Hyde::docsIndexPath() !== false) - {{ config('hyde.docsSidebarHeaderTitle', 'Documentation') }} + {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} @else - {{ config('hyde.docsSidebarHeaderTitle', 'Documentation') }} + {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} @endif @include('hyde::components.navigation.theme-toggle-button') @@ -35,10 +35,10 @@ @if(Hyde::docsIndexPath() !== false) - {{ config('hyde.docsSidebarHeaderTitle', 'Documentation') }} + {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} @else - {{ config('hyde.docsSidebarHeaderTitle', 'Documentation') }} + {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} @endif @include('hyde::components.navigation.theme-toggle-button') From 807d085e08df377d93a50fc7d232931d1b3d2e30 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:21:22 +0200 Subject: [PATCH 07/15] Update config keys to snake_case --- src/Actions/GeneratesNavigationMenu.php | 4 ++-- src/Commands/HydeUpdateConfigsCommand.php | 2 +- src/Concerns/HasTableOfContents.php | 2 +- src/Concerns/Internal/FileHelpers.php | 4 ++-- src/Concerns/Markdown/HasMarkdownFeatures.php | 2 +- src/Services/RssFeedService.php | 6 +++--- src/Services/SitemapService.php | 2 +- ...TestBuildStaticSiteCommandFlagToEnablePrettyUrlsTest.php | 6 +++--- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Actions/GeneratesNavigationMenu.php b/src/Actions/GeneratesNavigationMenu.php index 8505657d..e1cc06b0 100644 --- a/src/Actions/GeneratesNavigationMenu.php +++ b/src/Actions/GeneratesNavigationMenu.php @@ -93,7 +93,7 @@ private function getLinks(): array // Remove config defined blacklisted links foreach ($links as $key => $link) { - if (in_array(Str::slug($link['title']), config('hyde.navigationMenuBlacklist', []))) { + if (in_array(Str::slug($link['title']), config('hyde.navigation_menu_blacklist', []))) { unset($links[$key]); } } @@ -113,7 +113,7 @@ private function getLinks(): array */ public function getLinksFromConfig(): array { - $configLinks = config('hyde.navigationMenuLinks', []); + $configLinks = config('hyde.navigation_menu_links', []); $links = []; diff --git a/src/Commands/HydeUpdateConfigsCommand.php b/src/Commands/HydeUpdateConfigsCommand.php index a50d3352..f0bbed21 100644 --- a/src/Commands/HydeUpdateConfigsCommand.php +++ b/src/Commands/HydeUpdateConfigsCommand.php @@ -21,7 +21,7 @@ public function __construct() { parent::__construct(); - if ($this->checkIfConfigIsOutOfDate() && config('hyde.warnAboutOutdatedConfig', true)) { + if ($this->checkIfConfigIsOutOfDate() && config('hyde.warn_about_outdated_config', true)) { $this->setDescription( '⚠ Your configuration may be out of date. '. 'Run this command to update them.' diff --git a/src/Concerns/HasTableOfContents.php b/src/Concerns/HasTableOfContents.php index 260eb3ac..06c584d9 100644 --- a/src/Concerns/HasTableOfContents.php +++ b/src/Concerns/HasTableOfContents.php @@ -15,7 +15,7 @@ trait HasTableOfContents public function constructTableOfContents(): void { - if (config('hyde.documentationPageTableOfContents.enabled', true)) { + if (config('hyde.documentation_page_table_of_contents.enabled', true)) { $this->tableOfContents = (new GeneratesTableOfContents($this->body))->execute(); } } diff --git a/src/Concerns/Internal/FileHelpers.php b/src/Concerns/Internal/FileHelpers.php index 27a25762..2ad85cac 100644 --- a/src/Concerns/Internal/FileHelpers.php +++ b/src/Concerns/Internal/FileHelpers.php @@ -25,7 +25,7 @@ trait FileHelpers */ public static function docsDirectory(): string { - return trim(config('hyde.docsDirectory', 'docs'), '/\\'); + return trim(config('hyde.docs_directory', 'docs'), '/\\'); } /** @@ -86,7 +86,7 @@ public static function vendorPath(string $path = ''): string */ public static function pageLink(string $destination): string { - if (config('hyde.prettyUrls', false) === true) { + if (config('hyde.pretty_urls', false) === true) { if (str_ends_with($destination, '.html')) { if ($destination === 'index.html') { return '/'; diff --git a/src/Concerns/Markdown/HasMarkdownFeatures.php b/src/Concerns/Markdown/HasMarkdownFeatures.php index 1a8b9cd0..74d3f274 100644 --- a/src/Concerns/Markdown/HasMarkdownFeatures.php +++ b/src/Concerns/Markdown/HasMarkdownFeatures.php @@ -11,6 +11,6 @@ trait HasMarkdownFeatures { public static function hasTableOfContents(): bool { - return config('hyde.documentationPageTableOfContents.enabled', true); + return config('hyde.documentation_page_table_of_contents.enabled', true); } } diff --git a/src/Services/RssFeedService.php b/src/Services/RssFeedService.php index 485449de..5eb1d5f9 100644 --- a/src/Services/RssFeedService.php +++ b/src/Services/RssFeedService.php @@ -99,7 +99,7 @@ protected function addAdditionalChannelData(): void protected function getDescription(): string { return static::xmlEscape( - config('hyde.rssDescription', + config('hyde.rss_description', static::getTitle().' RSS Feed') ); } @@ -127,7 +127,7 @@ public static function getLink(): string public static function getDefaultOutputFilename(): string { - return config('hyde.rssFilename', 'feed.xml'); + return config('hyde.rss_filename', 'feed.xml'); } public static function generateFeed(): string @@ -137,6 +137,6 @@ public static function generateFeed(): string public static function canGenerateFeed(): bool { - return (Hyde::uriPath() !== false) && config('hyde.generateRssFeed', true) && Features::hasBlogPosts(); + return (Hyde::uriPath() !== false) && config('hyde.generate_rss_feed', true) && Features::hasBlogPosts(); } } diff --git a/src/Services/SitemapService.php b/src/Services/SitemapService.php index 0f812f84..a4942f51 100644 --- a/src/Services/SitemapService.php +++ b/src/Services/SitemapService.php @@ -120,6 +120,6 @@ public static function generateSitemap(): string public static function canGenerateSitemap(): bool { - return (Hyde::uriPath() !== false) && config('hyde.generateSitemap', true); + return (Hyde::uriPath() !== false) && config('hyde.generate_sitemap', true); } } diff --git a/tests/Unit/TestBuildStaticSiteCommandFlagToEnablePrettyUrlsTest.php b/tests/Unit/TestBuildStaticSiteCommandFlagToEnablePrettyUrlsTest.php index 3aae4513..14f625d1 100644 --- a/tests/Unit/TestBuildStaticSiteCommandFlagToEnablePrettyUrlsTest.php +++ b/tests/Unit/TestBuildStaticSiteCommandFlagToEnablePrettyUrlsTest.php @@ -11,17 +11,17 @@ class TestBuildStaticSiteCommandFlagToEnablePrettyUrlsTest extends TestCase { public function test_pretty_urls_can_be_enabled_with_flag() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->artisan('build --pretty-urls') ->expectsOutput('Generating site with pretty URLs') ->assertExitCode(0); - $this->assertTrue(config('hyde.prettyUrls', false)); + $this->assertTrue(config('hyde.pretty_urls', false)); } public function test_config_change_is_not_persisted() { - $this->assertFalse(config('hyde.prettyUrls', false)); + $this->assertFalse(config('hyde.pretty_urls', false)); } } From 92b9ae5fc4f2c7743206ebcfce48d81e4df7746d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:46:11 +0200 Subject: [PATCH 08/15] Extract documentation configuration options to docs.php --- .github/dev-docs/RELEASE-NOTES-DRAFT.md | 26 ++++++ .github/dev-docs/documentation-pages.md | 19 +++-- config/docs.php | 84 +++++++++++++++++++ config/hyde.php | 68 +-------------- resources/views/layouts/docs.blade.php | 8 +- src/Actions/GeneratesTableOfContents.php | 4 +- src/Concerns/HasTableOfContents.php | 2 +- src/Concerns/Internal/FileHelpers.php | 4 +- src/Concerns/Markdown/HasMarkdownFeatures.php | 2 +- src/Models/DocumentationSidebarItem.php | 2 +- .../DocumentationSidebarServiceTest.php | 8 +- .../HasConfigurableMarkdownFeaturesTest.php | 2 +- tests/Feature/StaticPageBuilderTest.php | 2 +- tests/Unit/HasMarkdownFeaturesTest.php | 4 +- 14 files changed, 140 insertions(+), 95 deletions(-) create mode 100644 .github/dev-docs/RELEASE-NOTES-DRAFT.md create mode 100644 config/docs.php diff --git a/.github/dev-docs/RELEASE-NOTES-DRAFT.md b/.github/dev-docs/RELEASE-NOTES-DRAFT.md new file mode 100644 index 00000000..29403b4c --- /dev/null +++ b/.github/dev-docs/RELEASE-NOTES-DRAFT.md @@ -0,0 +1,26 @@ +# Draft for the release notes of upcoming HydePHP versions + +## Changes to the configuration files + +The entire configuration system has been refactored. + +### Snake_case is used for all configuration keys + +All configuration keys are now in the snake_case_format. Published configuration files will need to be updated accordingly. This is pretty fast in a modern code editor like VS Code. + +### Documentation options have been moved to a new file + +The documentation page specific options have been moved to the `config/docs.php` file. +You may need to republish Blade views if you have done so before. + +This is also easy to do in a modern code editor. See this example of the search and replace I used +to update the codebase: + +`hyde.docs_sidebar_header_title` => `docs.header_title` + + +### Deprecations and removals + +The deprecated option named `hyde.docs_directory` has been removed. + +Use `docs.output_directory` instead. \ No newline at end of file diff --git a/.github/dev-docs/documentation-pages.md b/.github/dev-docs/documentation-pages.md index 8ab3b162..edd28537 100644 --- a/.github/dev-docs/documentation-pages.md +++ b/.github/dev-docs/documentation-pages.md @@ -111,7 +111,7 @@ The default priority is 999. You can override the priority using the following f priority: 5 ``` -You can also change the order in the Hyde configuration file. +You can also change the order in the Docs configuration file. See [the chapter in the customization page](customization.html#navigation-menu--sidebar) for more details.
    _I personally think the config route is easier as it gives an instant overview, however the first way is nice as well._ @@ -162,20 +162,20 @@ including the documentation pages. Here is a high level overview for quick refer ### Output directory If you want to store the compiled documentation pages in a different directory than the default 'docs' directory, -for example to specify a version like the Hyde docs does, you can specify the output directory in the Hyde configuration file. +for example to specify a version like the Hyde docs does, you can specify the output directory in the Docs configuration file. ```php -'docs_directory' => 'docs' // default -'docs_directory' => 'docs/master' // What the Hyde docs use +'output_directory' => 'docs' // default +'output_directory' => 'docs/master' // What the Hyde docs use ``` ### Sidebar header name By default, the site title shown in the sidebar header is generated from the configured site name suffixed with "docs". -You can change this in the Hyde configuration file. +You can change this in the Docs configuration file. ```php -'docs_sidebar_header_title' => 'API Documentation', +'title' => 'API Documentation', ``` ### Sidebar page order @@ -184,7 +184,7 @@ To quickly arrange the order of items in the sidebar, you can reorder the page s Link items without an entry here will have fall back to the default priority of 999, putting them last. ```php -'documentation_page_order' => [ +'sidebar_order' => [ 'readme', 'installation', 'getting-started', @@ -196,11 +196,12 @@ See [the chapter in the customization page](customization.html#navigation-menu-- ### Table of contents settings -In the Hyde config you can configure the behavior, content, and the look and feel of the sidebar table of contents. +In the `config/docs.php` file you can configure the behavior, content, +and the look and feel of the sidebar table of contents. You can also disable the feature completely. ```php -'documentation_page_table_of_contents' => [ +'table_of_contents' => [ 'enabled' => true, 'min_heading_level' => 2, 'max_heading_level' => 4, diff --git a/config/docs.php b/config/docs.php new file mode 100644 index 00000000..01e6207a --- /dev/null +++ b/config/docs.php @@ -0,0 +1,84 @@ + config('hyde.name', 'HydePHP').' Docs', + + + /* + |-------------------------------------------------------------------------- + | Documentation Site Output Directory + |-------------------------------------------------------------------------- + | + | If you want to store the compiled documentation pages in a different + | directory than the default 'docs' directory, for example to set the + | specified version, you can specify the directory here. + | + | Note that you need to take care as to not set it to something that + | may conflict with other parts, such as media or posts directories. + | + | The default value is 'docs'. For easy versioning you can do what + | HydePHP.com does, setting it to 'docs/master'. + | + */ + + 'output_directory' => 'docs', + + + /* + |-------------------------------------------------------------------------- + | Sidebar Page Order + |-------------------------------------------------------------------------- + | + | In the generated Documentation pages the navigation links in the sidebar + | are sorted alphabetically by default. As this rarely makes sense, you + | can reorder the page slugs in the list and the links will be sorted + | in that order. Link items without an entry here will have fall + | back to the default priority of 999, putting them last. + | + | You can also set explicit priorities in front matter. + | + */ + + 'sidebar_order' => [ + 'readme', + 'installation', + 'getting-started', + ], + + /* + |-------------------------------------------------------------------------- + | Table of Contents Settings + |-------------------------------------------------------------------------- + | + | The Hyde Documentation Module comes with a fancy Sidebar that, by default, + | has a Table of Contents included. Here, you can configure its behavior, + | content, look and feel. You can also disable the feature completely. + | + */ + + 'table_of_contents' => [ + 'enabled' => true, + 'min_heading_level' => 2, + 'max_heading_level' => 4, + ], +]; \ No newline at end of file diff --git a/config/hyde.php b/config/hyde.php index f9640f53..f300a9ce 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -182,38 +182,7 @@ '404', ], - /* - |-------------------------------------------------------------------------- - | Documentation Sidebar Header Name - |-------------------------------------------------------------------------- - | - | By default, the sidebar title shown in the documentation page layouts uses - | the app name suffixed with "docs". You can change it with this setting. - | - */ - - 'docs_sidebar_header_title' => $siteName.' Docs', - - /* - |-------------------------------------------------------------------------- - | Documentation Site Output Directory - |-------------------------------------------------------------------------- - | - | If you want to store the compiled documentation pages in a different - | directory than the default 'docs' directory, for example to set the - | specified version, you can specify the directory here. - | - | Note that you need to take care as to not set it to something that - | may conflict with other parts, such as media or posts directories. - | - | The default value is 'docs'. - | - */ - - /** - * @deprecated version 0.25.0, will be renamed to documentationOutputPath - */ - 'docs_directory' => 'docs', + /* |-------------------------------------------------------------------------- @@ -230,41 +199,6 @@ 'site_output_path' => Hyde\Framework\Hyde::path('_site'), - /* - |-------------------------------------------------------------------------- - | Documentation Sidebar Page Order - |-------------------------------------------------------------------------- - | - | In the generated Documentation pages the navigation links in the sidebar - | are sorted alphabetically by default. As this rarely makes sense, you - | can reorder the page slugs in the list and the links will be sorted - | in that order. Link items without an entry here will have fall - | back to the default priority of 999, putting them last. - | - */ - - 'documentation_page_order' => [ - 'readme', - 'installation', - 'getting-started', - ], - - /* - |-------------------------------------------------------------------------- - | Documentation Table of Contents Settings - |-------------------------------------------------------------------------- - | - | The Hyde Documentation Module comes with a fancy Sidebar that, by default, - | has a Table of Contents included. Here, you can configure its behavior, - | content, look and feel. You can also disable the feature completely. - | - */ - - 'documentation_page_table_of_contents' => [ - 'enabled' => true, - 'min_heading_level' => 2, - 'max_heading_level' => 4, - ], /* |-------------------------------------------------------------------------- diff --git a/resources/views/layouts/docs.blade.php b/resources/views/layouts/docs.blade.php index a6def2f7..30cad9ce 100644 --- a/resources/views/layouts/docs.blade.php +++ b/resources/views/layouts/docs.blade.php @@ -15,10 +15,10 @@ @if(Hyde::docsIndexPath() !== false) - {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} + {{ config('docs.title', 'Documentation') }} @else - {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} + {{ config('docs.title', 'Documentation') }} @endif @include('hyde::components.navigation.theme-toggle-button') @@ -35,10 +35,10 @@ @if(Hyde::docsIndexPath() !== false) - {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} + {{ config('docs.title', 'Documentation') }} @else - {{ config('hyde.docs_sidebar_header_title', 'Documentation') }} + {{ config('docs.title', 'Documentation') }} @endif @include('hyde::components.navigation.theme-toggle-button') diff --git a/src/Actions/GeneratesTableOfContents.php b/src/Actions/GeneratesTableOfContents.php index ae939194..7b853902 100644 --- a/src/Actions/GeneratesTableOfContents.php +++ b/src/Actions/GeneratesTableOfContents.php @@ -30,8 +30,8 @@ public function execute(): string 'html_class' => 'table-of-contents', 'position' => 'top', 'style' => 'bullet', - 'min_heading_level' => config('hyde.documentation_page_table_of_contents.min_heading_level', 2), - 'max_heading_level' => config('hyde.documentation_page_table_of_contents.max_heading_level', 4), + 'min_heading_level' => config('docs.table_of_contents.min_heading_level', 2), + 'max_heading_level' => config('docs.table_of_contents.max_heading_level', 4), 'normalize' => 'relative', ], 'heading_permalink' => [ diff --git a/src/Concerns/HasTableOfContents.php b/src/Concerns/HasTableOfContents.php index 06c584d9..e38ffbe8 100644 --- a/src/Concerns/HasTableOfContents.php +++ b/src/Concerns/HasTableOfContents.php @@ -15,7 +15,7 @@ trait HasTableOfContents public function constructTableOfContents(): void { - if (config('hyde.documentation_page_table_of_contents.enabled', true)) { + if (config('docs.table_of_contents.enabled', true)) { $this->tableOfContents = (new GeneratesTableOfContents($this->body))->execute(); } } diff --git a/src/Concerns/Internal/FileHelpers.php b/src/Concerns/Internal/FileHelpers.php index 2ad85cac..b3eaf03a 100644 --- a/src/Concerns/Internal/FileHelpers.php +++ b/src/Concerns/Internal/FileHelpers.php @@ -17,7 +17,7 @@ trait FileHelpers * * @deprecated will be renamed to be more distinct from other path helpers. * Naming suggestion is `getDocumentationOutputPath()`. - * The configuration is deprecated as well and will be renamed. + * The configuration option has been renamed. * * @todo Test and if needed add support for storing documentation files in the site root * @@ -25,7 +25,7 @@ trait FileHelpers */ public static function docsDirectory(): string { - return trim(config('hyde.docs_directory', 'docs'), '/\\'); + return trim(config('docs.output_directory', 'docs'), '/\\'); } /** diff --git a/src/Concerns/Markdown/HasMarkdownFeatures.php b/src/Concerns/Markdown/HasMarkdownFeatures.php index 74d3f274..889cf29f 100644 --- a/src/Concerns/Markdown/HasMarkdownFeatures.php +++ b/src/Concerns/Markdown/HasMarkdownFeatures.php @@ -11,6 +11,6 @@ trait HasMarkdownFeatures { public static function hasTableOfContents(): bool { - return config('hyde.documentation_page_table_of_contents.enabled', true); + return config('docs.table_of_contents.enabled', true); } } diff --git a/src/Models/DocumentationSidebarItem.php b/src/Models/DocumentationSidebarItem.php index ecb662ea..53b4fb11 100644 --- a/src/Models/DocumentationSidebarItem.php +++ b/src/Models/DocumentationSidebarItem.php @@ -30,7 +30,7 @@ public function __construct(string $label, string $destination, ?int $priority = protected function findPriorityInConfig(string $slug): int { - $orderIndexArray = config('hyde.documentationPageOrder', []); + $orderIndexArray = config('docs.sidebar_order', []); if (! in_array($slug, $orderIndexArray)) { return 500; diff --git a/tests/Feature/Services/DocumentationSidebarServiceTest.php b/tests/Feature/Services/DocumentationSidebarServiceTest.php index f5fada57..1ae0ce9e 100644 --- a/tests/Feature/Services/DocumentationSidebarServiceTest.php +++ b/tests/Feature/Services/DocumentationSidebarServiceTest.php @@ -79,7 +79,7 @@ public function test_files_with_front_matter_hidden_set_to_true_are_removed_from public function test_sidebar_is_ordered_alphabetically_when_no_order_is_set_in_config() { - Config::set('hyde.documentationPageOrder', []); + Config::set('docs.sidebar_order', []); touch(Hyde::path('_docs/alpha.md')); touch(Hyde::path('_docs/bravo.md')); touch(Hyde::path('_docs/charlie.md')); @@ -93,7 +93,7 @@ public function test_sidebar_is_ordered_alphabetically_when_no_order_is_set_in_c public function test_sidebar_is_ordered_by_priority_when_priority_is_set_in_config() { - Config::set('hyde.documentationPageOrder', [ + Config::set('docs.sidebar_order', [ 'charlie', 'bravo', 'alpha', @@ -127,14 +127,14 @@ public function test_sidebar_item_priority_set_in_config_overrides_front_matter( (new ConvertsArrayToFrontMatter)->execute(['priority' => 25]) ); - Config::set('hyde.documentationPageOrder', ['foo']); + Config::set('docs.sidebar_order', ['foo']); $this->assertEquals(25, DocumentationSidebarService::get()->first()->priority); } public function test_sidebar_priorities_can_be_set_in_both_front_matter_and_config() { - Config::set('hyde.documentationPageOrder', [ + Config::set('docs.sidebar_order', [ 'first', 'third', 'second', diff --git a/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php b/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php index e8b1bdf4..5c1c1461 100644 --- a/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php +++ b/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php @@ -95,7 +95,7 @@ public function test_has_features_array_can_enable_permalinks() // Test that method canEnablePermalinks is automatically for DocumentationPages public function test_has_features_array_can_enable_permalinks_auto() { - Config::set('hyde.documentationPageTableOfContents.enabled', true); + Config::set('docs.table_of_contents.enabled', true); $this->sourceModel = DocumentationPage::class; $this->assertTrue($this->canEnablePermalinks()); diff --git a/tests/Feature/StaticPageBuilderTest.php b/tests/Feature/StaticPageBuilderTest.php index c90a856d..76f022e6 100644 --- a/tests/Feature/StaticPageBuilderTest.php +++ b/tests/Feature/StaticPageBuilderTest.php @@ -106,7 +106,7 @@ public function test_creates_custom_documentation_directory() { $page = new DocumentationPage([], '# Body', 'Title', 'foo'); - Config::set('hyde.docsDirectory', 'docs/foo'); + Config::set('docs.output_directory', 'docs/foo'); new StaticPageBuilder($page, true); diff --git a/tests/Unit/HasMarkdownFeaturesTest.php b/tests/Unit/HasMarkdownFeaturesTest.php index 9b14727f..28b63622 100644 --- a/tests/Unit/HasMarkdownFeaturesTest.php +++ b/tests/Unit/HasMarkdownFeaturesTest.php @@ -17,10 +17,10 @@ public function test_has_table_of_contents() { $this->assertIsBool(static::hasTableOfContents()); - Config::set('hyde.documentationPageTableOfContents.enabled', true); + Config::set('docs.table_of_contents.enabled', true); $this->assertTrue(static::hasTableOfContents()); - Config::set('hyde.documentationPageTableOfContents.enabled', false); + Config::set('docs.table_of_contents.enabled', false); $this->assertFalse(static::hasTableOfContents()); } } From f578855047113c3181c9869f1ec9d4d521c3bd62 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:47:06 +0200 Subject: [PATCH 09/15] Use the snake_case config format --- src/Commands/HydeBuildStaticSiteCommand.php | 2 +- .../Feature/Concerns/HasPageMetadataTest.php | 4 +-- tests/Feature/Services/SitemapServiceTest.php | 4 +-- .../Unit/FileHelperPageLinkPrettyUrlTest.php | 26 +++++++++---------- tests/Unit/FileHelperRelativeLinkTest.php | 12 ++++----- tests/Unit/MarkdownPostHelpersTest.php | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Commands/HydeBuildStaticSiteCommand.php b/src/Commands/HydeBuildStaticSiteCommand.php index a9e0fa83..9d78b9be 100644 --- a/src/Commands/HydeBuildStaticSiteCommand.php +++ b/src/Commands/HydeBuildStaticSiteCommand.php @@ -106,7 +106,7 @@ protected function runPreBuildActions(): void if ($this->option('pretty-urls')) { $this->info('Generating site with pretty URLs'); $this->newLine(); - Config::set(['hyde.prettyUrls' => true]); + Config::set(['hyde.pretty_urls' => true]); } } diff --git a/tests/Feature/Concerns/HasPageMetadataTest.php b/tests/Feature/Concerns/HasPageMetadataTest.php index d423e783..ffcf0cd1 100644 --- a/tests/Feature/Concerns/HasPageMetadataTest.php +++ b/tests/Feature/Concerns/HasPageMetadataTest.php @@ -20,7 +20,7 @@ protected function setUp(): void config(['hyde.meta' => []]); config(['hyde.site_url' => null]); - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); config(['hyde.generateSitemap' => false]); } @@ -46,7 +46,7 @@ public function test_get_canonical_url_returns_pretty_url_for_top_level_page() public string $slug = 'foo'; }; config(['hyde.site_url' => 'https://example.com']); - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('https://example.com/foo', $page->getCanonicalUrl()); } diff --git a/tests/Feature/Services/SitemapServiceTest.php b/tests/Feature/Services/SitemapServiceTest.php index 98f700df..1eee71aa 100644 --- a/tests/Feature/Services/SitemapServiceTest.php +++ b/tests/Feature/Services/SitemapServiceTest.php @@ -112,7 +112,7 @@ public function test_can_generate_sitemap_helper_returns_false_if_sitemaps_are_d public function test_url_item_is_generated_correctly() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); config(['hyde.site_url' => 'https://example.com']); touch(Hyde::path('_pages/0-test.blade.php')); @@ -129,7 +129,7 @@ public function test_url_item_is_generated_correctly() public function test_url_item_is_generated_with_pretty_ur_ls_if_enabled() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); config(['hyde.site_url' => 'https://example.com']); touch(Hyde::path('_pages/0-test.blade.php')); diff --git a/tests/Unit/FileHelperPageLinkPrettyUrlTest.php b/tests/Unit/FileHelperPageLinkPrettyUrlTest.php index 6255ce4c..d4c1a6bb 100644 --- a/tests/Unit/FileHelperPageLinkPrettyUrlTest.php +++ b/tests/Unit/FileHelperPageLinkPrettyUrlTest.php @@ -14,82 +14,82 @@ class FileHelperPageLinkPrettyUrlTest extends TestCase { public function test_helper_returns_string_as_is_if_pretty_urls_is_not_true() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->assertEquals('foo/bar.html', Hyde::pageLink('foo/bar.html')); } public function test_helper_returns_pretty_url_if_pretty_urls_is_true() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('foo/bar', Hyde::pageLink('foo/bar.html')); } public function test_non_pretty_urls_is_default_value_when_config_is_not_set() { - config(['hyde.prettyUrls' => null]); + config(['hyde.pretty_urls' => null]); $this->assertEquals('foo/bar.html', Hyde::pageLink('foo/bar.html')); } public function test_helper_respects_absolute_urls() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->assertEquals('/foo/bar.html', Hyde::pageLink('/foo/bar.html')); } public function test_helper_respects_pretty_absolute_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('/foo/bar', Hyde::pageLink('/foo/bar.html')); } public function test_helper_respects_relative_urls() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->assertEquals('../foo/bar.html', Hyde::pageLink('../foo/bar.html')); } public function test_helper_respects_pretty_relative_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('../foo/bar', Hyde::pageLink('../foo/bar.html')); } public function test_non_html_links_are_not_modified() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('/foo/bar.jpg', Hyde::pageLink('/foo/bar.jpg')); } public function test_helper_respects_absolute_urls_with_pretty_urls_enabled() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('/foo/bar.jpg', Hyde::pageLink('/foo/bar.jpg')); } public function test_helper_rewrites_index_when_using_pretty_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('/', Hyde::pageLink('index.html')); } public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->assertEquals('index.html', Hyde::pageLink('index.html')); } public function test_helper_rewrites_documentation_page_index_when_using_pretty_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('docs/', Hyde::pageLink('docs/index.html')); } public function test_helper_does_not_rewrite_documentation_page_index_when_not_using_pretty_urls() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->assertEquals('docs/index.html', Hyde::pageLink('docs/index.html')); } } diff --git a/tests/Unit/FileHelperRelativeLinkTest.php b/tests/Unit/FileHelperRelativeLinkTest.php index acb93485..07b4a7e9 100644 --- a/tests/Unit/FileHelperRelativeLinkTest.php +++ b/tests/Unit/FileHelperRelativeLinkTest.php @@ -66,27 +66,27 @@ public function test_helper_handles_different_file_extensions() // Test helper returns pretty URL if enabled and destination is a HTML file public function test_helper_returns_pretty_url_if_enabled_and_destination_is_a_html_file() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('../foo', Hyde::relativeLink('foo.html', 'foo/bar.html')); } // Test helper method does not require current path to be HTML to use pretty URLs public function test_helper_method_does_not_require_current_path_to_be_html_to_use_pretty_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('../foo', Hyde::relativeLink('foo.html', 'foo/bar')); } // Test helper returns does not return pretty URL if when enabled but and destination is not a HTML file public function test_helper_returns_does_not_return_pretty_url_if_when_enabled_but_and_destination_is_not_a_html_file() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('../foo.png', Hyde::relativeLink('foo.png', 'foo/bar.html')); } public function test_helper_rewrites_index_when_using_pretty_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('/', Hyde::relativeLink('index.html', 'foo.html')); $this->assertEquals('../', Hyde::relativeLink('index.html', 'foo/bar.html')); $this->assertEquals('../../', Hyde::relativeLink('index.html', 'foo/bar/baz.html')); @@ -94,7 +94,7 @@ public function test_helper_rewrites_index_when_using_pretty_urls() public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls() { - config(['hyde.prettyUrls' => false]); + config(['hyde.pretty_urls' => false]); $this->assertEquals('index.html', Hyde::relativeLink('index.html', 'foo.html')); $this->assertEquals('../index.html', Hyde::relativeLink('index.html', 'foo/bar.html')); $this->assertEquals('../../index.html', Hyde::relativeLink('index.html', 'foo/bar/baz.html')); @@ -102,7 +102,7 @@ public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls() public function test_helper_rewrites_documentation_page_index_when_using_pretty_urls() { - config(['hyde.prettyUrls' => true]); + config(['hyde.pretty_urls' => true]); $this->assertEquals('docs/', Hyde::relativeLink('docs/index.html', 'foo.html')); $this->assertEquals('docs/', Hyde::relativeLink('docs/index.html', 'docs.html')); $this->assertEquals('../docs/', Hyde::relativeLink('docs/index.html', 'foo/bar.html')); diff --git a/tests/Unit/MarkdownPostHelpersTest.php b/tests/Unit/MarkdownPostHelpersTest.php index 24577721..f8de62b1 100644 --- a/tests/Unit/MarkdownPostHelpersTest.php +++ b/tests/Unit/MarkdownPostHelpersTest.php @@ -25,7 +25,7 @@ public function test_get_canonical_link_returns_canonical_uri_path_for_post_slug public function test_get_canonical_link_returns_pretty_url_when_enabled() { - config(['hyde.site_url' => 'https://example.com', 'hyde.prettyUrls' => true]); + config(['hyde.site_url' => 'https://example.com', 'hyde.pretty_urls' => true]); $post = new MarkdownPost([], '', '', 'foo-bar'); $this->assertEquals('https://example.com/posts/foo-bar', $post->getCanonicalLink()); } From 668c2be2ce8feeb865e04f2c4337fc4959156620 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:47:54 +0200 Subject: [PATCH 10/15] Use the snake_case config format --- tests/Feature/Commands/BuildStaticSiteCommandTest.php | 4 ++-- tests/Feature/Commands/HydeBuildSitemapCommandTest.php | 4 ++-- tests/Feature/Concerns/HasPageMetadataTest.php | 6 +++--- tests/Feature/Services/SitemapServiceTest.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Feature/Commands/BuildStaticSiteCommandTest.php b/tests/Feature/Commands/BuildStaticSiteCommandTest.php index bd60930c..66f15299 100644 --- a/tests/Feature/Commands/BuildStaticSiteCommandTest.php +++ b/tests/Feature/Commands/BuildStaticSiteCommandTest.php @@ -96,7 +96,7 @@ public function test_pretty_urls_option_output() public function test_sitemap_is_not_generated_when_conditions_are_not_met() { config(['hyde.site_url' => '']); - config(['hyde.generateSitemap' => false]); + config(['hyde.generate_sitemap' => false]); $this->artisan('build') ->doesntExpectOutput('Generating sitemap...') @@ -106,7 +106,7 @@ public function test_sitemap_is_not_generated_when_conditions_are_not_met() public function test_sitemap_is_generated_when_conditions_are_met() { config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateSitemap' => true]); + config(['hyde.generate_sitemap' => true]); $this->artisan('build') ->expectsOutput('Generating sitemap...') diff --git a/tests/Feature/Commands/HydeBuildSitemapCommandTest.php b/tests/Feature/Commands/HydeBuildSitemapCommandTest.php index f1f5fdda..be5df588 100644 --- a/tests/Feature/Commands/HydeBuildSitemapCommandTest.php +++ b/tests/Feature/Commands/HydeBuildSitemapCommandTest.php @@ -13,7 +13,7 @@ class HydeBuildSitemapCommandTest extends TestCase public function test_sitemap_is_not_generated_when_conditions_are_not_met() { config(['hyde.site_url' => '']); - config(['hyde.generateSitemap' => false]); + config(['hyde.generate_sitemap' => false]); unlinkIfExists(Hyde::path('_site/sitemap.xml')); $this->artisan('build:sitemap') @@ -26,7 +26,7 @@ public function test_sitemap_is_not_generated_when_conditions_are_not_met() public function test_sitemap_is_generated_when_conditions_are_met() { config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateSitemap' => true]); + config(['hyde.generate_sitemap' => true]); unlinkIfExists(Hyde::path('_site/sitemap.xml')); $this->artisan('build:sitemap') diff --git a/tests/Feature/Concerns/HasPageMetadataTest.php b/tests/Feature/Concerns/HasPageMetadataTest.php index ffcf0cd1..9e6980d1 100644 --- a/tests/Feature/Concerns/HasPageMetadataTest.php +++ b/tests/Feature/Concerns/HasPageMetadataTest.php @@ -21,7 +21,7 @@ protected function setUp(): void config(['hyde.meta' => []]); config(['hyde.site_url' => null]); config(['hyde.pretty_urls' => false]); - config(['hyde.generateSitemap' => false]); + config(['hyde.generate_sitemap' => false]); } public function test_get_canonical_url_returns_url_for_top_level_page() @@ -212,7 +212,7 @@ public function test_get_dynamic_metadata_adds_sitemap_link_when_conditions_are_ use HasPageMetadata; }; config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateSitemap' => true]); + config(['hyde.generate_sitemap' => true]); $this->assertEquals([''], $page->getDynamicMetadata() @@ -226,7 +226,7 @@ public function test_get_dynamic_metadata_does_not_add_sitemap_link_when_conditi use HasPageMetadata; }; config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateSitemap' => false]); + config(['hyde.generate_sitemap' => false]); $this->assertEquals([], $page->getDynamicMetadata() diff --git a/tests/Feature/Services/SitemapServiceTest.php b/tests/Feature/Services/SitemapServiceTest.php index 1eee71aa..7d96fd61 100644 --- a/tests/Feature/Services/SitemapServiceTest.php +++ b/tests/Feature/Services/SitemapServiceTest.php @@ -106,7 +106,7 @@ public function test_can_generate_sitemap_helper_returns_false_if_hyde_does_not_ public function test_can_generate_sitemap_helper_returns_false_if_sitemaps_are_disabled_in_config() { config(['hyde.site_url' => 'foo']); - config(['hyde.generateSitemap' => false]); + config(['hyde.generate_sitemap' => false]); $this->assertFalse(SitemapService::canGenerateSitemap()); } From 7531b44bdc509e05d54bfe20771b72875dc24996 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 21:48:29 +0200 Subject: [PATCH 11/15] Use the snake_case config format --- tests/Feature/Commands/BuildStaticSiteCommandTest.php | 4 ++-- tests/Feature/Commands/HydeBuildRssFeedCommandTest.php | 6 +++--- tests/Feature/Services/RssFeedServiceTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Feature/Commands/BuildStaticSiteCommandTest.php b/tests/Feature/Commands/BuildStaticSiteCommandTest.php index 66f15299..41a0a8a5 100644 --- a/tests/Feature/Commands/BuildStaticSiteCommandTest.php +++ b/tests/Feature/Commands/BuildStaticSiteCommandTest.php @@ -117,7 +117,7 @@ public function test_sitemap_is_generated_when_conditions_are_met() public function test_rss_feed_is_not_generated_when_conditions_are_not_met() { config(['hyde.site_url' => '']); - config(['hyde.generateRssFeed' => false]); + config(['hyde.generate_rss_feed' => false]); $this->artisan('build') ->doesntExpectOutput('Generating RSS feed...') @@ -127,7 +127,7 @@ public function test_rss_feed_is_not_generated_when_conditions_are_not_met() public function test_rss_feed_is_generated_when_conditions_are_met() { config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateRssFeed' => true]); + config(['hyde.generate_rss_feed' => true]); $this->artisan('build') ->expectsOutput('Generating RSS feed...') diff --git a/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php b/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php index 22411c0c..44ff734a 100644 --- a/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php +++ b/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php @@ -13,7 +13,7 @@ class HydeBuildRssFeedCommandTest extends TestCase public function test_rss_feed_is_not_generated_when_conditions_are_not_met() { config(['hyde.site_url' => '']); - config(['hyde.generateRssFeed' => false]); + config(['hyde.generate_rss_feed' => false]); unlinkIfExists(Hyde::path('_site/feed.xml')); $this->artisan('build:rss') @@ -25,7 +25,7 @@ public function test_rss_feed_is_not_generated_when_conditions_are_not_met() public function test_rss_feed_is_generated_when_conditions_are_met() { config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateRssFeed' => true]); + config(['hyde.generate_rss_feed' => true]); unlinkIfExists(Hyde::path('_site/feed.xml')); $this->artisan('build:rss') @@ -39,7 +39,7 @@ public function test_rss_feed_is_generated_when_conditions_are_met() public function test_rss_filename_can_be_changed() { config(['hyde.site_url' => 'https://example.com']); - config(['hyde.generateRssFeed' => true]); + config(['hyde.generate_rss_feed' => true]); config(['hyde.rssFilename' => 'blog.xml']); unlinkIfExists(Hyde::path('_site/feed.xml')); diff --git a/tests/Feature/Services/RssFeedServiceTest.php b/tests/Feature/Services/RssFeedServiceTest.php index a6c1f984..eb81998e 100644 --- a/tests/Feature/Services/RssFeedServiceTest.php +++ b/tests/Feature/Services/RssFeedServiceTest.php @@ -150,7 +150,7 @@ public function test_can_generate_sitemap_helper_returns_false_if_hyde_does_not_ public function test_can_generate_sitemap_helper_returns_false_if_sitemaps_are_disabled_in_config() { config(['hyde.site_url' => 'foo']); - config(['hyde.generateRssFeed' => false]); + config(['hyde.generate_rss_feed' => false]); $this->assertFalse(RssFeedService::canGenerateFeed()); } } From 0105243c24669bff14799713408561b6e304afea Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 22:00:11 +0200 Subject: [PATCH 12/15] Use the snake_case config format --- src/HydeServiceProvider.php | 2 +- tests/Feature/Commands/HydeBuildRssFeedCommandTest.php | 2 +- tests/Feature/GeneratesNavigationMenuTest.php | 2 +- tests/Feature/Services/RssFeedServiceTest.php | 2 +- tests/Unit/HasPageMetadataRssFeedLinkTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HydeServiceProvider.php b/src/HydeServiceProvider.php index 440a8506..820e404b 100644 --- a/src/HydeServiceProvider.php +++ b/src/HydeServiceProvider.php @@ -59,7 +59,7 @@ function () { $this->discoverBladeViewsIn('_pages'); $this->storeCompiledSiteIn(config( - 'hyde.siteOutputPath', Hyde::path('_site') + 'hyde.site_output_path', Hyde::path('_site') )); $this->commands([ diff --git a/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php b/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php index 44ff734a..73b205c2 100644 --- a/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php +++ b/tests/Feature/Commands/HydeBuildRssFeedCommandTest.php @@ -40,7 +40,7 @@ public function test_rss_filename_can_be_changed() { config(['hyde.site_url' => 'https://example.com']); config(['hyde.generate_rss_feed' => true]); - config(['hyde.rssFilename' => 'blog.xml']); + config(['hyde.rss_filename' => 'blog.xml']); unlinkIfExists(Hyde::path('_site/feed.xml')); unlinkIfExists(Hyde::path('_site/blog.xml')); diff --git a/tests/Feature/GeneratesNavigationMenuTest.php b/tests/Feature/GeneratesNavigationMenuTest.php index a40ef782..74dd1bae 100644 --- a/tests/Feature/GeneratesNavigationMenuTest.php +++ b/tests/Feature/GeneratesNavigationMenuTest.php @@ -30,7 +30,7 @@ public function test_get_links_from_config_method() { $generator = new GeneratesNavigationMenu(currentPage: 'foo/bar'); - Config::set('hyde.navigationMenuLinks', [ + Config::set('hyde.navigation_menu_links', [ [ 'title' => 'GNMTestExt', 'destination' => 'https://example.org/test', diff --git a/tests/Feature/Services/RssFeedServiceTest.php b/tests/Feature/Services/RssFeedServiceTest.php index eb81998e..ba3f39ab 100644 --- a/tests/Feature/Services/RssFeedServiceTest.php +++ b/tests/Feature/Services/RssFeedServiceTest.php @@ -70,7 +70,7 @@ public function test_xml_channel_data_can_be_customized() { config(['hyde.name' => 'Foo']); config(['hyde.site_url' => 'https://blog.foo.com/bar']); - config(['hyde.rssDescription' => 'Foo is a web log about stuff']); + config(['hyde.rss_description' => 'Foo is a web log about stuff']); $service = new RssFeedService(); $this->assertEquals('Foo', $service->feed->channel->title); diff --git a/tests/Unit/HasPageMetadataRssFeedLinkTest.php b/tests/Unit/HasPageMetadataRssFeedLinkTest.php index abbe5507..569ae12f 100644 --- a/tests/Unit/HasPageMetadataRssFeedLinkTest.php +++ b/tests/Unit/HasPageMetadataRssFeedLinkTest.php @@ -84,7 +84,7 @@ public function test_can_use_rss_feed_uses_configured_site_url() public function test_can_use_rss_feed_uses_configured_rss_file_name() { - config(['hyde.rssFilename' => 'posts.rss']); + config(['hyde.rss_filename' => 'posts.rss']); $page = new MarkdownPost([], ''); $this->assertStringContainsString( From acc274ab510a520f6874be9bd8a7685eec674e8c Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 22:02:11 +0200 Subject: [PATCH 13/15] Deprecate YAML file --- src/Services/AuthorService.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Services/AuthorService.php b/src/Services/AuthorService.php index aa5cdddf..c7d64060 100644 --- a/src/Services/AuthorService.php +++ b/src/Services/AuthorService.php @@ -10,10 +10,17 @@ /** * Contains service methods relating to blog post authors. + * + * The YAML service is deprecated, the data will be + * fetched from the main config instead. */ class AuthorService { public string $filepath; + + /** + * @deprecated version 0.28.0 + */ public array $yaml = []; public Collection $authors; @@ -37,10 +44,14 @@ public function __construct() * Returns the filepath of the Yaml file. * * If the file does not exist, it will be created. + * @deprecated version 0.28.0 */ public function publishFile(): void { file_put_contents($this->filepath, <<<'EOF' +# Note that this file is deprecated. You'll be able to +# define authors using the Author facade in the config + # In this file you can declare custom authors. # In the default example, `mr_hyde` is the username. @@ -58,6 +69,7 @@ public function publishFile(): void /** * Parse the Yaml file. * + * @deprecated version 0.28.0 * @return array */ public function getYaml(): array From 2cef183eecc627478221be8fcfb6d33b6f082a7e Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 22 May 2022 20:06:09 +0000 Subject: [PATCH 14/15] Apply fixes from StyleCI --- config/docs.php | 10 ++++------ config/hyde.php | 3 --- src/Services/AuthorService.php | 4 +++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/config/docs.php b/config/docs.php index 01e6207a..6831c4b0 100644 --- a/config/docs.php +++ b/config/docs.php @@ -1,5 +1,5 @@ config('hyde.name', 'HydePHP').' Docs', - /* |-------------------------------------------------------------------------- | Documentation Site Output Directory @@ -37,13 +36,12 @@ | may conflict with other parts, such as media or posts directories. | | The default value is 'docs'. For easy versioning you can do what - | HydePHP.com does, setting it to 'docs/master'. + | HydePHP.com does, setting it to 'docs/master'. | */ 'output_directory' => 'docs', - /* |-------------------------------------------------------------------------- | Sidebar Page Order @@ -81,4 +79,4 @@ 'min_heading_level' => 2, 'max_heading_level' => 4, ], -]; \ No newline at end of file +]; diff --git a/config/hyde.php b/config/hyde.php index f300a9ce..3bbd8510 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -182,8 +182,6 @@ '404', ], - - /* |-------------------------------------------------------------------------- | Site Output Directory (Experimental 🧪) @@ -199,7 +197,6 @@ 'site_output_path' => Hyde\Framework\Hyde::path('_site'), - /* |-------------------------------------------------------------------------- | Warn about outdated config? diff --git a/src/Services/AuthorService.php b/src/Services/AuthorService.php index c7d64060..9efacf51 100644 --- a/src/Services/AuthorService.php +++ b/src/Services/AuthorService.php @@ -10,7 +10,7 @@ /** * Contains service methods relating to blog post authors. - * + * * The YAML service is deprecated, the data will be * fetched from the main config instead. */ @@ -44,6 +44,7 @@ public function __construct() * Returns the filepath of the Yaml file. * * If the file does not exist, it will be created. + * * @deprecated version 0.28.0 */ public function publishFile(): void @@ -70,6 +71,7 @@ public function publishFile(): void * Parse the Yaml file. * * @deprecated version 0.28.0 + * * @return array */ public function getYaml(): array From 5334c89268c5000b46f327c198e9fbda401862b7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 May 2022 22:07:19 +0200 Subject: [PATCH 15/15] Add deprecation notice --- .github/dev-docs/RELEASE-NOTES-DRAFT.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/dev-docs/RELEASE-NOTES-DRAFT.md b/.github/dev-docs/RELEASE-NOTES-DRAFT.md index 29403b4c..9292cf17 100644 --- a/.github/dev-docs/RELEASE-NOTES-DRAFT.md +++ b/.github/dev-docs/RELEASE-NOTES-DRAFT.md @@ -23,4 +23,6 @@ to update the codebase: The deprecated option named `hyde.docs_directory` has been removed. -Use `docs.output_directory` instead. \ No newline at end of file +Use `docs.output_directory` instead. + +The authors.yml has been deprecated, and will be refactored in an upcoming release. \ No newline at end of file