From c31cce879929c74ce7b85dcd3c793e2e9a42de32 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Wed, 20 Jun 2018 13:05:44 -0700 Subject: [PATCH] Passthru kwargs from parse_changelog to make_app --- docs/changelog.rst | 9 +++++---- releases/util.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index da37a95..f65dc34 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,10 +2,11 @@ Changelog ========= -* :feature:`75` When loading changelogs for programmatic use (via - ``releases.util.parse_changelog`` and friends), there's now an optional - ``load_extensions`` kwarg for parsing the real underlying ``conf.py`` and - using it to initialize extensions. +* :feature:`75` Update ``releases.util.parse_changelog`` so it hands kwargs + into ``releases.util.make_app``, which in turn now accepts a + ``load_extensions`` argument triggering loading of one's configured + extensions. This is only of interest if you're using ``parse_changelog`` + directly; it does not impact normal Releases usage. * :release:`1.5.0 <2018-05-02>` * :feature:`59` Allow multiple changelog files -- ``releases_document_name`` may now optionally be a list of strings instead of a single string. Thanks to diff --git a/releases/util.py b/releases/util.py index bbaf59d..c892da7 100644 --- a/releases/util.py +++ b/releases/util.py @@ -29,7 +29,7 @@ except ImportError: from . import construct_releases, setup -def parse_changelog(path): +def parse_changelog(path, **kwargs): """ Load and parse changelog file from ``path``, returning data structures. @@ -44,6 +44,10 @@ def parse_changelog(path): print("Unreleased issues for 2.3.x: {}".format(changelog['2.3'])) print("Contents of v1.2.1: {}".format(changelog['1.2.1'])) + Aside from the documented arguments, any additional keyword arguments are + passed unmodified into an internal `get_doctree` call (which then passes + them to `make_app`). + :param str path: A relative or absolute file path string. :returns: @@ -60,7 +64,7 @@ def parse_changelog(path): ``unreleased_1_feature``, whereas one with 1.x and 2.x releases will have ``unreleased_1_feature`` and ``unreleased_2_feature``, etc). """ - app, doctree = get_doctree(path) + app, doctree = get_doctree(path, **kwargs) # Have to semi-reproduce the 'find first bullet list' bit from main code, # which is unfortunately side-effect-heavy (thanks to Sphinx plugin # design). @@ -94,7 +98,7 @@ def parse_changelog(path): return ret -def get_doctree(path): +def get_doctree(path, **kwargs): """ Obtain a Sphinx doctree from the RST file at ``path``. @@ -102,6 +106,9 @@ def get_doctree(path): Sphinx itself, but things there are pretty tightly coupled. So we wrote this. + Any additional kwargs are passed unmodified into an internal `make_app` + call. + :param str path: A relative or absolute file path string. :returns: @@ -112,7 +119,7 @@ def get_doctree(path): docname, _ = os.path.splitext(filename) # TODO: this only works for top level changelog files (i.e. ones where # their dirname is the project/doc root) - app = make_app(srcdir=root) + app = make_app(srcdir=root, **kwargs) # Create & init a BuildEnvironment. Mm, tasty side effects. app._init_env(freshenv=True) env = app.env