diff options
author | ptaneli <31743851+ptaneli@users.noreply.github.com> | 2018-12-24 11:55:22 +0000 |
---|---|---|
committer | Bernát Gábor <gaborjbernat@gmail.com> | 2018-12-24 13:55:22 +0200 |
commit | e8d82ce7499178afba14e425dc944e8364b7e690 (patch) | |
tree | 1f085401b376ccba126a7cf7aa39bfbd56168924 /docs/conf.py | |
parent | 971d341ce383420af342a8f9d531ce77242fda0e (diff) | |
download | virtualenv-boostrap.tar.gz |
Move to news files for changelog via towncrier. (#1234)boostrap
Closes #1230.
Co-Authored-By: Sia Agarwal <44545228+thisissia@users.noreply.github.com>
Co-Authored-By: Deniz Taneli <7292227+dtaneli@users.noreply.github.com>
Diffstat (limited to 'docs/conf.py')
-rw-r--r-- | docs/conf.py | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/docs/conf.py b/docs/conf.py index 0b2441c..e0c06a5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,27 +1,54 @@ -# -*- coding: utf-8 -*- +from __future__ import absolute_import, unicode_literals + import os +import re +import subprocess +import sys +from pathlib import Path + +from virtualenv import __version__ -on_rtd = os.environ.get("READTHEDOCS", None) == "True" extensions = ["sphinx.ext.autodoc", "sphinx.ext.extlinks"] source_suffix = ".rst" master_doc = "index" project = "virtualenv" copyright = "2007-2018, Ian Bicking, The Open Planning Project, PyPA" +ROOT_SRC_TREE_DIR = Path(__file__).parents[1] + -try: - from virtualenv import __version__ +def generate_draft_news(): + home = "https://github.com" + issue = "{}/issue".format(home) + fragments_path = ROOT_SRC_TREE_DIR / "docs" / "changelog" + for pattern, replacement in ( + (r"[^`]@([^,\s]+)", r"`@\1 <{}/\1>`_".format(home)), + (r"[^`]#([\d]+)", r"`#pr\1 <{}/\1>`_".format(issue)), + ): + for path in fragments_path.glob("*.rst"): + path.write_text(re.sub(pattern, replacement, path.read_text())) + env = os.environ.copy() + env["PATH"] += os.pathsep.join([os.path.dirname(sys.executable)] + env["PATH"].split(os.pathsep)) + changelog = subprocess.check_output( + ["towncrier", "--draft", "--version", "DRAFT"], cwd=str(ROOT_SRC_TREE_DIR), env=env + ).decode("utf-8") + if "No significant changes" in changelog: + content = "" + else: + note = "*Changes in master, but not released yet are under the draft section*." + content = "{}\n\n{}".format(note, changelog) + (ROOT_SRC_TREE_DIR / "docs" / "_draft.rst").write_text(content) - # The short X.Y version. - version = ".".join(__version__.split(".")[:2]) - # The full version, including alpha/beta/rc tags. - release = __version__ -except ImportError: - version = release = "dev" + +generate_draft_news() + +version = ".".join(__version__.split(".")[:2]) +release = __version__ today_fmt = "%B %d, %Y" unused_docs = [] pygments_style = "sphinx" +exclude_patterns = ["changelog/*"] extlinks = { "issue": ("https://github.com/pypa/virtualenv/issues/%s", "#"), @@ -29,6 +56,7 @@ extlinks = { } html_theme = "default" +on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: try: import sphinx_rtd_theme |