summaryrefslogtreecommitdiff
path: root/doc/tools
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2019-03-27 20:01:16 +0100
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2019-03-29 23:40:31 +0100
commitc8aa85189a8736bb9723770b9409e6f9c00fc249 (patch)
treeaec78e008cd5e1e3e08968434ede66b2993ee517 /doc/tools
parente45393482463ddb606bab4f2a78f4a5024cdce7a (diff)
EditorHelp, makerst: Improve enum ref resolving and constant ref support
Enum reference resolving will now search in the @GlobalScope if no class is specified and the enum cannot be resolved in the current class. Added support for constant references in EditorHelp, e.g.: [constant KEY_ENTER] or [constant Control.FOCUS_CLICK]. It supports enum constants (the enum name must not be included).
Diffstat (limited to 'doc/tools')
-rwxr-xr-xdoc/tools/makerst.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index 40dde48432..6d9cd7140a 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -757,14 +757,25 @@ def rstize_text(text, state): # type: (str, State) -> str
elif cmd.startswith("constant"):
found = False
- if method_param in class_def.constants:
- found = True
- else:
- for enum in class_def.enums.values():
- if method_param in enum.values:
- found = True
- break
+ # Search in the current class
+ search_class_defs = [class_def]
+
+ if param.find('.') == -1:
+ # Also search in @GlobalScope as a last resort if no class was specified
+ search_class_defs.append(state.classes["@GlobalScope"])
+
+ for search_class_def in search_class_defs:
+ if method_param in search_class_def.constants:
+ class_param = search_class_def.name
+ found = True
+
+ else:
+ for enum in search_class_def.enums.values():
+ if method_param in enum.values:
+ class_param = search_class_def.name
+ found = True
+ break
if not found:
print_error("Unresolved constant '{}', file: {}".format(param, state.current_class), state)
@@ -917,6 +928,9 @@ def make_enum(t, state): # type: (str, State) -> str
if c in state.classes and e not in state.classes[c].enums:
c = "@GlobalScope"
+ if not c in state.classes and c.startswith("_"):
+ c = c[1:] # Remove the underscore prefix
+
if c in state.classes and e in state.classes[c].enums:
return ":ref:`{0}<enum_{1}_{0}>`".format(e, c)
print_error("Unresolved enum '{}', file: {}".format(t, state.current_class), state)