Skip to content

Move tabs/tab directive to rst package#1316

Merged
jaapio merged 2 commits intophpDocumentor:mainfrom
wouterj:tabs-directive-to-rst-package
Mar 18, 2026
Merged

Move tabs/tab directive to rst package#1316
jaapio merged 2 commits intophpDocumentor:mainfrom
wouterj:tabs-directive-to-rst-package

Conversation

@wouterj
Copy link
Copy Markdown
Contributor

@wouterj wouterj commented Mar 15, 2026

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 GeneralDirectiveNodeRenderer did not function properly and always threw a Twig exception when defining the global variables. I've applied a basic fix to the TwigTemplateRenderer for this, to make the new tabs test pass.

@wouterj wouterj force-pushed the tabs-directive-to-rst-package branch from 765a228 to b507896 Compare March 17, 2026 20:58
@jaapio
Copy link
Copy Markdown
Member

jaapio commented Mar 18, 2026

Thanks @wouterj, I see how this improvement will help.

wouterj added 2 commits March 18, 2026 21:40
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.
@wouterj wouterj force-pushed the tabs-directive-to-rst-package branch from b507896 to cf23efe Compare March 18, 2026 20:41
@jaapio jaapio merged commit cf6e155 into phpDocumentor:main Mar 18, 2026
58 checks passed
@wouterj wouterj deleted the tabs-directive-to-rst-package branch March 18, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants