]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Generate tarball and pdf and introduce all-docs target
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Feb 2025 13:59:31 +0000 (14:59 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Feb 2025 14:24:30 +0000 (15:24 +0100)
docs/generate-docs.py
pdns/recursordist/meson.build

index f820aabee045e260789a944e8d1a437674860579..871dd19b866dda4bb93c3689a4cf49b533c154fe 100755 (executable)
@@ -3,6 +3,7 @@
 import argparse
 import glob
 import itertools
+import os
 import subprocess
 import sys
 import venv
@@ -32,24 +33,35 @@ def main():
     subprocess.run([pip, "install", "-U", "pip", "setuptools", "wheel"], check=True)
     subprocess.run([pip, "install", "-r", requirements_file], check=True)
 
-    # Run sphinx to generate the man-pages.
+    # Run sphinx to generate the docs
     source_directory = source_root.joinpath(args.source_directory)
     target_directory = build_root.joinpath(args.target_directory)
     files = [glob.glob(str(source_root.joinpath(pat))) for pat in args.files]
     files = list(itertools.chain.from_iterable(files))
     sphinx_build = venv_directory.joinpath("bin").joinpath("sphinx-build")
-    subprocess.run(
-        [
+
+    if args.latex_name:
+        buildargs = [
+            sphinx_build,
+            "-M",
+            "latexpdf",
+            source_directory,
+            '.'
+        ]
+    else:
+        buildargs = [
             sphinx_build,
             "-b",
             "html",
             source_directory,
             target_directory,
         ]
-        + files, # default is to do all
+    subprocess.run(
+        buildargs + files, # default is to do all
         check=True
     )
-
+    if args.latex_name:
+        os.rename(build_root.joinpath('latex').joinpath(args.latex_name), args.latex_name)
 
 def create_argument_parser():
     """Create command-line argument parser."""
@@ -92,6 +104,12 @@ def create_argument_parser():
         required=True,
         help="Target directory for man-pages relative to the build root",
     )
+    parser.add_argument(
+        "--latex-name",
+        type=Path,
+        required=False,
+        help="Generate latex instead of html",
+    )
     parser.add_argument(
         "files",
         type=Path,
index 38ce7c09a7a7f0adbf32812c21114a3de4269f14..1e0b8cb680c58038f8664bb441c4dbdb2c918032 100644 (file)
@@ -734,7 +734,7 @@ dep_conf_distfile = custom_target(
   install_dir:  get_option('sysconfdir'),
 )
 
-run_target(
+html_docs = custom_target(
   'html-docs',
   command: [
       python,
@@ -745,5 +745,35 @@ run_target(
       '--requirements-file', docs_dir / 'requirements.txt',
       '--source-directory', docs_dir,
       '--target-directory', '@BUILD_ROOT@' / 'html-docs',
-  ]
-)
\ No newline at end of file
+  ],
+  output: 'html-docs',
+  console: true,
+)
+
+docs_tarball = custom_target(
+  'html-docs.tar.bz2',
+  command: ['tar', 'cjf', 'html-docs.tar.bz2', html_docs],
+  output: 'html-docs.tar.bz2',
+)
+
+latex_docs = custom_target(
+  command: [
+      python,
+      product_source_dir / docs_dir / 'generate-docs.py',
+      '--build-root', '@BUILD_ROOT@',
+      '--source-root', '@SOURCE_ROOT@',
+      '--venv-name', 'venv-docs',
+      '--requirements-file', docs_dir / 'requirements.txt',
+      '--source-directory', docs_dir,
+      '--target-directory', '@BUILD_ROOT@',
+      '--latex-name', 'PowerDNS-Recursor.pdf',
+  ],
+  output: 'PowerDNS-Recursor.pdf',
+  console: true,
+)
+
+run_target(
+  'all-docs',
+  command: ['echo', 'Generated', html_docs, docs_tarball, latex_docs],
+)
+