diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-01 11:52:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-01 11:52:20 +0100 |
commit | 7140d766a2bdb56ad4e73e0a5107960ca8687040 (patch) | |
tree | b397489d20f81ee5227d50c5352c61781df5dbb6 | |
parent | 06fd6e6945f38ea110de07c6cc279bf9cf48e75d (diff) | |
parent | 55676b16da70ec0fcd716ca277af84eac0446845 (diff) |
Merge pull request #33997 from akien-mga/doc-makerst-escape
makerst: Escape default values using reST markup
-rwxr-xr-x | doc/tools/makerst.py | 67 | ||||
-rw-r--r-- | modules/gridmap/doc_classes/GridMap.xml | 3 |
2 files changed, 37 insertions, 33 deletions
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index ef38299680..de53259827 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -148,6 +148,8 @@ class State: setter = property.get("setter") or None # Use or None so '' gets turned into None. getter = property.get("getter") or None default_value = property.get("default") or None + if default_value is not None: + default_value = escape_rst(default_value) overridden = property.get("override") or False property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value, overridden) @@ -622,6 +624,40 @@ def make_class_list(class_list, columns): # type: (List[str], int) -> None f.close() +def escape_rst(text, until_pos=-1): # type: (str) -> str + # Escape \ character, otherwise it ends up as an escape character in rst + pos = 0 + while True: + pos = text.find('\\', pos, until_pos) + if pos == -1: + break + text = text[:pos] + "\\\\" + text[pos + 1:] + pos += 2 + + # Escape * character to avoid interpreting it as emphasis + pos = 0 + while True: + pos = text.find('*', pos, until_pos) + if pos == -1: + break + text = text[:pos] + "\*" + text[pos + 1:] + pos += 2 + + # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink + pos = 0 + while True: + pos = text.find('_', pos, until_pos) + if pos == -1: + break + if not text[pos + 1].isalnum(): # don't escape within a snake_case word + text = text[:pos] + "\_" + text[pos + 1:] + pos += 2 + else: + pos += 1 + + return text + + def rstize_text(text, state): # type: (str, State) -> str # Linebreak + tabs in the XML should become two line breaks unless in a "codeblock" pos = 0 @@ -677,36 +713,7 @@ def rstize_text(text, state): # type: (str, State) -> str pos += 2 next_brac_pos = text.find('[') - - # Escape \ character, otherwise it ends up as an escape character in rst - pos = 0 - while True: - pos = text.find('\\', pos, next_brac_pos) - if pos == -1: - break - text = text[:pos] + "\\\\" + text[pos + 1:] - pos += 2 - - # Escape * character to avoid interpreting it as emphasis - pos = 0 - while True: - pos = text.find('*', pos, next_brac_pos) - if pos == -1: - break - text = text[:pos] + "\*" + text[pos + 1:] - pos += 2 - - # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink - pos = 0 - while True: - pos = text.find('_', pos, next_brac_pos) - if pos == -1: - break - if not text[pos + 1].isalnum(): # don't escape within a snake_case word - text = text[:pos] + "\_" + text[pos + 1:] - pos += 2 - else: - pos += 1 + text = escape_rst(text, next_brac_pos) # Handle [tags] inside_code = False diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index a140fc8ac6..3de971db6d 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -226,9 +226,6 @@ <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library"> The assigned [MeshLibrary]. </member> - <member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme"> - Deprecated, use [member mesh_library] instead. - </member> </members> <signals> <signal name="cell_size_changed"> |