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
Only create a target for object descriptions #10478
Only create a target for object descriptions #10478
Conversation
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.
This needs a lot of tests -- for the new transform and for the behaviour x each domain.
A
You also need to fix the existing test failures. A |
fa8ec4a
to
800231b
Compare
So, I added documentation and unit tests. I'm still not quiet happy with the naming of the option: |
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.
Looks good to me. I like notypesetting
as it conveys exactly what it is doing, and it is in line with noindex
and noindexentry
.
eaaf978
to
e23f883
Compare
Add option :hidden: to ObjectDescription. Currently, this option has no effect except being stored as attribute in the resulting node.
Do not produce any output only a target node if option :hidden: is given. In this case all nodes representing this ObjectDescription are replaced by a single target where the target gets assigned all ids of the replaced nodes.
Record the source information (class attributes source and line) when replacing an object description node with a target node.
The collect_ids() function uses the its second parameter ``ids: List[str]`` as in- and output parameter and always returns None. Rewrite the function to become pure and side effect free: return the list of ids as the return value not as an output parameter.
replace_node_with_target() does not access the self-instance. Thus, declare it as a static method.
Move the collect_ids() method from inside the replace_node_with_target() into the class scope (as static method) since it does not need the closure of the surrounding replace_node_with_target() method. This also gives a potential speed boost.
Inline the one-line method replace_node_with_target() into its only call site. Since there are no call sites left, remove the method afterwards.
Instead of overriding the `option_spec` variable copy the `option_spec` of the superclass and update it. This way changes in the superclass propagate to its children. This is in line how other classes use "`option_spec`-inheritance".
The alias objects override the run() method and thus do not support ``:notypesetting:`` option.
Correct node order generated by the .. js:module:: directive: When generating an index entry, the index node must come before the target node.
Correct node order generated by the .. py:module:: directive: When generating an index entry, the index node must come before the target node.
It might be that a object description has no ids associated with it, e.g. if the option :noindex: is passed. In this case we would replace the object description node with a target node, which has no ids. This breaks docutils assumption about a target node and leads not errors. Therefore, do only create a target node if we have ids to work with.
An index directive creates a index node followed by a target node. Two consecutive index directives:: .. index:: first .. index:: second create index, target, index, target, i.e. a mixture. The interspersed index nodes prevent other transformations, e.g. PropagateTargets to properly work on the target nodes. Apply a transformation which reorders mixed and consecutive index and target nodes such that first all index nodes are before all target nodes: Given the following document as input: <document> <target ids="id1" ...> <index entries="...1..."> <target ids="id2" ...> <target ids="id3" ...> <index entries="...2..."> <target ids="id4" ...> The transformed result will be: <document> <index entries="...1..."> <index entries="...2..."> <target ids="id1" ...> <target ids="id2" ...> <target ids="id3" ...> <target ids="id4" ...>
e23f883
to
fb0ad6c
Compare
Thanks for all the feedback! @AA-Turner Once this is merged #9671 can be closed as this is an alternative attempt/proof-of-concept to solving this. |
Is there anything that prevents this from being merged or what else can I do to facilitate the adoption of this? |
@AA-Turner, @tk0miya anything preventing this from being merged? |
# Conflicts: # doc/usage/restructuredtext/domains.rst # sphinx/directives/__init__.py # sphinx/domains/c.py # sphinx/domains/cpp.py # sphinx/domains/javascript.py # sphinx/domains/python.py # sphinx/transforms/__init__.py
This resolves a regression introduced in sphinx-docGH-10478 (commit 97d2c5d).
Subject: Only create a target for object descriptions
Feature or Bugfix
Purpose
Adding feature for #9662 (ability to only create a target for a domain description).
Thanks again to @jakobandersen for the inspiration.
This is #9675 repurposed and rebased onto the current 5.x. In the hope that it now gets more traction.
Open Tasks:
:hidden:
,:targetonly:
,:your-favorite-word-here:
, ...Relates