From 0976ea4ea523e7ba534968e35b9bfeb6b9cb5482 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 26 Apr 2020 17:18:49 +0200 Subject: Fix links in online documentation index --- lv2specgen/lv2specgen.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lv2specgen') diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 8cfa1c7..e3948f1 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -1246,7 +1246,7 @@ def load_tags(path, docdir): return linkmap -def writeIndex(model, specloc, index_path, root_path, root_uri): +def writeIndex(model, specloc, index_path, root_path, root_uri, online): # Get extension URI ext_node = model.value(None, rdf.type, lv2.Specification) if not ext_node: @@ -1294,9 +1294,12 @@ def writeIndex(model, specloc, index_path, root_path, root_uri): # Find relative link target if root_uri and ext_node.startswith(root_uri): - target = ext_node[len(root_uri) :] + ".html" + target = ext_node[len(root_uri) :] else: - target = os.path.relpath(ext_node, root_path) + ".html" + target = os.path.relpath(ext_node, root_path) + + if not online: + target += ".html" stem = os.path.splitext(os.path.basename(target))[0] @@ -1553,7 +1556,7 @@ def specgen( # Write index row if index_path is not None: - writeIndex(m, specloc, index_path, root_path, root_uri) + writeIndex(m, specloc, index_path, root_path, root_uri, opts["online"]) # Validate complete output page try: @@ -1709,6 +1712,13 @@ if __name__ == "__main__": dest="copy_style", help="Copy style from template directory to output directory", ) + opt.add_option( + "-o", + "--online", + action="store_true", + dest="online", + help="Generate index for online documentation", + ) (options, args) = opt.parse_args() opts = vars(options) -- cgit v1.2.1