diff options
author | robojumper <robojumper@gmail.com> | 2018-06-11 13:35:44 +0200 |
---|---|---|
committer | robojumper <robojumper@gmail.com> | 2018-06-12 17:40:24 +0200 |
commit | 98b59cf2a387e469851eee137cc6310cfc4b2a6d (patch) | |
tree | ab4d5a8a7fb9e7e5bb0159c1e6660a4e851ddad0 /doc/tools | |
parent | 76875ba145c5745033d0a1c9fda2f4349e2509b3 (diff) |
Add support for tutorial links to makerst.py
Also change the <tutorials> structure to make use of individual <link> tags
Diffstat (limited to 'doc/tools')
-rwxr-xr-x | doc/tools/makerst.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 289e967a93..93ad823d42 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -4,11 +4,15 @@ import codecs import sys import os +import re import xml.etree.ElementTree as ET input_list = [] cur_file = "" +# http(s)://docs.godotengine.org/<langcode>/<tag>/path/to/page.html(#fragment-tag) +godot_docs_pattern = re.compile('^http(?:s)?:\/\/docs\.godotengine\.org\/(?:[a-zA-Z0-9\.\-_]*)\/(?:[a-zA-Z0-9\.\-_]*)\/(.*)\.html(#.*)?$') + for arg in sys.argv[1:]: if arg.endswith(os.sep): arg = arg[:-1] @@ -588,6 +592,32 @@ def make_rst_class(node): f.write(make_heading('Description', '-')) f.write(rstize_text(descr.text.strip(), name) + "\n\n") + global godot_docs_pattern + tutorials = node.find('tutorials') + if tutorials != None and len(tutorials) > 0: + f.write(make_heading('Tutorials', '-')) + for t in tutorials: + link = t.text.strip() + match = godot_docs_pattern.search(link); + if match: + groups = match.groups() + if match.lastindex == 2: + # Doc reference with fragment identifier: emit direct link to section with reference to page, for example: + # `#calling-javascript-from-script in Exporting For Web` + f.write("- `" + groups[1] + " <../" + groups[0] + ".html" + groups[1] + ">`_ in :doc:`../" + groups[0] + "`\n") + # Commented out alternative: Instead just emit: + # `Subsection in Exporting For Web` + # f.write("- `Subsection <../" + groups[0] + ".html" + groups[1] + ">`_ in :doc:`../" + groups[0] + "`\n") + elif match.lastindex == 1: + # Doc reference, for example: + # `Math` + f.write("- :doc:`../" + groups[0] + "`\n") + else: + # External link, for example: + # `http://enet.bespin.org/usergroup0.html` + f.write("- `" + link + " <" + link + ">`_\n") + f.write("\n") + methods = node.find('methods') if methods != None and len(list(methods)) > 0: f.write(make_heading('Member Function Description', '-')) |