-
-
Notifications
You must be signed in to change notification settings - Fork 401
[Site] Rework Toolkit recipe rendering system, improve our Markdown converter #3256
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
Conversation
8cecca4 to
b9a35bf
Compare
| // format: "package@version", "@scope/package", "@scope/package@version" | ||
| $name = $package; | ||
| $version = null; | ||
| $versionPos = strrpos($package, '@'); | ||
| if (false !== $versionPos && 0 !== $versionPos) { | ||
| $name = substr($package, 0, $versionPos); | ||
| $version = substr($package, $versionPos + 1); | ||
| } | ||
|
|
||
| if (null !== $version) { | ||
| $dependencies[] = new NpmPackageDependency($name, new ConstraintVersion($version)); | ||
| } else { | ||
| $dependencies[] = new NpmPackageDependency($package); | ||
| $dependencies[] = new NpmPackageDependency($name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small bug, must have been cherry-picked 🙈
| '#64748b', | ||
| 'linear-gradient(142deg, #334155 -15%, #64748b 95%)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'm open to suggestions btw)
b9a35bf to
a95eee5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the Toolkit recipe rendering system by replacing hacky HTML-in-Markdown with proper CommonMark extensions. The changes improve developer experience by making Markdown templates cleaner and more maintainable, while adding support for tabs and toolkit preview rendering through custom CommonMark parsers.
Key changes:
- Introduced CommonMark extensions for tabs and toolkit preview rendering with custom parsers, nodes, and renderers
- Refactored
ToolkitServiceto extract reusable methods and simplified the markdown generation logic - Added Shell/Bash syntax highlighting support with command, comment, and option patterns
- Renamed
Toolkit_Tab*components toWysiwyg_Tab*for better semantic clarity
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
ux.symfony.com/templates/toolkit/recipe/_previewable_code_block.md.twig |
New template for rendering code blocks with preview tabs |
ux.symfony.com/templates/toolkit/recipe/_code_block.md.twig |
New template for rendering simple code blocks |
ux.symfony.com/templates/toolkit/_component.md.twig |
New unified markdown template for component documentation |
ux.symfony.com/templates/components/Toolkit/Tabs.html.twig |
Renamed tab component with updated CSS classes |
ux.symfony.com/templates/components/Toolkit/Tab/Panel.html.twig |
Tab panel component with Wysiwyg naming |
ux.symfony.com/templates/components/Toolkit/Tab/Control.html.twig |
Tab control component with updated structure |
ux.symfony.com/templates/components/Toolkit/ComponentDoc.html.twig |
Simplified to use markdownContent property |
ux.symfony.com/templates/components/Code/CodeBlockInline.html.twig |
New inline code block component with copy functionality |
ux.symfony.com/src/Util/SourceCleaner.php |
Removed obsolete cleanupTwigFile method |
ux.symfony.com/src/Twig/Components/Toolkit/ComponentDoc.php |
Refactored to use Twig templates for markdown generation |
ux.symfony.com/src/Twig/Components/Code/CodeBlockInline.php |
New component class for inline code blocks |
ux.symfony.com/src/Twig/Components/Code/CodeBlock.php |
Removed Twig file cleanup logic |
ux.symfony.com/src/Service/UxPackageRepository.php |
Updated Toolkit package colors |
ux.symfony.com/src/Service/Toolkit/ToolkitService.php |
Refactored to extract recipe data methods and made class readonly |
ux.symfony.com/src/Service/Tempest/Highlighter/HighlighterFactory.php |
Factory for creating Tempest highlighter with custom languages |
ux.symfony.com/src/Service/Tempest/Highlighter/Languages/Shell/ShellLanguage.php |
Shell language support for syntax highlighting |
ux.symfony.com/src/Service/Tempest/Highlighter/Languages/Shell/Patterns/*.php |
Shell patterns for commands, comments, and options |
ux.symfony.com/src/Service/CommonMark/Extension/ToolkitPreview/*.php |
CommonMark extension for toolkit preview blocks |
ux.symfony.com/src/Service/CommonMark/Extension/Tabs/*.php |
CommonMark extension for tabs rendering |
ux.symfony.com/src/Service/CommonMark/Extension/FencedCode/FencedCodeRenderer.php |
New renderer using CodeBlockInline component |
ux.symfony.com/src/Service/CommonMark/Extension/CodeBlockRenderer/CodeBlockRenderer.php |
Removed old code block renderer |
ux.symfony.com/src/Service/CommonMark/ConverterFactory.php |
Updated to register new CommonMark extensions |
ux.symfony.com/config/services.yaml |
Added factory for Tempest Highlighter |
ux.symfony.com/assets/styles/components/_Wysiwyg_Tabs.scss |
New styles for Wysiwyg tabs |
ux.symfony.com/assets/styles/components/_Toolkit.scss |
Extracted Toolkit-specific styles |
ux.symfony.com/assets/styles/components/_Toolkit_Tabs.scss |
Removed old Toolkit tabs styles |
ux.symfony.com/assets/styles/components/_Wysiwyg.scss |
Updated with Terminal margin and link selector |
ux.symfony.com/assets/styles/app.scss |
Fixed typo and updated imports |
src/Toolkit/src/Recipe/RecipeManifest.php |
Fixed npm dependency parsing for scoped packages without versions |
src/Toolkit/tests/Recipe/RecipeManifestTest.php |
Added test case for scoped package without version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ux.symfony.com/src/Service/CommonMark/Extension/ToolkitPreview/Parser/ToolkitPreviewParser.php
Show resolved
Hide resolved
ux.symfony.com/src/Service/CommonMark/Extension/ToolkitPreview/Parser/ToolkitPreviewParser.php
Outdated
Show resolved
Hide resolved
ux.symfony.com/src/Service/Tempest/Highlighter/Languages/Shell/Patterns/ShellCommandPattern.php
Outdated
Show resolved
Hide resolved
ux.symfony.com/src/Service/CommonMark/Extension/ToolkitPreview/Parser/ToolkitPreviewParser.php
Outdated
Show resolved
Hide resolved
ux.symfony.com/templates/components/Toolkit/Tab/Control.html.twig
Outdated
Show resolved
Hide resolved
a95eee5 to
513877a
Compare
…der (Kocal) This PR was merged into the 2.x branch. Discussion ---------- [*CS-Fixer] Ensure "apps/" exists before adding it in Finder | Q | A | -------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Documentation? | no <!-- required for new features, or documentation updates --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Update/add documentation as required (we can help!) - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Follow #3251, I noticed in #3256 that Fabbot is failing because the Finder used by PHP-CS-Fixer throw an error because the directory `apps/` does not exist (https://github.com/symfony/ux/actions/runs/20607943823/job/59187283446?pr=3256#step:4:25). Indeed, I didn't modified any files from `apps/` folder in this PR, and it looks like `Finder::in()` throws an exception when the path does not exist. Commits ------- 0e355fe [*CS-Fixer] Ensure "apps/" exists before adding it in Finder
513877a to
b7587ef
Compare


This PR aims to improve the UX and DX, on the recipe page and how it's generated.
Before, the page was generated by a Twig Component that rendered Markdown with some HTML inside. It was very hacky, because inserting raw HTML in a Markdown can be difficult and came with costs, you need to be super careful about newlines and cie.
Now, the page is still generated by a Twig Component, but it only render raw Markdown. The Markdown is then properly parsed and interpreted by the PHPLeague CommonMark system. With some custom extensions, it is now possible to easily render tabs and Toolkit example preview without any issue.
In a markdown, it is possible to render tabs with:
The
Toolkit_Tab*components have been renamed to `Wysiwyg_Tab* in order to make them generic.In a markdown, it is possible to render a Toolkit exemple preview with:
I also added a new component
CodeBlockInline, because the actualCodeBlockwas hard to use to render inline code.A super-minimal Bash language support has been added to Tempest, in order to add some colors to Bash code.
Before/after: the commands are highlighted, and copy/pastable too!
Before/after: the commands about packages dependencies are moved above, the files are not rendered in


<details>tags anymore because copy/pasting the filename was super-hard. Now, they are rendered in dedicated code-blocks, fully-expanded, with a filename and a copy button: