summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2012-10-15 12:54:26 +0200
committerStefan Behnel <stefan_ml@behnel.de>2012-10-15 12:54:26 +0200
commit12a58b74de72818a2a75bbc231d5dc2856f1de4d (patch)
tree5e6c179b512a9c9a90f69bfb7c76ef2bf5b4acb1 /doc
parent8d832761a4bd69ffd8f8e9ab6ab76fc2ec03a436 (diff)
downloadpython-lxml-12a58b74de72818a2a75bbc231d5dc2856f1de4d.tar.gz
change tracker references to HTML links on changelog generation
Diffstat (limited to 'doc')
-rw-r--r--doc/mkhtml.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/doc/mkhtml.py b/doc/mkhtml.py
index 810e6e83..cc58da0a 100644
--- a/doc/mkhtml.py
+++ b/doc/mkhtml.py
@@ -8,6 +8,11 @@ import copy
import shutil
import subprocess
+try:
+ from io import open as open_file
+except ImportError:
+ from codecs import open as open_file
+
RST2HTML_OPTIONS = " ".join([
'--no-toc-backlinks',
'--strip-comments',
@@ -135,6 +140,30 @@ def rest2html(script, source_path, dest_path, stylesheet_url):
stylesheet_url, source_path, dest_path))
subprocess.call(command, shell=True)
+def convert_changelog(lxml_path, changelog_file_path, rst2html_script, stylesheet_url):
+ f = open_file(os.path.join(lxml_path, 'CHANGES.txt'), 'r', encoding='utf-8')
+ try:
+ content = f.read()
+ finally:
+ f.close()
+
+ links = dict(LP='`%s <https://bugs.launchpad.net/lxml/+bug/%s>`_',
+ GH='`%s <https://github.com/lxml/lxml/issues/%s>`_')
+ replace_tracker_links = re.compile('((LP|GH)#([0-9]+))').sub
+ def insert_link(match):
+ text, ref_type, ref_id = match.groups()
+ return links[ref_type] % (text, ref_id)
+ content = replace_tracker_links(insert_link, content)
+
+ command = [sys.executable, rst2html_script] + RST2HTML_OPTIONS.split() + [
+ '--link-stylesheet', '--stylesheet', stylesheet_url ]
+ out_file = open(changelog_file_path, 'wb')
+ try:
+ rst2html = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=out_file)
+ rst2html.communicate(content.encode('utf8'))
+ finally:
+ out_file.close()
+
def publish(dirname, lxml_path, release):
if not os.path.exists(dirname):
os.mkdir(dirname)
@@ -180,10 +209,8 @@ def publish(dirname, lxml_path, release):
build_menu(tree, basename, section_head)
# also convert CHANGES.txt
- rest2html(script,
- os.path.join(lxml_path, 'CHANGES.txt'),
- os.path.join(dirname, 'changes-%s.html' % release),
- '')
+ convert_changelog(lxml_path, os.path.join(dirname, 'changes-%s.html' % release),
+ script, stylesheet_url)
# generate sitemap from menu
sitemap = XML('''\