Fix generated Python code for Doxygen comments with triple quotes
In addition to the changes in the previous commit, also avoid syntax errors in the generated Python docstrings by splitting them into several parts if there are 3 quotes in a row in the input, as it's impossible to have them inside triple-quoted strings, generally speaking (i.e. if there are occurrences of both """ and ''' inside the string).
This commit is contained in:
parent
b81cd1bdab
commit
f57b096c92
4 changed files with 26 additions and 0 deletions
|
|
@ -1599,6 +1599,16 @@ public:
|
|||
|
||||
Append(doc, useSingleQuotes ? "r'''" : "r\"\"\"");
|
||||
|
||||
// We also need to avoid having triple quotes of whichever type we use, as
|
||||
// this would break Python doc string syntax too. Unfortunately there is no
|
||||
// way to have triple quotes inside of raw-triple-quoted string, so we have
|
||||
// to break the string in parts and rely on concatenation of the adjacent
|
||||
// string literals.
|
||||
if (useSingleQuotes)
|
||||
Replaceall(docstr, "'''", "''' \"'''\" '''");
|
||||
else
|
||||
Replaceall(docstr, "\"\"\"", "\"\"\" '\"\"\"' \"\"\"");
|
||||
|
||||
Append(doc, docstr);
|
||||
Append(doc, useSingleQuotes ? "'''" : "\"\"\"");
|
||||
Delete(docstr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue