docs: Move the python libraries to tools/lib/python

"scripts/lib" was always a bit of an awkward place for Python modules.  We
already have tools/lib; create a tools/lib/python, move the libraries
there, and update the users accordingly.

While at it, move the contents of tools/docs/lib.  Rather than make another
directory, just put these documentation-oriented modules under "kdoc".

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <20251110220430.726665-2-corbet@lwn.net>
This commit is contained in:
Jonathan Corbet 2025-11-10 15:04:29 -07:00
parent f690e07859
commit 778b8ebe51
28 changed files with 29 additions and 19 deletions

View File

@ -1,2 +1,2 @@
[MASTER] [MASTER]
init-hook='import sys; sys.path += ["scripts/lib/kdoc", "scripts/lib/abi", "tools/docs/lib"]' init-hook='import sys; sys.path += ["tools/lib/python"]'

View File

@ -115,6 +115,6 @@ dochelp:
@echo ' make PAPER={a4|letter} Specifies the paper size used for LaTeX/PDF output.' @echo ' make PAPER={a4|letter} Specifies the paper size used for LaTeX/PDF output.'
@echo @echo
@echo ' make FONTS_CONF_DENY_VF={path} sets a deny list to block variable Noto CJK fonts' @echo ' make FONTS_CONF_DENY_VF={path} sets a deny list to block variable Noto CJK fonts'
@echo ' for PDF build. See tools/docs/lib/latex_fonts.py for more details' @echo ' for PDF build. See tools/lib/python/kdoc/latex_fonts.py for more details'
@echo @echo
@echo ' Default location for the generated documents is Documentation/output' @echo ' Default location for the generated documents is Documentation/output'

View File

@ -43,7 +43,7 @@ from sphinx.util.docutils import switch_source_input
from sphinx.util import logging from sphinx.util import logging
srctree = os.path.abspath(os.environ["srctree"]) srctree = os.path.abspath(os.environ["srctree"])
sys.path.insert(0, os.path.join(srctree, "scripts/lib/abi")) sys.path.insert(0, os.path.join(srctree, "tools/lib/python/abi"))
from abi_parser import AbiParser from abi_parser import AbiParser

View File

@ -97,7 +97,7 @@ from docutils.parsers.rst.directives.body import CodeBlock, NumberLines
from sphinx.util import logging from sphinx.util import logging
srctree = os.path.abspath(os.environ["srctree"]) srctree = os.path.abspath(os.environ["srctree"])
sys.path.insert(0, os.path.join(srctree, "tools/docs/lib")) sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc"))
from parse_data_structs import ParseDataStructs from parse_data_structs import ParseDataStructs

View File

@ -42,7 +42,7 @@ from sphinx.util import logging
from pprint import pformat from pprint import pformat
srctree = os.path.abspath(os.environ["srctree"]) srctree = os.path.abspath(os.environ["srctree"])
sys.path.insert(0, os.path.join(srctree, "scripts/lib/kdoc")) sys.path.insert(0, os.path.join(srctree, "tools/lib/python/kdoc"))
from kdoc_files import KernelFiles from kdoc_files import KernelFiles
from kdoc_output import RestFormat from kdoc_output import RestFormat

View File

@ -7412,8 +7412,7 @@ P: Documentation/doc-guide/maintainer-profile.rst
T: git git://git.lwn.net/linux.git docs-next T: git git://git.lwn.net/linux.git docs-next
F: Documentation/ F: Documentation/
F: scripts/kernel-doc* F: scripts/kernel-doc*
F: scripts/lib/abi/* F: tools/lib/python/*
F: scripts/lib/kdoc/*
F: tools/docs/ F: tools/docs/
F: tools/net/ynl/pyynl/lib/doc_generator.py F: tools/net/ynl/pyynl/lib/doc_generator.py
X: Documentation/ABI/ X: Documentation/ABI/

View File

@ -13,7 +13,7 @@ See:
import os import os
import sys import sys
LIB_DIR = "lib" LIB_DIR = "../tools/lib/python"
SRC_DIR = os.path.dirname(os.path.realpath(__file__)) SRC_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))

View File

@ -111,7 +111,7 @@ import sys
# Import Python modules # Import Python modules
LIB_DIR = "lib/kdoc" LIB_DIR = "../tools/lib/python/kdoc"
SRC_DIR = os.path.dirname(os.path.realpath(__file__)) SRC_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))

View File

@ -9,13 +9,17 @@
""" """
Detect problematic Noto CJK variable fonts. Detect problematic Noto CJK variable fonts.
or more details, see lib/latex_fonts.py. or more details, see .../tools/lib/python/kdoc/latex_fonts.py.
""" """
import argparse import argparse
import sys import sys
import os.path
from lib.latex_fonts import LatexFontChecker src_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc'))
from latex_fonts import LatexFontChecker
checker = LatexFontChecker() checker = LatexFontChecker()

View File

@ -14,7 +14,7 @@ import sys
# Import Python modules # Import Python modules
LIB_DIR = "../../scripts/lib/abi" LIB_DIR = "../lib/python/abi"
SRC_DIR = os.path.dirname(os.path.realpath(__file__)) SRC_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))

View File

@ -24,10 +24,13 @@ The optional ``FILE_RULES`` contains a set of rules like:
replace define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ :c:type:`v4l2_event_motion_det` replace define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ :c:type:`v4l2_event_motion_det`
""" """
import argparse import argparse, sys
import os.path
from lib.parse_data_structs import ParseDataStructs src_dir = os.path.dirname(os.path.realpath(__file__))
from lib.enrich_formatter import EnrichFormatter sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc'))
from parse_data_structs import ParseDataStructs
from enrich_formatter import EnrichFormatter
def main(): def main():
"""Main function""" """Main function"""

View File

@ -56,14 +56,15 @@ import sys
from concurrent import futures from concurrent import futures
from glob import glob from glob import glob
from lib.python_version import PythonVersion
from lib.latex_fonts import LatexFontChecker
LIB_DIR = "../../scripts/lib" LIB_DIR = "../lib/python"
SRC_DIR = os.path.dirname(os.path.realpath(__file__)) SRC_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR + '/kdoc')) # temporary
from python_version import PythonVersion
from latex_fonts import LatexFontChecker
from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401 from jobserver import JobserverExec # pylint: disable=C0413,C0411,E0401
# #

View File

@ -32,8 +32,11 @@ import re
import subprocess import subprocess
import sys import sys
from glob import glob from glob import glob
import os.path
from lib.python_version import PythonVersion src_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(src_dir, '../lib/python/kdoc'))
from python_version import PythonVersion
RECOMMENDED_VERSION = PythonVersion("3.4.3").version RECOMMENDED_VERSION = PythonVersion("3.4.3").version
MIN_PYTHON_VERSION = PythonVersion("3.7").version MIN_PYTHON_VERSION = PythonVersion("3.7").version