Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-06-15 16:43:13 +0300
committerBastien Montagne <bastien@blender.org>2022-07-01 12:14:24 +0300
commit7ec5ef4e1e3b71c87ebc6649ff9d10e07be9e725 (patch)
tree179be32a1d1abca93ed8831f69cc2293c111de5a
parent5e4a8fa12e2900ed35016cca40454280e0df9317 (diff)
Py API Doc: add runtime changelog generation to `sphinx_doc_gen.py`.
Optionally use `sphinx_changelog_gen.py` to dump current version of the API in a JSON file, and use closest previous one listed in given index file to create a changelog RST page for Sphinx. Part of {T97663}.
-rw-r--r--doc/python_api/sphinx_doc_gen.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index 107c233134e..db6b810762a 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -136,6 +136,26 @@ def handle_args():
"(default=False)",
required=False)
+ parser.add_argument(
+ "--api-changelog-generate",
+ dest="changelog",
+ default=False,
+ action='store_true',
+ help="Generate the API changelog RST file "
+ "(default=False, requires `--api-dump-index-path` parameter)",
+ required=False,
+ )
+
+ parser.add_argument(
+ "--api-dump-index-path",
+ dest="api_dump_index_path",
+ metavar='FILE',
+ default=None,
+ help="Path to the API dump index JSON file "
+ "(required when `--api-changelog-generate` is True)",
+ required=False,
+ )
+
parser.add_argument("-o", "--output",
dest="output_dir",
type=str,
@@ -473,6 +493,26 @@ if ARGS.sphinx_build_pdf:
sphinx_make_pdf_log = os.path.join(ARGS.output_dir, ".latex_make.log")
SPHINX_MAKE_PDF_STDOUT = open(sphinx_make_pdf_log, "w", encoding="utf-8")
+
+# --------------------------------CHANGELOG GENERATION--------------------------------------
+
+def generate_changelog():
+ import importlib.util
+ spec = importlib.util.spec_from_file_location("sphinx_changelog_gen",
+ os.path.abspath(os.path.join(SCRIPT_DIR, "sphinx_changelog_gen.py")))
+ sphinx_changelog_gen = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(sphinx_changelog_gen)
+
+ API_DUMP_INDEX_FILEPATH = ARGS.api_dump_index_path
+ API_DUMP_ROOT = os.path.dirname(API_DUMP_INDEX_FILEPATH)
+ API_DUMP_FILEPATH = os.path.abspath(os.path.join(API_DUMP_ROOT, BLENDER_VERSION_DOTS, "api_dump.json"))
+ API_CHANGELOG_FILEPATH = os.path.abspath(os.path.join(SPHINX_IN_TMP, "change_log.rst"))
+
+ sphinx_changelog_gen.main(("--", "--indexpath", API_DUMP_INDEX_FILEPATH, "dump", "--filepath-out", API_DUMP_FILEPATH))
+
+ sphinx_changelog_gen.main(("--", "--indexpath", API_DUMP_INDEX_FILEPATH, "changelog", "--filepath-out", API_CHANGELOG_FILEPATH))
+
+
# --------------------------------API DUMP--------------------------------------
# lame, python won't give some access
@@ -2272,6 +2312,9 @@ def main():
rna2sphinx(SPHINX_IN_TMP)
+ if ARGS.changelog:
+ generate_changelog()
+
if ARGS.full_rebuild:
# only for full updates
shutil.rmtree(SPHINX_IN, True)