Redo gendoc script.

pull/977/head
Kegan Dougal 10 years ago
parent 42857df26f
commit df448df813

1
.gitignore vendored

@ -0,0 +1 @@
scripts/gen

@ -0,0 +1,53 @@
#! /usr/bin/env python
from docutils.core import publish_file
import glob
import os
import shutil
import sys
stylesheets = {
"stylesheet_path": ["basic.css", "nature.css"]
}
def glob_spec(out_file_name):
with open(out_file_name, "wb") as outfile:
for f in sorted(glob.glob("../specification/*.rst")):
with open(f, "rb") as infile:
outfile.write(infile.read())
def rst2html(i, o):
with open(i, "r") as in_file:
with open(o, "w") as out_file:
publish_file(
source=in_file,
destination=out_file,
reader_name="standalone",
parser_name="restructuredtext",
writer_name="html",
settings_overrides=stylesheets
)
def prepare_env():
try:
os.makedirs("./gen")
except OSError:
pass
try:
os.makedirs("./tmp")
except OSError:
pass
def cleanup_env():
shutil.rmtree("./tmp")
def main():
prepare_env()
glob_spec("tmp/full_spec.rst")
rst2html("tmp/full_spec.rst", "gen/specification.html")
rst2html("../howtos/client-server.rst", "gen/howtos.html")
cleanup_env()
if __name__ == '__main__':
main()

@ -1,23 +0,0 @@
#!/bin/bash
MATRIXDOTORG=$HOME/workspace/matrix.org
# list of places we mess with the template:
#
# docs/*/*.html
# mailman
# alpha
# swagger
# blog
cat ../specification/*.rst > /tmp/spec.rst
rst2html-2.7.py --stylesheet=basic.css,nature.css /tmp/spec.rst > $MATRIXDOTORG/docs/spec/index.html
rst2html-2.7.py --stylesheet=basic.css,nature.css ../howtos/client-server.rst > $MATRIXDOTORG/docs/howtos/client-server.html
perl -pi -e 's#<head>#<head><link rel="stylesheet" href="/site.css">#' $MATRIXDOTORG/docs/spec/index.html $MATRIXDOTORG/docs/howtos/client-server.html
perl -MFile::Slurp -pi -e 'BEGIN { $nav = read_file("'$MATRIXDOTORG'/includes/nav.html") } s#<body>#<body><div id="header"><div id="headerContent">$nav</div></div><div id="page"><div id="wrapper"><div style="text-align: center; padding: 40px;"><a href="/"><img src="/matrix.png" width="305" height="130" alt="[matrix]"/></a></div>#' $MATRIXDOTORG/docs/spec/index.html $MATRIXDOTORG/docs/howtos/client-server.html
perl -pi -e 's#</body>#</div></div><div id="footer"><div id="footerContent">&copy 2014-2015 Matrix.org</div></div></body>#' $MATRIXDOTORG/docs/spec/index.html $MATRIXDOTORG/docs/howtos/client-server.html
scp -r $MATRIXDOTORG/docs matrix@ldc-prd-matrix-001:/sites/matrix

@ -0,0 +1,21 @@
#! /bin/bash
if [ -z "$1" ]; then
echo "Expected /includes/nav.html file as arg."
exit 1
fi
NAV_BAR=$1
if [ ! -f $NAV_BAR ]; then
echo $NAV_BAR " does not exist"
exit 1
fi
python gendoc.py
perl -pi -e 's#<head>#<head><link rel="stylesheet" href="/site.css">#' gen/specification.html gen/howtos.html
perl -MFile::Slurp -pi -e 'BEGIN { $nav = read_file("'$NAV_BAR'") } s#<body>#<body><div id="header"><div id="headerContent">$nav</div></div><div id="page"><div id="wrapper"><div style="text-align: center; padding: 40px;"><a href="/"><img src="/matrix.png" width="305" height="130" alt="[matrix]"/></a></div>#' gen/specification.html gen/howtos.html
perl -pi -e 's#</body>#</div></div><div id="footer"><div id="footerContent">&copy 2014-2015 Matrix.org</div></div></body>#' gen/specification.html gen/howtos.html
Loading…
Cancel
Save