melissawm / sphinx-tags

A tiny Sphinx extension that implements blog-style tags for documentation.
https://sphinx-tags.readthedocs.io/en/latest/
MIT License
44 stars 11 forks source link

How to ignore tags directive on a specific page #105

Open RemDelaporteMathurin opened 3 months ago

RemDelaporteMathurin commented 3 months ago

We added a page to explain how to add tags to pages with two example tags (tag1 and tag2) however, these tags show up in the tag list and we would like to avoid this.

Is there a way to ignore the {tags} directive in one specific page?

story645 commented 3 months ago

My rough guess is this can maybe be implemented as add an 'ignore_file' config value that then gets parsed as part of this statement:

https://github.com/melissawm/sphinx-tags/blob/main/src%2Fsphinx_tags%2F__init__.py#L373-L377

melissawm commented 3 months ago

This is a limitation of how the parsing is done right now, and the work on https://github.com/melissawm/sphinx-tags/pull/101 should fix it, but ignoring the page seems like a reasonable solution while that's not finished. Thanks for the issue!

rekomodo commented 3 months ago

My rough guess is this can maybe be implemented as add an 'ignore_file' config value that then gets parsed as part of this statement:

https://github.com/melissawm/sphinx-tags/blob/main/src%2Fsphinx_tags%2F__init__.py#L373-L377

I tried this for our case and this approach ignores the page altogether, which makes sense since it's a sphinx setting, not a sphinx-tags setting (we wanted to have the page and ignore the tags).

Our hacky workaround was to replace the a in {tags} for the homoglyph а to avoid detection by the parser https://github.com/rekomodo/V-V-report/blob/e67161f2444af45c9c1e4beff467b4795ad2765d/report/how_to.md?plain=1#L49-L51

Thanks for the support!

story645 commented 3 months ago

which makes sense since it's a sphinx setting, not a sphinx-tags setting (we wanted to have the page and ignore the tags).

Sorry, what I meant was add a new sphinx-tags config value ignore-this-page that then gets used as part of that lookup, not use the sphinx ignore config.

melissawm commented 3 months ago

I will try to submit a PR for this later this week, and I'm happy to do a minor release for it unless I can fix it definitively as part of #101 sooner than that. If you can do it before then, I'm happy to accept any contributions!

espwangning commented 3 months ago

Thanks for the initiative and support!

In my documentation, I use the .. only:: directive together with .. tag::, for example

.. only:: v1.0

    .. tags:: Fixed

.. only:: v1.1

    .. tags:: Not fixed

When generating the tag list, it would be good for me if irrelevant .. tag:: can be ignored. Probably this can also be achieved with "new sphinx-tags config value ignore-this-page".

story645 commented 3 months ago

When generating the tag list, it would be good for me if irrelevant .. tag:: can be ignored. Probably this can also be achieved with "new sphinx-tags config value ignore-this-page".

I think that would need a different sphinx-tags config #81