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

Unable to use role to reference a resource that has :noindex: #29

Open
jessetan opened this issue Oct 25, 2019 · 2 comments
Open

Unable to use role to reference a resource that has :noindex: #29

jessetan opened this issue Oct 25, 2019 · 2 comments

Comments

@jessetan
Copy link

If a resource is documented as:

.. http:get:: /myresource

  This is a resource.

It can be referenced by :http:get:`/myresource` , which turns into a clickable link.

However, I do not want my PDF to contain a routing table. So I add :noindex to the directive.
Now the role no longer produces a clickable link and Sphinx logs a warning WARNING: Cannot resolve reference to <#text: 'GET /myresource'>.

Is there a way to make a resource not appear in the routing table in a way that the role can still link to the directive?

@jessetan
Copy link
Author

As a workaround, I'm using a very small extension:

from sphinxcontrib.httpdomain import HTTPIndex

def _generate(self, docnames=None):
    return ([], True)

def setup(app):
    # Override routing table generation
    HTTPIndex.generate = _generate

    return {'version': '0.1'}   # identifies the version of our extension

@y-ishida
Copy link

y-ishida commented Mar 13, 2024

I added the code to conf.py, referring to jessetan's workaround. It works well for me.

from sphinxcontrib.httpdomain import HTTPIndex
HTTPIndex.generate = lambda a, b = None: ([], True)

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

No branches or pull requests

2 participants