diff options
Diffstat (limited to 'tools/docs/sphinx-build-wrapper')
| -rwxr-xr-x | tools/docs/sphinx-build-wrapper | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrapper index b7c149dff06b..6f1163333a47 100755 --- a/tools/docs/sphinx-build-wrapper +++ b/tools/docs/sphinx-build-wrapper @@ -99,9 +99,9 @@ class SphinxBuilder: def get_path(self, path, use_cwd=False, abs_path=False): """ - Ancillary routine to handle patches the right way, as shell does. + Ancillary routine to handle paths the right way, as shell does. - It first expands "~" and "~user". Then, if patch is not absolute, + It first expands "~" and "~user". Then, if path is not absolute, join self.srctree. Finally, if requested, convert to abspath. """ @@ -220,6 +220,15 @@ class SphinxBuilder: self.pdflatex = os.environ.get("PDFLATEX", "xelatex") # + # Add localversion* to kernelversion if present + # + for file in glob(os.environ["srctree"] + "/localversion*"): + if not file.endswith(".orig"): + with open(file, 'r', encoding='utf-8') as f: + text = f.read() + self.kernelversion += text + + # # Kernel main Makefile defines a PYTHON3 variable whose default is # "python3". When set to a different value, it allows running a # diferent version than the default official python3 package. @@ -238,7 +247,12 @@ class SphinxBuilder: self.latexopts = os.environ.get("LATEXOPTS", "") if not verbose: - verbose = bool(os.environ.get("KBUILD_VERBOSE", "") != "") + try: + verbose = bool(int(os.environ.get("KBUILD_VERBOSE", 0))) + except ValueError: + # Handles an eventual case where verbosity is not a number + # like KBUILD_VERBOSE="" + verbose = False if verbose is not None: self.verbose = verbose @@ -576,7 +590,6 @@ class SphinxBuilder: """ re_kernel_doc = re.compile(r"^\.\.\s+kernel-doc::\s*(\S+)") - re_man = re.compile(r'^\.TH "[^"]*" (\d+) "([^"]*)"') if docs_dir == src_dir: # @@ -616,8 +629,7 @@ class SphinxBuilder: fp = None try: for line in result.stdout.split("\n"): - match = re_man.match(line) - if not match: + if not line.startswith(".TH"): if fp: fp.write(line + '\n') continue @@ -625,7 +637,11 @@ class SphinxBuilder: if fp: fp.close() - fname = f"{output_dir}/{match.group(2)}.{match.group(1)}" + # Use shlex here, as it handles well parameters with commas + args = shlex.split(line) + fname = f"{args[1]}.{args[2]}" + fname = fname.replace("/", " ") + fname = f"{output_dir}/{fname}" if self.verbose: print(f"Creating {fname}") |
