From f81f77352cbca122cf72c589b2f5d160e0db660a Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 4 Jul 2020 02:15:05 -0400 Subject: [PATCH] Restructure changelog generation as a Sphinx extension --- conf.py | 10 ++++++---- docs/sphinx_extensions/dfhack/__init__.py | 0 .../dfhack/changelog.py} | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 docs/sphinx_extensions/dfhack/__init__.py rename docs/{gen_changelog.py => sphinx_extensions/dfhack/changelog.py} (97%) diff --git a/conf.py b/conf.py index b3f2b5848..47d1c0c58 100644 --- a/conf.py +++ b/conf.py @@ -22,8 +22,6 @@ import re import shlex # pylint:disable=unused-import import sys -sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'docs')) -from gen_changelog import generate_changelog # -- Support :dfhack-keybind:`command` ------------------------------------ # this is a custom directive that pulls info from dfhack.init-example @@ -180,19 +178,23 @@ def all_keybinds_documented(): # Actually call the docs generator and run test -generate_changelog() write_script_docs() all_keybinds_documented() # -- General configuration ------------------------------------------------ +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'docs', 'sphinx_extensions')) + # If your documentation needs a minimal Sphinx version, state it here. needs_sphinx = '1.8' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.extlinks'] +extensions = [ + 'sphinx.ext.extlinks', + 'dfhack.changelog', +] # This config value must be a dictionary of external sites, mapping unique # short alias names to a base URL and a prefix. diff --git a/docs/sphinx_extensions/dfhack/__init__.py b/docs/sphinx_extensions/dfhack/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/gen_changelog.py b/docs/sphinx_extensions/dfhack/changelog.py similarity index 97% rename from docs/gen_changelog.py rename to docs/sphinx_extensions/dfhack/changelog.py index 8b1a6771e..4c0f30427 100644 --- a/docs/gen_changelog.py +++ b/docs/sphinx_extensions/dfhack/changelog.py @@ -283,3 +283,17 @@ if __name__ == '__main__': print('stable missing: ' + description) if description not in content_dev: print('dev missing: ' + description) + + +def sphinx_entrypoint(app, config): + generate_changelog() + + +def setup(app): + app.connect('config-inited', sphinx_entrypoint) + + return { + 'version': '0.1', + 'parallel_read_safe': True, + 'parallel_write_safe': True, + }