summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-02-11 02:24:17 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-02-22 18:02:58 +0900
commit973c91bb1013ba977b87c20ade5e34d235f75778 (patch)
tree559c1a7b8373d577ec865f511c55d049dec0dd8c
parentbc14e8fd37e0e8ff8303f8741a9ce2033ac40a88 (diff)
downloadsphinx-git-973c91bb1013ba977b87c20ade5e34d235f75778.tar.gz
std domain: Add StandardDomain.note_hyperlink_target()
-rw-r--r--sphinx/domains/std.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 52633d194..91497035b 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -578,6 +578,30 @@ class StandardDomain(Domain):
for node, settings in env.app.registry.enumerable_nodes.items():
self.enumerable_nodes[node] = settings
+ def note_hyperlink_target(self, name: str, docname: str, node_id: str,
+ title: str = '') -> None:
+ """Add a hyperlink target for cross reference.
+
+ .. warning::
+
+ This is only for internal use. Please don't use this from your extension.
+ ``document.note_explicit_target()`` or ``note_implicit_target()`` are recommended to
+ add a hyperlink target to the document.
+
+ This only adds a hyperlink target to the StandardDomain. And this does not add a
+ node_id to node. Therefore, it is very fragile to calling this without
+ understanding hyperlink target framework in both docutils and Sphinx.
+
+ .. versionadded:: 3.0
+ """
+ if name in self.anonlabels and self.anonlabels[name] != (docname, node_id):
+ logger.warning(__('duplicate label %s, other instance in %s'),
+ name, self.env.doc2path(self.anonlabels[name][0]))
+
+ self.anonlabels[name] = (docname, node_id)
+ if title:
+ self.labels[name] = (docname, node_id, title)
+
@property
def objects(self) -> Dict[Tuple[str, str], Tuple[str, str]]:
return self.data.setdefault('objects', {}) # (objtype, name) -> docname, labelid