Redo gendoc script.
This commit is contained in:
parent
42857df26f
commit
df448df813
4 changed files with 75 additions and 23 deletions
53
scripts/gendoc.py
Executable file
53
scripts/gendoc.py
Executable file
|
@ -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()
|
Loading…
Add table
Add a link
Reference in a new issue