diff --git a/.gitignore b/.gitignore index 02c8df9a4521ca742f06a3f3a3953fc34d3a58d7..7c9e95a55b1a04b231d3c2e3f2192ae39612e04a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pdfs_encrypted/* .vscode **/__pycache__ +venv/* diff --git a/docs/source/_template.rst b/docs/source/_template.rst new file mode 100644 index 0000000000000000000000000000000000000000..c47f0b201d41b3e352393e90f199f2a49ceace56 --- /dev/null +++ b/docs/source/_template.rst @@ -0,0 +1,13 @@ +<header> + +.. toctree:: + :maxdepth: 3 + +.. autoprogram:: <file>:_parser + :prog: <file>.py + +API +=== + +.. automodule:: <file> + :members: diff --git a/docs/source/generate_rst.py b/docs/source/generate_rst.py new file mode 100644 index 0000000000000000000000000000000000000000..acd4bcf190436adaed6129e9593fe24b329801e8 --- /dev/null +++ b/docs/source/generate_rst.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +import os + + +def generateFiles(file_infos, template_path, out_dir): + """ insert figures into latex template + """ + + with open(template_path, "r") as template_handle: + template_string = template_handle.read() + + for file_info in file_infos: + file = file_info['file'] + title = file_info['title'] + + line = '*'*len(title) + header = "{title}\n{line}".format(title=title, line=line) + s = template_string.replace("<file>", file) + s = s.replace("<header>", header) + + out_file = "{file}.rst".format(file=file) + out_path = os.path.join(out_dir, out_file) + + if os.path.exists(out_path): + print("Overwriting {file}." + .format(file=out_file)) + + with open(out_path, 'w') as out_handle: + out_handle.write(s) + + print("Done.") + + +if __name__ == '__main__': + """ Main routine + """ + + file_infos = [ + {'file': 'watermark', 'title': 'Watermark'}, + {'file': 'batch', 'title': 'Batch'}, + {'file': 'encrypt', 'title': 'Encrypt'}, + {'file': 'preparemoodle', 'title': 'Prepare Moodle'}, + {'file': 'preparepdf', 'title': 'Prepare PDFs'}, + {'file': 'renamescans', 'title': 'Rename Scans'}, + {'file': 'supplements', 'title': 'Supplements'}, + ] + + generateFiles( + file_infos=file_infos, template_path='./docs/source/_template.rst', + out_dir='./docs/source/') diff --git a/docs/source/preparepdf.rst b/docs/source/preparepdf.rst index 6766a9bcef2ea91834784f7453fcf4688e174e81..8d4abde30494c999cdb41eb6afb9f7cf12d36c9d 100644 --- a/docs/source/preparepdf.rst +++ b/docs/source/preparepdf.rst @@ -1,5 +1,5 @@ -Prepare PDFs -************* +Prepare PDFs +************ .. toctree:: :maxdepth: 3