diff --git a/Examples/test-suite/doxygen_misc_constructs.h b/Examples/test-suite/doxygen_misc_constructs.h index 7782b532f..9e81aaf28 100644 --- a/Examples/test-suite/doxygen_misc_constructs.h +++ b/Examples/test-suite/doxygen_misc_constructs.h @@ -94,3 +94,9 @@ void cycle(int id, char *fileName) /// This doc comment ends with a quote: "and that's ok" void doc_ends_with_quote() {} +/** + This comment contains embedded triple-quoted string: + + """How quaint""" + */ +void doc_with_triple_quotes() {} diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java index ca4b06b55..cae2b2192 100644 --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java @@ -188,6 +188,10 @@ public class doxygen_misc_constructs_runme { wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_ends_with_quote()", "This doc comment ends with a quote: \"and that's ok\""); + wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_with_triple_quotes()", + "This comment contains embedded triple-quoted string:\n" + + "\"\"\"How quaint\"\"\""); + // and ask the parser to check comments for us System.exit(CommentParser.check(wantedComments)); } diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py index 5655b2cef..44f607fee 100644 --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py @@ -135,3 +135,9 @@ Spaces at the start of line should be taken into account: comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_ends_with_quote), r'''This doc comment ends with a quote: "and that's ok"''' ); + +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_with_triple_quotes), + r'''This comment contains embedded triple-quoted string: + + """How quaint"""''' +); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a4ac11811..c8c45df35 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -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);