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

Set conditional tags for use during inclusion #13024

Open
nedbat opened this issue Oct 15, 2024 · 2 comments
Open

Set conditional tags for use during inclusion #13024

nedbat opened this issue Oct 15, 2024 · 2 comments
Labels
markup type:proposal a feature suggestion

Comments

@nedbat
Copy link
Contributor

nedbat commented Oct 15, 2024

I would like to have a common file that will be included in multiple places in my docs. I want to be able to use .. only:: directives in that common file, and have tags set differently by different .. include: directives so that the content is customize for each place it is included.

For example (with invented :tags: syntax):

.. common.rst

This is for everyone

.. only:: red

    Hello red team!

.. only:: blue

    Hello blue team!
Red team
========

This is for red team.

.. include:: common.rst
   :tags: red
@nedbat nedbat added the type:proposal a feature suggestion label Oct 15, 2024
@AA-Turner
Copy link
Member

I think this is reasonable, but it would mean that include directives have unique rules w.r.t. tags.

Thoughts @chrisjsewell @picnixz?

A

@timhoffm
Copy link
Contributor

The request sounds reasonable.

it would mean that include directives have unique rules w.r.t. tags.

Yes, include must influence the tags one way or the other.

Thoughts on the implementation: Tags are currently a constant global setting. Obviously, that has to be changed. There are fundamentally two ways:

  1. make tags non-constant: i.e. temporarly override the global value (think: context manager) while processing the include.

  2. make tags document-local: Tags are currently stored in the app / builder. We could attach the tags to the document instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
markup type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

3 participants