mirror of https://github.com/torvalds/linux.git
docs: conf.py: get rid of load_config.py
The code here was meant to handle 3 functions: 1. allow having a separate conf.py file, per subdir; 2. generate a list of latex documents. 3. set "subproject" tag if SPHINXDIRS points to a subdir. We don't have (1) anymore, and (3) is now properly handled entirely inside conf.py. So, only (3) is still needed, and this is a single-line change at conf.py. So, drop it, moving the remaining code to conf.py. While here, drop a duplicated $(RUSTDOC) command-line argument. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <ec998f9f268a401ca6aa36e3221d39c97efeccaa.1758361087.git.mchehab+huawei@kernel.org>
This commit is contained in:
parent
c2381e8a61
commit
72603d73fa
|
|
@ -24,7 +24,6 @@ SPHINXDIRS = .
|
|||
DOCS_THEME =
|
||||
DOCS_CSS =
|
||||
RUSTDOC =
|
||||
SPHINX_CONF = conf.py
|
||||
PAPER =
|
||||
BUILDDIR = $(obj)/output
|
||||
PDFLATEX = xelatex
|
||||
|
|
@ -60,8 +59,8 @@ else # HAVE_SPHINX
|
|||
# Common documentation targets
|
||||
htmldocs mandocs infodocs texinfodocs latexdocs epubdocs xmldocs pdfdocs linkcheckdocs:
|
||||
$(Q)@$(srctree)/tools/docs/sphinx-pre-install --version-check
|
||||
+$(Q)$(PYTHON3) $(BUILD_WRAPPER) $@ $(RUSTDOC)\
|
||||
--sphinxdirs="$(SPHINXDIRS)" --conf="$(SPHINX_CONF)" $(RUSTDOC)\
|
||||
+$(Q)$(PYTHON3) $(BUILD_WRAPPER) $@ \
|
||||
--sphinxdirs="$(SPHINXDIRS)" $(RUSTDOC) \
|
||||
--builddir="$(BUILDDIR)" --deny-vf=$(FONTS_CONF_DENY_VF) \
|
||||
--theme=$(DOCS_THEME) --css=$(DOCS_CSS) --paper=$(PAPER)
|
||||
|
||||
|
|
@ -108,9 +107,6 @@ dochelp:
|
|||
@echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
|
||||
@echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
|
||||
@echo
|
||||
@echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
|
||||
@echo ' configuration. This is e.g. useful to build with nit-picking config.'
|
||||
@echo
|
||||
@echo ' make DOCS_THEME={sphinx-theme} selects a different Sphinx theme.'
|
||||
@echo
|
||||
@echo ' make DOCS_CSS={a .css file} adds a DOCS_CSS override file for html/epub output.'
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ import sphinx
|
|||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, os.path.abspath("sphinx"))
|
||||
|
||||
from load_config import loadConfig # pylint: disable=C0413,E0401
|
||||
|
||||
# Minimal supported version
|
||||
needs_sphinx = "3.4.3"
|
||||
|
||||
|
|
@ -93,8 +91,12 @@ def config_init(app, config):
|
|||
# LaTeX and PDF output require a list of documents with are dependent
|
||||
# of the app.srcdir. Add them here
|
||||
|
||||
# When SPHINXDIRS is used, we just need to get index.rst, if it exists
|
||||
# Handle the case where SPHINXDIRS is used
|
||||
if not os.path.samefile(doctree, app.srcdir):
|
||||
# Add a tag to mark that the build is actually a subproject
|
||||
tags.add("subproject")
|
||||
|
||||
# get index.rst, if it exists
|
||||
doc = os.path.basename(app.srcdir)
|
||||
fname = "index"
|
||||
if os.path.exists(os.path.join(app.srcdir, fname + ".rst")):
|
||||
|
|
@ -583,13 +585,6 @@ pdf_documents = [
|
|||
kerneldoc_bin = "../scripts/kernel-doc.py"
|
||||
kerneldoc_srctree = ".."
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Since loadConfig overwrites settings from the global namespace, it has to be
|
||||
# the last statement in the conf.py file
|
||||
# ------------------------------------------------------------------------------
|
||||
loadConfig(globals())
|
||||
|
||||
|
||||
def setup(app):
|
||||
"""Patterns need to be updated at init time on older Sphinx versions"""
|
||||
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
# -*- coding: utf-8; mode: python -*-
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# pylint: disable=R0903, C0330, R0914, R0912, E0401
|
||||
|
||||
import os
|
||||
import sys
|
||||
from sphinx.util.osutil import fs_encoding
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
def loadConfig(namespace):
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
"""Load an additional configuration file into *namespace*.
|
||||
|
||||
The name of the configuration file is taken from the environment
|
||||
``SPHINX_CONF``. The external configuration file extends (or overwrites) the
|
||||
configuration values from the origin ``conf.py``. With this you are able to
|
||||
maintain *build themes*. """
|
||||
|
||||
config_file = os.environ.get("SPHINX_CONF", None)
|
||||
if (config_file is not None
|
||||
and os.path.normpath(namespace["__file__"]) != os.path.normpath(config_file) ):
|
||||
config_file = os.path.abspath(config_file)
|
||||
|
||||
# Let's avoid one conf.py file just due to latex_documents
|
||||
start = config_file.find('Documentation/')
|
||||
if start >= 0:
|
||||
start = config_file.find('/', start + 1)
|
||||
|
||||
end = config_file.rfind('/')
|
||||
if start >= 0 and end > 0:
|
||||
dir = config_file[start + 1:end]
|
||||
|
||||
print("source directory: %s" % dir)
|
||||
new_latex_docs = []
|
||||
latex_documents = namespace['latex_documents']
|
||||
|
||||
for l in latex_documents:
|
||||
if l[0].find(dir + '/') == 0:
|
||||
has = True
|
||||
fn = l[0][len(dir) + 1:]
|
||||
new_latex_docs.append((fn, l[1], l[2], l[3], l[4]))
|
||||
break
|
||||
|
||||
namespace['latex_documents'] = new_latex_docs
|
||||
|
||||
# If there is an extra conf.py file, load it
|
||||
if os.path.isfile(config_file):
|
||||
sys.stdout.write("load additional sphinx-config: %s\n" % config_file)
|
||||
config = namespace.copy()
|
||||
config['__file__'] = config_file
|
||||
with open(config_file, 'rb') as f:
|
||||
code = compile(f.read(), fs_encoding, 'exec')
|
||||
exec(code, config)
|
||||
del config['__file__']
|
||||
namespace.update(config)
|
||||
else:
|
||||
config = namespace.copy()
|
||||
config['tags'].add("subproject")
|
||||
namespace.update(config)
|
||||
|
|
@ -602,7 +602,7 @@ class SphinxBuilder:
|
|||
"""Remove documentation output directory"""
|
||||
shutil.rmtree(self.builddir, ignore_errors=True)
|
||||
|
||||
def build(self, target, sphinxdirs=None, conf="conf.py",
|
||||
def build(self, target, sphinxdirs=None,
|
||||
theme=None, css=None, paper=None, deny_vf=None, rustdoc=False):
|
||||
"""
|
||||
Build documentation using Sphinx. This is the core function of this
|
||||
|
|
@ -653,9 +653,6 @@ class SphinxBuilder:
|
|||
if rustdoc:
|
||||
args.extend(["-t", "rustdoc"])
|
||||
|
||||
if conf:
|
||||
self.env["SPHINX_CONF"] = self.get_path(conf, abs_path=True)
|
||||
|
||||
if not sphinxdirs:
|
||||
sphinxdirs = os.environ.get("SPHINXDIRS", ".")
|
||||
|
||||
|
|
@ -773,8 +770,6 @@ def main():
|
|||
help="Documentation target to build")
|
||||
parser.add_argument("--sphinxdirs", nargs="+",
|
||||
help="Specific directories to build")
|
||||
parser.add_argument("--conf", default="conf.py",
|
||||
help="Sphinx configuration file")
|
||||
parser.add_argument("--builddir", default="output",
|
||||
help="Sphinx configuration file")
|
||||
|
||||
|
|
@ -813,7 +808,7 @@ def main():
|
|||
verbose=args.verbose, n_jobs=args.jobs,
|
||||
interactive=args.interactive)
|
||||
|
||||
builder.build(args.target, sphinxdirs=args.sphinxdirs, conf=args.conf,
|
||||
builder.build(args.target, sphinxdirs=args.sphinxdirs,
|
||||
theme=args.theme, css=args.css, paper=args.paper,
|
||||
rustdoc=args.rustdoc, deny_vf=args.deny_vf)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue