diff options
| author | Scott Bahling <sbahling@suse.de> | 2013-07-18 12:43:07 +0200 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.de> | 2013-07-18 12:43:07 +0200 |
| commit | 66120bb19e24096f2482df5e479e7e4b9ca59fed (patch) | |
| tree | 3290393c96773ad1096ef3f3ade79ec1a13be801 /panfry/main.py | |
| parent | 094530f92d678f9c2f2ad498a2c21653de399a99 (diff) | |
| download | panfry-66120bb19e24096f2482df5e479e7e4b9ca59fed.tar.gz panfry-66120bb19e24096f2482df5e479e7e4b9ca59fed.tar.xz panfry-66120bb19e24096f2482df5e479e7e4b9ca59fed.zip | |
Implement multi-level documentation handling
Diffstat (limited to 'panfry/main.py')
| -rwxr-xr-x | panfry/main.py | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/panfry/main.py b/panfry/main.py index 9572243..1b90181 100755 --- a/panfry/main.py +++ b/panfry/main.py @@ -36,8 +36,10 @@ class StoppableHttpServer(BaseHTTPServer.HTTPServer): def get_env(): env = panfry.cli.init_argparser().parse_args() env.pub_path = os.path.abspath(env.pub_path) + env.index = [''] if env.cmd in ['gen']: + INDEX = os.path.join(env.doc_path, 'src', 'INDEX') if not os.path.isdir(env.doc_path): print("%s directory not found. Aborting..." % env.doc_path) exit(1) @@ -52,47 +54,53 @@ def get_env(): if env.pandoc_options: env.pandoc_options = list(shlex.split(env.pandoc_options)) + if os.path.isfile(INDEX): + env.index += open(INDEX, 'r').readlines() + return env def gen(env): - document = Document(env.doc_path) - document.set_templater(Templater(env.templates_path)) - document.set_pandoc_options(env.pandoc_options) - if env.simple_toc: - document.set_simple_toc - - if env.json_toc: - document.set_json_toc - - if env.clean and os.path.exists(env.pub_path): - print("Cleanup, removing %s..." % env.pub_path) - shutil.rmtree(env.pub_path) - if not os.path.exists(env.pub_path): - os.mkdir(env.pub_path) - - if env.assets: - print("Publishing assets only...", end=' ') - document.publish_assets(env.pub_path) - print("done.") - exit(0) - - print("\nUsing pandoc options:") - for opt in env.pandoc_options: - print(" --%s" % opt) - - print() - - ###### Create PDF - pdffile = document.publish_pdf(env.pub_path) - print("Wrote PDF: %s" % pdffile) - - ###### Create epub - epubfile = document.publish_epub(env.pub_path) - print("Wrote epub: %s" % epubfile) - - ###### Create HTML - document.publish_html(env.pub_path) + for item in env.index: + item = item.strip() + docpubpath = os.path.join(env.pub_path, item) + document = Document(env.doc_path, item) + document.set_templater(Templater(env.templates_path)) + document.set_pandoc_options(env.pandoc_options) + if env.simple_toc: + document.set_simple_toc + + if env.json_toc: + document.set_json_toc + + if env.clean and os.path.exists(env.pub_path): + print("Cleanup, removing %s..." % env.pub_path) + shutil.rmtree(env.pub_path) + if not os.path.exists(docpubpath): + os.makedirs(docpubpath) + + if env.assets: + print("Publishing assets only...", end=' ') + document.publish_assets(env.pub_path) + print("done.") + exit(0) + + print("\nUsing pandoc options:") + for opt in env.pandoc_options: + print(" --%s" % opt) + + print() + + ###### Create PDF + pdffile = document.publish_pdf(docpubpath) + print("Wrote PDF: %s" % pdffile) + + ###### Create epub + epubfile = document.publish_epub(docpubpath) + print("Wrote epub: %s" % epubfile) + + ###### Create HTML + document.publish_html(docpubpath) exit(0) |
