Passthru kwargs from parse_changelog to make_app

This commit is contained in:
Jeff Forcier 2018-06-20 13:05:44 -07:00
parent 8aa126d4f5
commit c31cce8799
2 changed files with 16 additions and 8 deletions

View file

@ -2,10 +2,11 @@
Changelog Changelog
========= =========
* :feature:`75` When loading changelogs for programmatic use (via * :feature:`75` Update ``releases.util.parse_changelog`` so it hands kwargs
``releases.util.parse_changelog`` and friends), there's now an optional into ``releases.util.make_app``, which in turn now accepts a
``load_extensions`` kwarg for parsing the real underlying ``conf.py`` and ``load_extensions`` argument triggering loading of one's configured
using it to initialize extensions. 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>` * :release:`1.5.0 <2018-05-02>`
* :feature:`59` Allow multiple changelog files -- ``releases_document_name`` * :feature:`59` Allow multiple changelog files -- ``releases_document_name``
may now optionally be a list of strings instead of a single string. Thanks to may now optionally be a list of strings instead of a single string. Thanks to

View file

@ -29,7 +29,7 @@ except ImportError:
from . import construct_releases, setup from . import construct_releases, setup
def parse_changelog(path): def parse_changelog(path, **kwargs):
""" """
Load and parse changelog file from ``path``, returning data structures. 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("Unreleased issues for 2.3.x: {}".format(changelog['2.3']))
print("Contents of v1.2.1: {}".format(changelog['1.2.1'])) 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. :param str path: A relative or absolute file path string.
:returns: :returns:
@ -60,7 +64,7 @@ def parse_changelog(path):
``unreleased_1_feature``, whereas one with 1.x and 2.x releases will ``unreleased_1_feature``, whereas one with 1.x and 2.x releases will
have ``unreleased_1_feature`` and ``unreleased_2_feature``, etc). 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, # Have to semi-reproduce the 'find first bullet list' bit from main code,
# which is unfortunately side-effect-heavy (thanks to Sphinx plugin # which is unfortunately side-effect-heavy (thanks to Sphinx plugin
# design). # design).
@ -94,7 +98,7 @@ def parse_changelog(path):
return ret return ret
def get_doctree(path): def get_doctree(path, **kwargs):
""" """
Obtain a Sphinx doctree from the RST file at ``path``. 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 Sphinx itself, but things there are pretty tightly coupled. So we wrote
this. this.
Any additional kwargs are passed unmodified into an internal `make_app`
call.
:param str path: A relative or absolute file path string. :param str path: A relative or absolute file path string.
:returns: :returns:
@ -112,7 +119,7 @@ def get_doctree(path):
docname, _ = os.path.splitext(filename) docname, _ = os.path.splitext(filename)
# TODO: this only works for top level changelog files (i.e. ones where # TODO: this only works for top level changelog files (i.e. ones where
# their dirname is the project/doc root) # 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. # Create & init a BuildEnvironment. Mm, tasty side effects.
app._init_env(freshenv=True) app._init_env(freshenv=True)
env = app.env env = app.env