parse_pages - configurable apitool doc and base urls

This commit is contained in:
mDuo13
2016-03-03 18:09:04 -08:00
parent 5b274c06ca
commit 9abb1c6f20
29 changed files with 1124 additions and 1146 deletions

View File

@@ -365,15 +365,25 @@ def render_pages(target=None, for_pdf=False, bypass_errors=False):
if "template" in currentpage:
# Use a template other than the default one
template = env.get_template(currentpage["template"])
#do link substitution for "doc_page" param
if "doc_page" in currentpage:
doc_page = next(p for p in pages
if p["html"] == currentpage["doc_page"])
if target["name"] in doc_page:
currentpage["doc_page"] = doc_page[target["name"]]
out_html = template.render(currentpage=currentpage,
categories=categories,
pages=pages,
content=html_content)
content=html_content,
target=target)
else:
out_html = default_template.render(currentpage=currentpage,
categories=categories,
pages=pages,
content=html_content)
content=html_content,
target=target)
# Experimental: replace links in full HTML, not just content
soup = BeautifulSoup(out_html, "html.parser")
@@ -540,6 +550,9 @@ if __name__ == "__main__":
if cli_args.watch:
logging.info("watching for changes...")
pdf_path = os.path.join(config["out_path"], cli_args.pdf)
watch(pdf_path, cli_args.target)
if cli_args.pdf:
pdf_path = os.path.join(config["out_path"], cli_args.pdf)
watch(pdf_path, cli_args.target)
else:
watch(None, cli_args.target)