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

started of a domain #92

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

started of a domain #92

wants to merge 1 commit into from

Conversation

story645
Copy link
Collaborator

@story645 story645 commented Jan 8, 2024

So this is busted at the moment, but trying to shake out if it's worth it. Downside of domains is (if you don't use the primary_domain config) is that the tag becomes tag:tags:: or the like. Upside is I think it makes stuff like #66 easier b/c it's another directive in the domain and has access to the same shared list. Also if I can get this working, then tag_1 etc becomes the cross reference.

@JWCook
Copy link
Collaborator

JWCook commented Jan 28, 2024

Looks like a good start! It seems like this is probably Sphinx's recommended way of doing things like our tags index page.

Since that would be a breaking change, though, it would be good to support both the new domain and the original tags directive for awhile, and show DeprecationWarning for the latter. And then maybe remove that later on after a major version bump?

One way to do this would be:

  • Copy __init__.py from 1.3.1 to a separate module, say _compat.py
  • Remove setup() from that module
  • Add a warnings.warn(DeprecationWarning) to update_tags()
  • Add to the current __init__.py something like:
from _compat import TagLinks as TagLinksDirective
from _compat import update_tags as update_tags_directive

...

def setup(app):
    ...
    app.connect("builder-inited", update_tags_directive)
    app.add_directive("tags", TagLinksDirective)
    app.add_domain(TagDomain)

Alternatively, we could also do something simple but terrible like a str.replace("tags::", "tag:tags::") on the whole document before it's parsed 😬

@story645
Copy link
Collaborator Author

Alternatively, we could also do something simple but terrible like a str.replace("tags::", "tag:tags::") on the whole document before it's parsed 😬

I think there's also the https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-primary_domain but yeah that would be not great either, though now I'm thinking if basically in run could call out to the domain version 🤔

This was referenced Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants