-
-
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
ext: allow builders to override support for linkcode references #10585
ext: allow builders to override support for linkcode references #10585
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.
+1: Reasonable. It's much better to describe this behavior in the document of linkcode extension.
Just for clarity, are you asking that we add a comment inside the implementation to explain this option, such as: @@ -24,6 +24,11 @@ def doctree_read(app: Sphinx, doctree: Node) -> None:
raise LinkcodeError(
"Function `linkcode_resolve` is not given in conf.py")
+ # By default, the linkcode extension will only inject references
+ # for an `html` builder/format. If a (third-party) builder wishes
+ # to support managing references generated by linkcode as well, they
+ # can override the `supported_linkcode` attribute in their builder
+ # definition.
node_only_expr = getattr(app.builder, 'supported_linkcode', 'html')
domain_keys = { Or is there another document you are referring to? I assume it would not be doc/usage/extensions/linkcode.rst since that is more user focused. Unless you are recommending another document somewhere inside doc/extdev? |
Please may you add the new attribute/override mechanism somewhere in the documentation, and please also update CHANGES. A |
@AA-Turner, any chance we can get this in a release window? If there is anything else that needed to be done, please let me know. |
Hi all, is there anything that can be done to get this merged? I am looking to make use of @jdknight's excellent confluencebuilder extension, but I need it to work with linkcode and this looks to be the blocker. |
For `sphinx.ext.linkcode` extension, prospect changes [1] will provide support for other Sphinx extensions to take advantage of linkcode-generated references. Updating this extension to hint that it will support `sphinx.ext.linkcode`. This should help ensure a future release the Confluence Builder extension will automatically be ready to utilize the Sphinx-managed extension (if Sphinx does update to include linkcode support for custom builders). If Sphinx changes the way of integrating with linkcode or opts to not support such an extension, the introduced line in this commit can be modified or dropped at a later time. [1]: sphinx-doc/sphinx#10585 Signed-off-by: James Knight <james.d.knight@live.com>
The original `sphinx.ext.linkcode` extension will only include references into a doctree for `html` builders. Custom builders who would like to handle linkcode references do not have a graceful way to enable this feature. This commit aims to allow custom builders to override when these references are included. If a builder defines a `supported_linkcode` attribute, this extension will use the value of this attribute to consider other builders/formats when conditionally adding references. Signed-off-by: James Knight <james.d.knight@live.com>
Adding a document under Sphinx's "extension development" chapter which provides information about integrating third-party builds with recently added features to the built-in linkcode extension. Signed-off-by: James Knight <james.d.knight@live.com>
Feature or Bugfix
Purpose
The original
sphinx.ext.linkcode
extension will only include references into a doctree forhtml
builders. Custom builders who would like to handle linkcode references do not have a graceful way to enable this feature.This commit aims to allow custom builders to override when these references are included. If a builder defines a
supported_linkcode
attribute, this extension will use the value of this attribute to consider other builders/formats when conditionally adding references.Relates