forked from 4hopp/proto2cpp
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
bugProblems in the build system, build scripts, etc or faults in the interface.Problems in the build system, build scripts, etc or faults in the interface.
Description
Describe the bug
All full stops (periods) '.' occurring in comments are replaced with :: even when they don't result in a reference.
Describe how to reproduce the bug
Steps to reproduce the behavior:
- Write the following documentation string:
/**
* This documentation is quite long.
*
* It needs more than once sentence to describe what is happening.
*
* FullyStopped.value is a reference, but FullyStopped.
* value is not.
*/
message FullyStopped {
required uint32 value = 1;
};
- Generate documentation:
<detaileddescription>
<para>This documentation is quite long::</para>
<para>It needs more than once sentence to describe what is happening::</para>
<para>
<ref refid="structFullyStopped_1a8defeb7fb78806a0c55bfec7b89e6500" kindref="member">FullyStopped::value</ref>
is a reference, but <ref refid="structFullyStopped" kindref="compound">FullyStopped</ref>:: value is not:: </para> </detaileddescription>Converted to markdown for readability:
This documentation is quite long::
It needs more than once sentence to describe what is happening::
FullyStopped::value is a reference, but FullyStopped:: value is not
Describe the expected behavior
'.' characters should not be replaced if they are not followed by a set of non-whitespace characters
This documentation is quite long.
It needs more than once sentence to describe what is happening.
FullyStopped::value is a reference, but FullyStopped. value is not
Show some screenshots
Not Applicable
Describe the OS you are using
- OS: Debian 10
- Language: Protobuf, Doxygen, and English
- Version:
proto2cpp.py@3e30b94615d64cf02713b23060f985f953751bb8(v0.8-beta)
Additional context
A patch:
The (\S+) group requires the . to be followed by at least one (1) non whitespace character.
Any whitespace following a :: would be invalid syntax in C++ anyway, so I don't think this would break that many intentional references. Considering a sentence not followed by white space, like this one.I believe that would be invalid syntax in English.
diff --git a/proto2cpp.py b/proto2cpp.py
index a355aaa..6f0d80a 100644
--- a/proto2cpp.py
+++ b/proto2cpp.py
@@ -183,7 +183,8 @@ class proto2cpp:
isMultilineComment = False
# line = line.replace(".", "::") but not in quoted strings (Necessary for import statement)
- line = re.sub(r'\.(?=(?:[^"]*"[^"]*")*[^"]*$)',r'::',line)
+ # also not if the "." was the final character in the line or was followed by whitespace (natural punctuation)
+ line = re.sub(r'\.(?=(?:[^"]*"[^"]*")*[^"]*$)(\S+)',r'::\1',line)
# Search for " option ...;", remove it
line = re.sub(r'\boption\b[^;]+;', r'', line)Metadata
Metadata
Assignees
Labels
bugProblems in the build system, build scripts, etc or faults in the interface.Problems in the build system, build scripts, etc or faults in the interface.