Skip to content

Add JekyllPageGenerator #10

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

Merged
merged 2 commits into from
Mar 25, 2021
Merged

Add JekyllPageGenerator #10

merged 2 commits into from
Mar 25, 2021

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Mar 18, 2021

Sniff: add getter for the standard, category and sniff name

Includes tests.

Add JekyllPageGenerator

Jekyll is the underlying technology used for GitHub Pages. Jekyll parses markdown and liquid files to HTML pages for a site.

Generally Jekyll expects "frontmatter" - a --- delimited block at the top of the markdown file -.
The existence of the frontmatter indicates to Jekyll that the page should be processed by the transformation engine and not just copied over.
Frontmatter also allows for adding variables to the page which can be used in the page/theme to do certain things.

Even though for GitHub Pages, a plugin is active which make the frontmatter not strictly necessary, for this "PHPCS docs" type of website it is useful.

By default, the first # (H1) header will be regarded as the page.title and this page title is then subsequently used in the website menu and such.

As for these sniff pages, the default title is the full sniffname Standard.Category.SniffName and the Standard and Category are already "levels" in a typical menu due to the folder structure, it is less noisy to use just the plain SniffName as the page.title.

To that end, I'm adding a separate JekyllPageGenerator class which extends the standard MarkdownGenerator class and adds the frontmatter to the page.

This will also allow for extending the available frontmatter with additional keys in the future if deemed necessary.

Includes test.

jrfnl added 2 commits March 18, 2021 07:30
Jekyll is the underlying technology used for GitHub Pages. Jekyll parses markdown and liquid files to HTML pages for a site.

Generally Jekyll expects "frontmatter" - a `---` delimited block at the top of the markdown file -.
The existence of the frontmatter indicates to Jekyll that the page should be _processed_ by the transformation engine and not just copied over.
Frontmatter also allows for adding variables to the page which can be used in the page/theme to do certain things.

Even though for GitHub Pages, a plugin is active which make the frontmatter not _strictly_ necessary, for this "PHPCS docs" type of website it is useful.

By default, the first `#` (H1) header will be regarded as the `page.title` and this page title is then subsequently used in the website menu and such.

As for these sniff pages, the default title is the full sniffname `Standard.Category.SniffName` and the `Standard` and `Category` are already "levels" in a typical menu due to the folder structure, it is less noisy to use just the plain `SniffName` as the `page.title`.

To that end, I'm adding a separate `JekyllPageGenerator` class which extends the standard `MarkdownGenerator` class and adds the _frontmatter_ to the page.

This will also allow for extending the available frontmatter with additional keys in the future if deemed necessary.

Includes test.
@afilina afilina self-assigned this Mar 18, 2021

use App\Value\Sniff;

class JekyllPageGenerator extends MarkdownGenerator implements Generator
Copy link
Collaborator

@afilina afilina Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classes should be final and we should not extend implementations. It's okay to copy an existing to make the necessary changes. We can always extract truly reusable elements and inject them as dependencies instead. The test for the new class should encompass the common elements as well, otherwise we're not truly testing them, and any unintended regressions would go unnoticed. Not a deal breaker and I'm happy to address the issue in a subsequent commit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's defer it and create a ticket to improve later.

@afilina afilina merged commit 5bc3e88 into main Mar 25, 2021
@jrfnl jrfnl deleted the feature/add-jekyllpagegenerator branch March 26, 2021 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants