From 025f20fbe7c5fcc083772d844051aacc225e0d78 Mon Sep 17 00:00:00 2001 From: Sijis Aviles Date: Tue, 9 Apr 2019 09:12:04 -0500 Subject: [PATCH] docs: Auto-create CHANGES from git --- .gitchangelog.rc | 44 +++++++++++++++++++++++++++++++++++++++++++ docs/conf.py | 6 ++++++ docs/requirements.txt | 5 +++-- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .gitchangelog.rc diff --git a/.gitchangelog.rc b/.gitchangelog.rc new file mode 100644 index 000000000..73d7ea0d2 --- /dev/null +++ b/.gitchangelog.rc @@ -0,0 +1,44 @@ +# Reference: https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.rc.reference + +FILENAME = 'CHANGES.rst' + +unreleased_version_label = 'Unreleased (master)' +include_merge = False + +section_regexps = [ + ('New', [ + r'^[Nn]ew', + r'^[Aa]dd', + ]), + ('Fixes', [ + r'^[Ff]ix', + r'^[Uu]pdate', + r'[Aa]llow', + ]), + ('Docs', [ + r'([Dd]ocs|[Dd]ocumentation)', + r'[Bb]adges?', + ]), + ('Other', None ## Match all lines + ), +] + +subject_process = (strip | ucfirst | final_dot) +ignore_regexps = [ + r'[Pp][Ee][Pp]\-?8', + r'[Tt][Yy][Pp][Oo]', + r'spelling', + #r'[Ff]ormat(ing)?', + r'^$', ## ignore commits with empty messages +] + +body_process = ReSub(r'.*', r'') | strip + +revs = ["^4.0.0", "HEAD"] + +def write_changelog(lines): + """Write changelog to file.""" + with open(FILENAME, 'wt') as f: + f.writelines(lines) + +publish = write_changelog diff --git a/docs/conf.py b/docs/conf.py index 61665a3da..dc62debf1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -120,6 +120,11 @@ def autodoc_skip_member(app, what, name, obj, skip, options): def run_apidoc(_): subprocess.check_call("sphinx-apidoc --separate -f -o . ../errbot", shell=True) +# -- Changelog ----------------------------------------------------------------- + +def run_changelog(_): + subprocess.check_call("gitchangelog", shell=True) + # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -315,3 +320,4 @@ def run_apidoc(_): def setup(app): app.connect("autodoc-skip-member", autodoc_skip_member) app.connect("builder-inited", run_apidoc) + app.connect("builder-inited", run_changelog) diff --git a/docs/requirements.txt b/docs/requirements.txt index 081820494..12b327d53 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,9 +5,10 @@ sphinx>=1.2 https://github.com/zoni/sphinx-autodoc-annotation/archive/issue-2.zip -e . -sleekxmpp +gitchangelog +hypchat irc pyfire python-telegram-bot slackclient -hypchat +sleekxmpp