Move tabs/tab directive to rst package#1316
Merged
jaapio merged 2 commits intophpDocumentor:mainfrom Mar 18, 2026
Merged
Conversation
10 tasks
stof
reviewed
Mar 16, 2026
packages/guides-restructured-text/src/RestructuredText/Nodes/TabsNode.php
Outdated
Show resolved
Hide resolved
765a228 to
b507896
Compare
jaapio
reviewed
Mar 18, 2026
packages/guides-theme-bootstrap/src/Bootstrap/Nodes/TabsNode.php
Outdated
Show resolved
Hide resolved
Member
|
Thanks @wouterj, I see how this improvement will help. |
This directive is also very useful outside of the Bootstrap theme (e.g. it is used by the Symfony docs with their custom theme). This moves the implementation to the guides-restructured-text and provides a smooth upgrade path in the guides-theme-bootstrap package.
After initializing the Twig Environment, no new variables can be introduced (existing ones can be changed). As Environment::load() initializes the environment, this causes issues when calling renderTemplate() afterwards. By defining them in both methods, no error is thrown.
b507896 to
cf23efe
Compare
jaapio
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symfony is using the
.. tabs::directive with our custom theme instead of BootstrapCSS. I can see this use-case for other users as well, so I propose to move the directive to the restructured-text sub-package. I provided a basic HTML template that does not work, but has enough to make a working JS implementation.I've used the technique used by Symfony for moving a class to another namespace. This provides the smoothest upgrade path, with a deprecation notice for the old class, but no break in runtime code or static analysis.
At last, it looks like the
GeneralDirectiveNodeRendererdid not function properly and always threw a Twig exception when defining the global variables. I've applied a basic fix to theTwigTemplateRendererfor this, to make the new tabs test pass.