summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-09-08 17:30:05 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-10-13 20:07:29 +0000
commit2cdcc75ad3ce38023b307a2aa3bcd9c0a1013c2a (patch)
treeee75042f34951193b2669fe5e77b3c5ce59cd1f1
parentb04cdf8fc92d7a762ea864d97f03b3dd5c68dde7 (diff)
Adapt each QUIP's self-link to use the right URL
Originally QUIPs were to be simply numbered. At some point we realized we could include some mention of the subject matter in the rst-file name. However, the quip2html script was still assuming quip-0012.html (for example) would be the URL of QUIP 12, without its subject matter suffix. Amend the script, and the template's token used to build the URL, to include the full filename stem (without .rst suffix) in the URL (with a .html suffix). Change-Id: I04d09c3ae80620d13f62a2f8cd2b3dcce3d159b8 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rwxr-xr-xscripts/quip2html.py12
-rw-r--r--scripts/template.diff2
2 files changed, 8 insertions, 6 deletions
diff --git a/scripts/quip2html.py b/scripts/quip2html.py
index 8d83a13..47f1449 100755
--- a/scripts/quip2html.py
+++ b/scripts/quip2html.py
@@ -164,6 +164,11 @@ class QuipReader(standalone.Reader):
standalone.Reader.__init__(self, parser, '')
class QuipWriter(html4css1.Writer):
+ def __init__(self, stem):
+ # For gen-quip-0000 we want quip-0000; otherwise, use the stem as is:
+ self.__stem = stem[4:] if stem.startswith('gen-') else stem
+ super().__init__()
+
# Assumed to be run from the build directory
cwd_file = os.path.join(os.getcwd(), 'dummy')
script_dir = os.path.dirname(__file__)
@@ -202,10 +207,7 @@ class QuipWriter(html4css1.Writer):
header = self.document[index]
self.quipnum = header[0][1].astext()
subs['quip'] = self.quipnum
- try:
- subs['quipnum'] = '%04i' % int(self.quipnum)
- except ValueError:
- subs['quipnum'] = self.quipnum
+ subs['urlstem'] = self.__stem
self.title = header[1][1].astext()
subs['title'] = 'QUIP %s | %s' % (self.quipnum, self.title)
subs['body'] = ''.join(self.body_pre_docinfo + self.docinfo + self.body)
@@ -244,7 +246,7 @@ def main(filename, source, output, stderr):
reader=QuipReader(),
parser_name='restructuredtext',
writer_name='html4css1',
- writer=QuipWriter(),
+ writer=QuipWriter(os.path.splitext(git.base)[0]),
# Allow Docutils traceback if there's an exception:
settings_overrides={'traceback': True, 'halt_level': 2,
# output.write needs a string:
diff --git a/scripts/template.diff b/scripts/template.diff
index ff508c1..34ef265 100644
--- a/scripts/template.diff
+++ b/scripts/template.diff
@@ -50,7 +50,7 @@
+ <h1>%(title)s</h1>
+ <ul>
+ <li><a href="./">QUIP Index</a></li>
-+ <li><a href="quip-%(quipnum)s.html">QUIP %(quip)s</a></li>
++ <li><a href="%(urlstem)s.html">QUIP %(quip)s</a></li>
+ </ul>
+ <div class="context document">
+%(body)s