-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add contents entries for domain objects #10807
Conversation
Great, this saves me from having to turn that gist into a real Sphinx extension. Does this also include support for glossary entries? I will test this out tomorrow. |
Very nice. Can you outline the requirements for a domain to hook into / support this? |
Could this change also allow the standard domain to provide objects, like the |
I've not tried this out yet, but thanks for tackling it. I've just had no time of late, so I really appreciate someone pushing it over the line! |
No, should it? Such a thing could be a follow-up PR. A |
Define the (isinstance(node, addnodes.desc) and bool(node[0]['fullname'])) is True The python domain handles the definition in A |
I included glossary entries in the gist. It would be nice if they were also added to the toc, although whether it's here or in a separate PR doesn't really matter to me. |
As I noted on the issue, I think we should keep the literal styling. This makes it easier to distinguish between functions and normal headers. Also, Sphinx always renders links to functions using |
ret: List[Node] = [] | ||
|
||
content_node: Element = nodes.section() | ||
with switch_source_input(self.state, self.content): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to see this fixed here too. I didn't look into it too deeply, but should PyModule
just use the same mechanisms as the other Py* classes (subclassing from PyObject
)?
Also I suppose the docs should be updated for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this addressed (documenting the change to py:module
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if people would want this whole thing to be disableable with a configuration option. I guess if no one asks for it it's probably better to not add it, but it does seem like it could be something someone might not want. |
Thanks all for reviews. A |
Thanks for implementing this, this is a great feature! The structure of the domain object sections (using For a live example, see https://insipid-sphinx-theme.readthedocs.io/en/sphinx5.x/showcase/api-doc.html |
Interestingly, the domain object sections get a section number in the TOC (when using the Since the sections in the main text didn't have numbers in the first place, I guess I would expect the TOC entries to have no numbers either? And the nesting in the reST section isn't correct, but the PR description already mentions that the reST domain is not supported. |
@AA-Turner thank you for doing the work to get this implemented in Sphinx proper. This is going to be a huge benefit to a lot of projects. |
Thanks for testing this Matthias.
Please may you open a new issue for this, I'm not sure I fully understand? I'd like to get this fixed before 5.2 release
I implemented support for the reST domain so nesting should work -- again please may you open a new issue with a mininal reproducer? Thanks, |
|
|
It is deliberate that the If I apply this patch, the diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index 6076eb7fb..bd507a21c 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -1024,7 +1024,7 @@ class PyModule(SphinxDirective):
content_node.document = self.state.document
nested_parse_with_titles(self.state, self.content, content_node)
- ret: List[Node] = [*content_node.children]
+ ret: List[Node] = []
if not noindex:
# note module to the domain
node_id = make_id(self.env, self.state.document, 'module', modname)
@@ -1045,6 +1045,7 @@ class PyModule(SphinxDirective):
indextext = '%s; %s' % (pairindextypes['module'], modname)
inode = addnodes.index(entries=[('pair', indextext, node_id, '', None)])
ret.append(inode)
+ ret.extend(content_node.children)
return ret
def make_old_id(self, name: str) -> str: |
@domdfcoding please may you open a new issue and tag me? This likely isn't intentional. A |
Why was the |
Thanks Jakob--at one point in the PR I was using A |
I don't think |
IIRC the implementation required handling noindex specially, but maybe that's a detail that can be worked around. |
Cleanup documentation in preparation for sphinx-doc/sphinx#10807
sphinx-doc/sphinx#10807 decided to add a feature which was enabled by default. This feature however increased the toctree's height and width by a huge amount - a breaking change. This locks sphinx to an exact version to reduce issues like this again.
sphinx-doc/sphinx#10807 decided to add a feature which was enabled by default. This feature however increased the toctree's height and width by a huge amount - a breaking change. This locks sphinx to an exact version to reduce issues like this again.
sphinx-doc/sphinx#10807 decided to add a feature which was enabled by default. This feature however increased the toctree's height and width by a huge amount - a breaking change. This locks sphinx to an exact version to reduce issues like this again.
Closes #6316, closes #10804
Per a recent request on the CPython discord, this adds entries in the table of contents for domain objects (e.g.
py:function
,js:module
, etc).It does not support objects from the C, C++, and RST domains, as well as the
option
,cmdoption
, andenvvar
objects.A draft implementation by @agoose77 and @asmeurer was useful background, thank you both for this.
Feature or Bugfix
Relates
Ping for feedback and review, from people who have commented on the linked issues/CPython Discord thread: @Phillip-M-Feldman @slateny @pradyunsg @CAM-Gerlach @tony @agoose77 @asmeurer
A