Run jekyll as part of the matrix-doc build

- this saves us having to run it manually on the web server.
This commit is contained in:
Richard van der Hoff 2017-08-02 16:18:20 +01:00
parent 299b60970b
commit 9d2a93ad7b
30 changed files with 1372 additions and 7 deletions

23
scripts/add_anchors.py Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env python
#
# adds anchors before any <h1/h2/h3/h4/h5> tags with an id="..." - this is used
# for things like the FAQ where we want to have anchored links to every
# question (and this way you don't have to manually maintain it in the source
# doc).
from sys import argv
import re
script, filename = argv
textfile = open(filename, "r")
regex = r'(<h\d id="(.*?)">)'
regex2 = r'(<div class="section" id="(.*?)">)'
replacement = r'<p><a class="anchor" id="\2"></a></p>\n\1'
# check for <hX id="..." (used in the FAQ) and add anchors - and then check
# for <div class="section" id="..." and add anchors (used in the spec)
for line in textfile:
line = re.sub(regex, replacement, line.rstrip())
print(re.sub(regex2, replacement, line.rstrip()))

20
scripts/generate-jekyll.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
#
# this script runs 'jekyll' to turn the 'supporting-docs' into HTML.
#
# jekyll requires the `docutils` and `pygments` python packages, so install
# them or run from a virtualenv which includes them.
set -e
# tell jekyll to parse things as utf-8
export LANG="en_GB.UTF-8"
cd `dirname $0`/..
mkdir -p _site
jekyll build -s jekyll
./scripts/add_anchors.py _site/guides/faq.html >tmp && mv tmp _site/guides/faq.html
./scripts/add_anchors.py _site/projects/try-matrix-now.html >tmp && mv tmp _site/projects/try-matrix-now.html