diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-17 18:47:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-17 18:47:58 +0300 |
commit | 208e0647210d727c89481ec970e7cd76b707aab6 (patch) | |
tree | 60b765246ddcb667fe9e0eaba92027ecedad40ba /doc | |
parent | a9c5e1d9b7927a2d35da05eea0f4e204e8d78fa4 (diff) |
Doc: escape enum name & description
Needed since key enum now uses many characters as they're typed.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 99b8325cff3..f68d6bf617a 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 ]) |