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

@@ -179,6 +179,20 @@ pages:
html: data-api-v2-tool.html
methods_js: js/apitool-methods-data_v2.js
rest_host: https://data.ripple.com
doc_page: reference-data-api.html
sidebar: true
targets:
- local
- ripple.com
template: template-rest-api-tool.html
- name: rippled JSON-RPC Tool
# This tool requires a local server w/ reverse proxy
category: API Tools
html: tool-jsonrpc.html
methods_js: js/apitool-methods-jsonrpc.js
rest_host: http://localhost/rippled
doc_page: reference-rippled.html
sidebar: true
targets:
- local

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)

View File

@@ -42,6 +42,11 @@
</div>
</div>
</div>
<script type='text/javascript'>
// Set some constants for the REST tool script
var URL_BASE = '{{ currentpage.rest_host }}';
var DOC_BASE = '{{ currentpage.doc_page }}';
</script>
{% endblock %}
{% block endbody %}