aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-02-24 22:36:06 -0600
committerJason R. Coombs <jaraco@jaraco.com>2015-02-24 22:36:06 -0600
commit02fac66f96af6b6952d227809186db1c5ae628a6 (patch)
tree617fcb65a902118115d143e95dcb2202e870a5a6
parentb16a6dd269e4fd283a78834c7f379c977aad0f6e (diff)
downloadexternal_python_setuptools-02fac66f96af6b6952d227809186db1c5ae628a6.tar.gz
external_python_setuptools-02fac66f96af6b6952d227809186db1c5ae628a6.tar.bz2
external_python_setuptools-02fac66f96af6b6952d227809186db1c5ae628a6.zip
Use rst.linker for generating linked changelog
-rw-r--r--docs/conf.py49
-rw-r--r--linkify.py56
-rwxr-xr-xsetup.py1
3 files changed, 49 insertions, 57 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 5ea2e05e..24830987 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -28,7 +28,7 @@ import setup as setup_script
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['linkify']
+extensions = ['rst.linker']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -198,3 +198,50 @@ latex_documents = [
# If false, no module index is generated.
#latex_use_modindex = True
+
+link_files = {
+ 'CHANGES.txt': dict(
+ using=dict(
+ BB='https://bitbucket.org',
+ GH='https://github.com',
+ ),
+ replace=[
+ dict(
+ pattern=r"(Issue )?#(?P<issue>\d+)",
+ url='{BB}/pypa/setuptools/issue/{issue}',
+ ),
+ dict(
+ pattern=r"Pull Request ?#(?P<pull_request>\d+)",
+ url='{BB}/pypa/setuptools/pull-request/{pull_request}',
+ ),
+ dict(
+ pattern=r"Distribute #(?P<distribute>\d+)",
+ url='{BB}/tarek/distribute/issue/{distribute}',
+ ),
+ dict(
+ pattern=r"Buildout #(?P<buildout>\d+)",
+ url='{GH}/buildout/buildout/issues/{buildout}',
+ ),
+ dict(
+ pattern=r"Old Setuptools #(?P<old_setuptools>\d+)",
+ url='http://bugs.python.org/setuptools/issue{old_setuptools}',
+ ),
+ dict(
+ pattern=r"Jython #(?P<jython>\d+)",
+ url='http://bugs.jython.org/issue{jython}',
+ ),
+ dict(
+ pattern=r"Python #(?P<python>\d+)",
+ url='http://bugs.python.org/issue{python}',
+ ),
+ dict(
+ pattern=r"Interop #(?P<interop>\d+)",
+ url='{GH}/pypa/interoperability-peps/issues/{interop}',
+ ),
+ dict(
+ pattern=r"Pip #(?P<pip>\d+)",
+ url='{GH}/pypa/pip/issues/{pip}',
+ ),
+ ],
+ ),
+}
diff --git a/linkify.py b/linkify.py
deleted file mode 100644
index 5c6e16b4..00000000
--- a/linkify.py
+++ /dev/null
@@ -1,56 +0,0 @@
-"""
-Sphinx plugin to add links to the changelog.
-"""
-
-import re
-import os
-
-
-link_patterns = [
- r"(Issue )?#(?P<issue>\d+)",
- r"Pull Request ?#(?P<pull_request>\d+)",
- r"Distribute #(?P<distribute>\d+)",
- r"Buildout #(?P<buildout>\d+)",
- r"Old Setuptools #(?P<old_setuptools>\d+)",
- r"Jython #(?P<jython>\d+)",
- r"Python #(?P<python>\d+)",
- r"Interop #(?P<interop>\d+)",
- r"Pip #(?P<pip>\d+)",
-]
-
-issue_urls = dict(
- pull_request='https://bitbucket.org'
- '/pypa/setuptools/pull-request/{pull_request}',
- issue='https://bitbucket.org/pypa/setuptools/issue/{issue}',
- distribute='https://bitbucket.org/tarek/distribute/issue/{distribute}',
- buildout='https://github.com/buildout/buildout/issues/{buildout}',
- old_setuptools='http://bugs.python.org/setuptools/issue{old_setuptools}',
- jython='http://bugs.jython.org/issue{jython}',
- python='http://bugs.python.org/issue{python}',
- interop='https://github.com/pypa/interoperability-peps/issues/{interop}',
- pip='https://github.com/pypa/pip/issues/{pip}',
-)
-
-
-def _linkify(source, dest):
- pattern = '|'.join(link_patterns)
- with open(source) as source:
- out = re.sub(pattern, replacer, source.read())
- with open(dest, 'w') as dest:
- dest.write(out)
-
-
-def replacer(match):
- text = match.group(0)
- match_dict = match.groupdict()
- for key in match_dict:
- if match_dict[key]:
- url = issue_urls[key].format(**match_dict)
- return "`{text} <{url}>`_".format(text=text, url=url)
-
-def setup(app):
- _linkify('CHANGES.txt', 'CHANGES (links).txt')
- app.connect('build-finished', remove_file)
-
-def remove_file(app, exception):
- os.remove('CHANGES (links).txt')
diff --git a/setup.py b/setup.py
index 63093917..9d4330ac 100755
--- a/setup.py
+++ b/setup.py
@@ -172,6 +172,7 @@ setup_params = dict(
'pytest',
] + (['mock'] if sys.version_info[:2] < (3, 3) else []),
setup_requires=[
+ 'rst.linker',
] + pytest_runner,
)