Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DocumentationPage localPath property #324

Merged
merged 7 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ This serves two purposes:
- for new features.

### Changed
- for changes in existing functionality.
- internal: The DocumentationPage slug now behaves like other pages, and the basename is produced at runtime, see below

### Deprecated
- for soon-to-be removed features.

### Removed
- for now removed features.
- Removed `$localPath` property from DocumentationPage class, see above

### Fixed
- for any bug fixes.
Expand Down
1 change: 0 additions & 1 deletion packages/framework/src/Actions/SourceFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ protected function parseDocumentationPage(): DocumentationPage
title: FindsTitleForDocument::get($this->slug, $matter, $body),
slug: basename($this->slug),
category: $this->getDocumentationPageCategory($matter),
localPath: $this->slug
);
}

Expand Down
13 changes: 3 additions & 10 deletions packages/framework/src/Models/Pages/DocumentationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ class DocumentationPage extends AbstractMarkdownPage
*/
public ?string $category;

/**
* The path to the page relative to the configured `_docs` directory.
* Generally only needed if the page is in a subdirectory.
*/
public ?string $localPath;

public function __construct(array $matter = [], string $body = '', string $title = '', string $slug = '', ?string $category = null, ?string $localPath = null)
public function __construct(array $matter = [], string $body = '', string $title = '', string $slug = '', ?string $category = null)
{
parent::__construct($matter, $body, $title, $slug);
$this->category = $category;
$this->localPath = $localPath;
}

/** @inheritDoc */
public function getSourcePath(): string
public function getCurrentPagePath(): string
{
return is_null($this->localPath) ? parent::getSourcePath() : static::qualifyBasename($this->localPath);
return trim(static::getOutputDirectory().'/'.basename($this->slug), '/');
}

/** @internal */
Expand Down
6 changes: 6 additions & 0 deletions packages/framework/tests/Unit/DocumentationPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,10 @@ public function test_has_table_of_contents()
Config::set('docs.table_of_contents.enabled', false);
$this->assertFalse(DocumentationPage::hasTableOfContents());
}

public function test_compiled_pages_originating_in_subdirectories_get_output_to_root_docs_path()
{
$page = (new DocumentationPage([], '', '', 'foo/bar'));
$this->assertEquals('docs/bar.html', $page->getOutputPath());
}
}