[Bf-blender-cvs] [b0a6d48] blender-v2.76-release: Doc: escape enum name & description
Campbell Barton
noreply at git.blender.org
Wed Sep 23 16:11:43 CEST 2015
Commit: b0a6d486591c7b7ae1e7aaed6e6998b9e74b54a1
Author: Campbell Barton
Date: Fri Sep 18 01:47:58 2015 +1000
Branches: blender-v2.76-release
https://developer.blender.org/rBb0a6d486591c7b7ae1e7aaed6e6998b9e74b54a1
Doc: escape enum name & description
Needed since key enum now uses many characters as they're typed.
===================================================================
M doc/python_api/sphinx_doc_gen.py
===================================================================
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index 99b8325..f68d6bf 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -472,6 +472,18 @@ else:
_BPY_PROP_COLLECTION_ID = "collection"
+def escape_rst(text):
+ """ Escape plain text which may contain characters used by RST.
+ """
+ return text.translate(escape_rst.trans)
+escape_rst.trans = str.maketrans({
+ "`": "\\`",
+ "|": "\\|",
+ "*": "\\*",
+ "\\": "\\\\",
+ })
+
+
def is_struct_seq(value):
return isinstance(value, tuple) and type(tuple) != tuple and hasattr(value, "n_fields")
@@ -1139,7 +1151,7 @@ def pycontext2sphinx(basepath):
def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
- """ write a bullet point list of enum + descrptons
+ """ write a bullet point list of enum + descriptions
"""
if use_empty_descriptions:
@@ -1154,7 +1166,7 @@ def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
if ok:
return "".join(["* ``%s`` %s.\n" %
(identifier,
- ", ".join(val for val in (name, description) if val),
+ ", ".join(escape_rst(val) for val in (name, description) if val),
)
for identifier, name, description in prop.enum_items
])
More information about the Bf-blender-cvs
mailing list