diff options
| author | Rémi Verschelde | 2018-06-13 14:29:45 +0200 |
|---|---|---|
| committer | GitHub | 2018-06-13 14:29:45 +0200 |
| commit | f0fa5902100b5b2a6207b1656cf90af3c36bd213 (patch) | |
| tree | b901e9760a7bade5ad0c0c48d55c21e5c1c7d39f /doc/tools/makerst.py | |
| parent | 62b75a94ec9c746aa6f58dad39ca2917428a38f1 (diff) | |
| parent | 98b59cf2a387e469851eee137cc6310cfc4b2a6d (diff) | |
| download | godot-f0fa5902100b5b2a6207b1656cf90af3c36bd213.tar.gz godot-f0fa5902100b5b2a6207b1656cf90af3c36bd213.tar.zst godot-f0fa5902100b5b2a6207b1656cf90af3c36bd213.zip | |
Diffstat (limited to 'doc/tools/makerst.py')
| -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 289e967a9..93ad823d4 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', '-')) |
