makerst: Add descriptions to method qualifiers
This closes https://github.com/godotengine/godot-docs/issues/1753.
(cherry picked from commit c162a39c7b
)
This commit is contained in:
parent
c8d8134288
commit
78a6a57884
|
@ -565,6 +565,8 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
f.write(make_footer())
|
||||||
|
|
||||||
|
|
||||||
def escape_rst(text, until_pos=-1): # type: (str) -> str
|
def escape_rst(text, until_pos=-1): # type: (str) -> str
|
||||||
# Escape \ character, otherwise it ends up as an escape character in rst
|
# Escape \ character, otherwise it ends up as an escape character in rst
|
||||||
|
@ -986,7 +988,10 @@ def make_method_signature(
|
||||||
out += " **)**"
|
out += " **)**"
|
||||||
|
|
||||||
if isinstance(method_def, MethodDef) and method_def.qualifiers is not None:
|
if isinstance(method_def, MethodDef) and method_def.qualifiers is not None:
|
||||||
out += " " + method_def.qualifiers
|
# Use substitutions for abbreviations. This is used to display tooltips on hover.
|
||||||
|
# See `make_footer()` for descriptions.
|
||||||
|
for qualifier in method_def.qualifiers.split():
|
||||||
|
out += " |" + qualifier + "|"
|
||||||
|
|
||||||
return ret_type, out
|
return ret_type, out
|
||||||
|
|
||||||
|
@ -995,6 +1000,18 @@ def make_heading(title, underline): # type: (str, str) -> str
|
||||||
return title + "\n" + (underline * len(title)) + "\n\n"
|
return title + "\n" + (underline * len(title)) + "\n\n"
|
||||||
|
|
||||||
|
|
||||||
|
def make_footer(): # type: () -> str
|
||||||
|
# Generate reusable abbreviation substitutions.
|
||||||
|
# This way, we avoid bloating the generated rST with duplicate abbreviations.
|
||||||
|
# fmt: off
|
||||||
|
return (
|
||||||
|
".. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`\n"
|
||||||
|
".. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`\n"
|
||||||
|
".. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`"
|
||||||
|
)
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
|
||||||
def make_url(link): # type: (str) -> str
|
def make_url(link): # type: (str) -> str
|
||||||
match = GODOT_DOCS_PATTERN.search(link)
|
match = GODOT_DOCS_PATTERN.search(link)
|
||||||
if match:
|
if match:
|
||||||
|
|
Loading…
Reference in New Issue