-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add docs on sphinx tags #4603
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
Comments
Seems very useful, I wonder how many people are aware of this functionality, maybe Sphinx heavy users, or maybe I was the only one that didn't know about this 😁 |
Does it worth to implement this as a YAML option, add validation, modify the command, etc instead of just using the I mean, we need to do some extra work and I don't think we are adding any value by using the YAML file here. Instead, by using the # conf.py
tags.add('footag') |
There is only one downside of only using the conf.py file
But not sure if that worth it |
Also, some useful tags are already provided
|
I'm not following you about the downside that you are mentioning here. Can you expand? |
@humitos I think this would be a downside if we pass tags per builder, so they are exposed on the config.py file or people only want some tags on rtd. |
I don't understand this 😕
This is still possible and simpler: # conf.py
if READTHEDOCS == 'True':
tags.add('footag')
else:
tags.add('bartag') |
Nevermind, I don't think that case is worth it p: But we could expose "something" to the rst files with a tag like .. only:: readthedocs |
That could be. It's another feature/issue, though. And it doesn't require to implement anything from our side. Just change the command on the builders to add that option. Although, I don't think it's really useful. |
I didn't realize sphinx exposed a tag element in the conf.py, that is a better ux. We should document this usage |
@agjohnson but you can't see the builder tags in the conf.py file
|
Just linking to the new docs http://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags Also:
Not sure what we want to document here. |
@stsewd what is the need to be able to see the tags? I don't think we need read access to them, just need to guide users to add them and use them. I think what we want to document is "How to have conditional content in your documentation", which describes:
I just tested this out, and it does work as I'd expect. Thinking about this more however, I thought of an additional use case. Asking users to add a Another feature we could add is dropping our own tags into
Authors could use these to make version-dependent docs: .. only:: is_stable
This version is the most stable version
Mostly just brainstorming here, perhaps there are more tags we could add automatically? Also, these are mostly features to make docs more version specific. Perhaps it would be better served by an extension that inspects |
Got it, that should be in our guides section https://docs.readthedocs.io/en/latest/guides/index.html. I'm not sure if there is a need to add tags from the rtd side, users already have access to the version from the conf.py file, maybe we can add that to the guide? Not sure about |
Yup +1 on a guide for this. They have access to the version, but most folks don't automate this or keep it up to date. I feel like we could be updating the version in conf.py for them. Hard to determine what is default and what is an intended value for |
Just pointing that we already set up a |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I will work on it. I am new to Sphinx, so I might need a little guidance along the way:sweat_smile: |
Is anyone still working on this? If I understand correctly, we need documentation on how to add tags in RTD using Sphinx? I can take this issue :) |
@potterwrit yes, you can submit a PR! |
@akien-mga sorry for the confusion, these tags, are to clasify the version, they are not sphinx tags. Also, we are removing those tags in the next release #5864 Maybe you could use env variables to have this? https://docs.readthedocs.io/en/stable/guides/environment-variables.html |
@stsewd Thanks, environment variables + some logic to parse them and append the Sphinx |
By just adding sphinx-tabs==1.1.13, I was able to get sphinx-tabs in my docs, Can I add this in doc |
@Lokesh2703 this issue is about sphinx tags, not tabs https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags. |
Should we try to contribute this upstream instead? |
If there are any improvements to the existing docs yeah, but we still need to document or put an example of how to use/expose tags specific to rtd, like #4603 (comment) and adding tags for if we are building the latest version like #4603 (comment) |
I am trying to add something like the below in
Where do we declare or configure tags in conf? |
That's a Sphinx issue. This should be raised as an issue on Sphinx, but I'm commenting here because it comes up on Google. This workaround will silence the syntax highlights and allow imports from other conf files (e.g. when you want to build sub-trees of your doc as a PDF): # Workaround to allow importing this file from other confs and remove
if 'tags' not in locals():
class Tags(dict):
def has(self, tag):
return tag in self
tags = Tags() |
Uh oh!
There was an error while loading. Please reload this page.
Another Sphinx feature that would be helpful would be addition of Sphinx tags:
http://www.sphinx-doc.org/en/stable/markup/misc.html#including-content-based-on-tags
It allows for having content like:
The tags config option is already exposed in conf.py
The text was updated successfully, but these errors were encountered: