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

importlib documentation doesn't declare functions properly #125018

Closed
ncoghlan opened this issue Oct 6, 2024 · 7 comments
Closed

importlib documentation doesn't declare functions properly #125018

ncoghlan opened this issue Oct 6, 2024 · 7 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@ncoghlan
Copy link
Contributor

ncoghlan commented Oct 6, 2024

https://docs.python.org/3/library/importlib.metadata.html#distribution-versions doesn't actually define a Sphinx function for version, so attempted references with `:func:`importlib.metadata.version` (including via the intersphinx extension) fail.

Edit: fixed the backticks thanks to @serhiy-storchaka's tip below (TIL that you can use repeated backticks with trailing and leading space for inline code markup, allowing inclusion of single backticks in the quoted code)

Linked PRs

@serhiy-storchaka
Copy link
Member

Use triple backticks :func:`importlib.metadata.version`.

@webknjaz
Copy link
Contributor

webknjaz commented Oct 6, 2024

@serhiy-storchaka nope, @ncoghlan is right. For the full list of exposed objects, I have this little helper that updates every several hours: https://webknjaz.github.io/intersphinx-untangled/docs.python.org/.

And the terminal way to see what's exposed would be python -Im sphinx.ext.intersphinx https://docs.python.org/en/3/objects.inv.

These references don't come from Python runtime but from Sphinx. They must be properly declared in Sphinx in order to be linkable.

Single backticks work depending on Sphinx config. In that case, it's because of default_role = 'any' that Sphinx attempts finding any object of any role matching the name in intersphinx (and the site-local domain).

@serhiy-storchaka
Copy link
Member

I meant that you can use triple quotes to quote text containing single or double backquotes in Markdown.

@ncoghlan
Copy link
Contributor Author

ncoghlan commented Oct 6, 2024

I fixed the initial post to avoid requiring imagination of the actual reference syntax (thanks to @serhiy-storchaka's tip, I learned something new about Markdown today: https://meta.stackexchange.com/questions/82718/how-do-i-escape-a-backtick-within-in-line-code-in-markdown ).

@ncoghlan ncoghlan self-assigned this Oct 6, 2024
ncoghlan added a commit to ncoghlan/cpython that referenced this issue Oct 6, 2024
This allows direct intersphinx references to APIs via references
like `` :func:`importlib.metadata.version` ``.
@ncoghlan
Copy link
Contributor Author

ncoghlan commented Oct 6, 2024

Posted a PR that adds the minimal text needed to define valid semantic cross-reference targets. The phrase "as described below" features heavily in their descriptive text, since I didn't want to embark on a wholesale rewrite of the module docs just to fix a cross-referencing issue.

@webknjaz
Copy link
Contributor

webknjaz commented Oct 6, 2024

I fixed the initial post to avoid requiring imagination of the actual reference syntax (thanks to @serhiy-storchaka's tip, I learned something new about Markdown today: meta.stackexchange.com/questions/82718/how-do-i-escape-a-backtick-within-in-line-code-in-markdown ).

One stray backtick still renders for me, though..

ncoghlan added a commit that referenced this issue Oct 7, 2024
This allows direct intersphinx references to APIs via references
like `` :func:`importlib.metadata.version` ``.

---------

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
ncoghlan added a commit to ncoghlan/cpython that referenced this issue Oct 7, 2024
…#125027)

This allows direct intersphinx references to APIs via references
like `` :func:`importlib.metadata.version` ``.

---------

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
(cherry picked from commit cda3b5a)
ncoghlan added a commit that referenced this issue Oct 7, 2024
…5027) (#125048)

This allows direct intersphinx references to APIs via references
like `` :func:`importlib.metadata.version` ``.

---------

(cherry picked from commit cda3b5a)

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
AA-Turner added a commit to AA-Turner/cpython that referenced this issue Oct 7, 2024
AA-Turner added a commit that referenced this issue Oct 7, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 7, 2024
(cherry picked from commit 10094a5)

Co-authored-by: Adam Turner <[email protected]>
AA-Turner added a commit that referenced this issue Oct 7, 2024
gh-125018: Fix role syntax (GH-125050)
(cherry picked from commit 10094a5)

Co-authored-by: Adam Turner <[email protected]>
AA-Turner added a commit that referenced this issue Oct 8, 2024
…5027) (#125047)

gh-125018: Add importlib.metadata semantic link targets (#125027)

This allows direct intersphinx references to APIs via references
like `` :func:`importlib.metadata.version` ``.

(cherry picked from commit cda3b5a)

---------

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 8, 2024
(cherry picked from commit 10094a5)

Co-authored-by: Adam Turner <[email protected]>
AA-Turner added a commit that referenced this issue Oct 8, 2024
gh-125018: Fix role syntax (GH-125050)
(cherry picked from commit 10094a5)

Co-authored-by: Adam Turner <[email protected]>
@ncoghlan
Copy link
Contributor Author

ncoghlan commented Oct 8, 2024

Thanks for the syntax cleanups @AA-Turner (I incorrectly assumed that Sphinx would error on the !~ syntax if it didn't understand it, missing the possibility that it might just treat everything after the ! as a plain text string to pass through to the rendered output, which is what actually happened).

@ncoghlan ncoghlan closed this as completed Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants