From 54e822530b7cab792ed7ca30f519e3d328fa4743 Mon Sep 17 00:00:00 2001 From: Nicolas Peugnet Date: Mon, 1 Jan 2024 16:49:00 +0100 Subject: [PATCH] Add example of add_linkcode_domain usage in linkcode docs --- doc/usage/extensions/linkcode.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/usage/extensions/linkcode.rst b/doc/usage/extensions/linkcode.rst index 1a1977fc2b2..555dcb67c9e 100644 --- a/doc/usage/extensions/linkcode.rst +++ b/doc/usage/extensions/linkcode.rst @@ -38,9 +38,6 @@ Configuration - ``javascript``: ``object`` (name of the object), ``fullname`` (name of the item) - Support for other domains can be added with - :py:meth:`.Sphinx.add_linkcode_domain()`. - Example: .. code-block:: python @@ -52,3 +49,14 @@ Configuration return None filename = info['module'].replace('.', '/') return "https://somesite/sourcerepo/%s.py" % filename + + Support for other domains can be added by extensions with + :py:meth:`.Sphinx.add_linkcode_domain()`. + For example, a Sphinx extension that adds support for the ``php`` domain + could use the following code to add support for the ``php`` domain + in :mod:`~sphinx.ext.linkcode`: + + .. code-block:: python + + def setup(app): + app.add_linkcode_domain('php', ['namespace', 'class', 'fullname'])