Fixed #29942 -- Restored source file linking in docs by using the Sphinx linkcode ext.

Co-authored-by: David Smith <smithdc@gmail.com>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
This commit is contained in:
Joachim Jablon 2023-06-02 00:33:27 +01:00 committed by nessita
parent f030236a86
commit b691accea1
11 changed files with 414 additions and 2 deletions

View file

@ -9,6 +9,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import functools
import sys
from os.path import abspath, dirname, join
@ -29,6 +30,10 @@ sys.path.insert(1, dirname(dirname(abspath(__file__))))
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.append(abspath(join(dirname(__file__), "_ext")))
# Use the module to GitHub url resolver, but import it after the _ext directoy
# it lives in has been added to sys.path.
import github_links # NOQA
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@ -40,8 +45,8 @@ extensions = [
"djangodocs",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx.ext.autosectionlabel",
"sphinx.ext.linkcode",
]
# AutosectionLabel settings.
@ -432,3 +437,9 @@ epub_cover = ("", "epub-cover.html")
# If false, no index is generated.
# epub_use_index = True
linkcode_resolve = functools.partial(
github_links.github_linkcode_resolve,
version=version,
next_version=django_next_version,
)