summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristián Maureira-Fredes <cristian.maureira-fredes@qt.io>2022-11-30 10:44:15 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-13 11:57:41 +0000
commit0818c469d0364c9557463086b958abb224de704a (patch)
treeea75e290717437be407c7c408c5b409e9bed6734
parent478fcbedd224fe0ff0bc41b24a62cda521acbd07 (diff)
Add simple template option
This includes a new minimal HTML template to be used to render the QUIPs, motivated by the inclusion of the generated HTML files into the qt-project.org website. A new make variable is used QUIP_TEMPLATE, so one can select a different HTML base file, skipping the current default approach of patching the PlanetQt theme. Change-Id: Iefbc7024d2fccc66241d541c53e46a9b4fdf9cff Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
-rw-r--r--Makefile11
-rw-r--r--ReadMe.rst15
-rwxr-xr-xscripts/gen-quip-0000.py2
-rw-r--r--templates/simple_template.html27
4 files changed, 52 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 2cf32cb..62f04da 100644
--- a/Makefile
+++ b/Makefile
@@ -13,36 +13,45 @@ endif
RST := $(wildcard quip-[0-9][0-9][0-9][0-9]*.rst)
RSTHTML := $(RST:%.rst=$(HTMLDIR)/%.html)
HTML := $(HTMLDIR)/quip-0000.html $(RSTHTML)
+ifeq ($(QUIP_TEMPLATE),)
WEBLINK := favicon.ico \
cookiebar-x.png cookie_small.png list_arrow.png theqtcompany.png \
extras.js main.js modernizr.custom.84855.js \
online.css style.css \
images
LINK := $(HTMLDIR)/.web $(HTMLDIR)/index.html $(WEBLINK:%=$(HTMLDIR)/%)
+endif
html: $(HTML) $(LINK)
$(HTML) $(LINK): $(HTMLDIR)/.ready
-$(WEBLINK:%=$(HTMLDIR)/%) $(WEBLINK:%=$(HTMLDIR)/.web/%): $(HTMLDIR)/.web
%/.ready:
$Q mkdir -p $(@D) && touch $@
$(HTMLDIR)/index.html: $(HTMLDIR)/quip-0000.html
$Q [ -h $@ ] || (cd $(@D) && ln -s $(<F) $(@F))
+ifeq ($(QUIP_TEMPLATE),)
+$(WEBLINK:%=$(HTMLDIR)/%) $(WEBLINK:%=$(HTMLDIR)/.web/%): $(HTMLDIR)/.web
$(WEBLINK:%=$(HTMLDIR)/%): $(HTMLDIR)/%: $(HTMLDIR)/.web/%
$Q [ -h $@ ] || (cd $(@D) && ln -s .web/$(@F) $(@F))
$(HTMLDIR)/.web: planetqt/website
$Q [ -h $@ ] || (cd $(@D) && ln -s $(abspath $<) $(@F))
+endif
$(HTMLDIR)/quip-0000.html: scripts/gen-quip-0000.py scripts/quip2html.py $(RST) template.html
scripts/gen-quip-0000.py $(RST) | scripts/quip2html.py - >$@
$(RSTHTML): $(HTMLDIR)/%.html: %.rst scripts/quip2html.py template.html
scripts/quip2html.py $< >$@
+ifeq ($(QUIP_TEMPLATE),)
.INTERMEDIATE: scripts/template.html
template.html: scripts/template.diff planetqt/template.qt
$Q patch -l -p0 -i $< -o scripts/$@ && mv scripts/$@ $@
# We only stomp template.html if patch succeeds.
+else
+template.html: $(QUIP_TEMPLATE)
+ $Q rm -f $@; ln -s $< $@
+endif
.PHONY: clean
clean:
diff --git a/ReadMe.rst b/ReadMe.rst
index e7a520e..a8823e3 100644
--- a/ReadMe.rst
+++ b/ReadMe.rst
@@ -13,9 +13,12 @@ preview of what this is all about.
Generating HTML from QUIPs
--------------------------
-You'll need this module checked out, along with its sub-module: see
+If you want the output to include the Planet Qt style,
+you'll need this module checked out, along with its sub-module: see
`Planet Qt and the template`_ for how to get Planet Qt checked out and
up to date.
+Alternatively, you can set the ``QUIP_TEMPLATE`` make variable
+to use another HTML template.
You can generate the HTML using ``make``, provided you have GNU
``make``, ``python3`` and its ``docutils`` package installed.
@@ -65,6 +68,16 @@ having a limited implementation of ``https``, most likely.
.. _checklink: http://validator.w3.org/docs/checklink.html
+Minimal template
+----------------
+
+In ``templates/`` you will find a minimal html to generate the QUIPs
+without any styling. This template can be used like:
+
+ make QUIP_TEMPLATE="templates/simple_template.html"
+
+but by default, a template derived from Planet Qt is used.
+
Planet Qt and the template
--------------------------
diff --git a/scripts/gen-quip-0000.py b/scripts/gen-quip-0000.py
index 0a1403f..864f061 100755
--- a/scripts/gen-quip-0000.py
+++ b/scripts/gen-quip-0000.py
@@ -15,7 +15,7 @@ class RootQuip (dict):
def __init__(self, files):
parser = HeaderParser()
for quip in files:
- with open(quip, 'r', encoding='utf-8') as quipfp:
+ with open(quip, 'r', encoding='tf-8') as quipfp:
self[quip] = parser.parse(quipfp)
def last_name(names): # tool function for owners; not a method
diff --git a/templates/simple_template.html b/templates/simple_template.html
new file mode 100644
index 0000000..9b92838
--- /dev/null
+++ b/templates/simple_template.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes" />
+
+ <title>%(title)s</title>
+ %(stylesheet)s
+ <link rel="shortcut icon" href="favicon.ico" />
+</head>
+<body>
+<div class="content">
+ <div class="wrapper">
+ <h1>%(title)s</h1>
+ <ul>
+ <li><a href="./">QUIP Index</a></li>
+ <li><a href="%(urlstem)s.html">QUIP %(quip)s</a></li>
+ </ul>
+ <div class="context document">
+ %(body)s
+ </div>
+ </div>
+</div>
+
+</body>
+</html>