summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Klopcic <marko.klopcic@isystem.si>2012-09-06 20:56:19 +0000
committerMarko Klopcic <marko.klopcic@isystem.si>2012-09-06 20:56:19 +0000
commit8d61aae0fb913bd779b975645af12e12b3fa8565 (patch)
treee3fb69d6bf4810d73983f2a32da8345232228db1
parent2f77dbc7f4e2b406cb52aeaa10758dd35fffeca5 (diff)
downloadswig-8d61aae0fb913bd779b975645af12e12b3fa8565.tar.gz
fixed handling of /******/ comments, added tests for backslash handling, which fail
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13733 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Examples/test-suite/doxygen_misc_constructs.h52
-rw-r--r--Examples/test-suite/doxygen_misc_constructs.i27
-rw-r--r--Examples/test-suite/java/doxygen_misc_constructs_runme.java28
-rw-r--r--Source/CParse/cscanner.c13
-rw-r--r--Source/DoxygenTranslator/src/JavaDocConverter.cpp4
5 files changed, 106 insertions, 18 deletions
diff --git a/Examples/test-suite/doxygen_misc_constructs.h b/Examples/test-suite/doxygen_misc_constructs.h
new file mode 100644
index 000000000..813e6ddcd
--- /dev/null
+++ b/Examples/test-suite/doxygen_misc_constructs.h
@@ -0,0 +1,52 @@
+/*
+ * This file contains comments which demonstrate details about Doxygen processing,
+ * so they can be emulated in SWIG doxy comment translation
+ */
+
+
+
+/**This comment without space after '*' is valid in Doxygen.
+ *
+ */
+void isNoSpaceValidA()
+{}
+
+/**.This comment without space after '*' is valid in Doxygen.
+ *
+ */
+void isNoSpaceValidB()
+{}
+
+
+/***This is not Doxygen comment.
+ *
+ */
+void isNoSpaceValidC()
+{}
+
+
+/**
+ * Backslash following\c word is valid doxygen command. Output contains
+ * 'followingword' with word in 'code' font.
+ */
+void backslashA()
+{}
+
+/**
+ * Doxy command without trailing \cspace space is ignored. Standalone
+ * \ and '\' get to output. Commands not recognized by Doxygen \blah
+ * are ignored. Backslashes in DOS paths d:\xyz\c\myfile and words
+ * following them do not appear on output, we must quote them with
+ * double quotes: "d:\xyz\c\myfile", single quotes do not help:
+ * 'd:\xyz\c\myfile'. Escaping works: d:\\xyz\\c\\myfile. Unix
+ * paths of course have no such problems: /xyz/c/myfile
+ */
+void backslashB()
+{}
+
+/**
+ *
+ */
+void htmlTags()
+{}
+
diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i
index 0af22c72d..447e6b24e 100644
--- a/Examples/test-suite/doxygen_misc_constructs.i
+++ b/Examples/test-suite/doxygen_misc_constructs.i
@@ -37,10 +37,8 @@
* @link Connection::getId() @endlink <br>
*/
void getAddress(int &fileName,
- int line,
- bool isGetSize = false)
- {
- }
+ int line,
+ bool isGetSize = false) {}
// The first comment must be ignored.
/**
@@ -74,27 +72,28 @@
* instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags
* may be specified.
*/
- int waitTime(long waitTime)
- {
- }
+ int waitTime(long waitTime) {return 33;}
// Line with tag \ingroup must not appear in translated comment:
/** \ingroup icFacade
*
- * This class manages connection.
+ * This function returns connection id.
*/
- int getConnection()
- {
- }
+ int getConnection() {return 3;}
+ // the follwing must produce no comment in wrapper
+ /*******************************************************************/
+ char getFirstLetter() {return 'a';}
+
+
/**
* Class description.
*/
class ClassWithNestedEnum {
public:
/**
- * Enum description.b
+ * Enum description.
*/
typedef enum {ONE, ///< desc of one
TWO, ///< desc of two
@@ -102,4 +101,8 @@
} ENested;
};
+
+ #include "doxygen_misc_constructs.h"
+
%}
+ %include "doxygen_misc_constructs.h"
diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
index 7c0928a7a..c7a14f91e 100644
--- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java
+++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
@@ -28,7 +28,7 @@ public class doxygen_misc_constructs_runme {
wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getConnection()",
" \n" +
" \n" +
- " This class manages connection. \n" +
+ " This function returns connection id. \n" +
" \n" +
"");
wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getAddress(doxygen_misc_constructs.SWIGTYPE_p_int, int)",
@@ -119,6 +119,32 @@ public class doxygen_misc_constructs_runme {
" desc of three\n" +
" \n");
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.isNoSpaceValidA()",
+ " This comment without space after '*' is valid in Doxygen. \n" +
+ " \n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.isNoSpaceValidB()",
+ " .This comment without space after '*' is valid in Doxygen. \n" +
+ " \n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashA()",
+ " Backslash following<code>word</code> is valid doxygen command. Output contains \n" +
+ " 'followingword' with word in 'code' font. \n" +
+ " \n" +
+ "");
+
+ wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashB()",
+ " Doxy command without trailing cspace space is ignored. Standalone \n" +
+ " \\ and '\\' get to output. Commands not recognized by Doxygen \n" +
+ " are ignored. Backslashes in DOS paths d: and words \n" +
+ " following them do not appear on output, we must quote them with \n" +
+ " double quotes: \"d:\\xyz\\c\\myfile\", single quotes do not help: \n" +
+ " 'd: '. Escaping works: d:\\xyz\\c\\myfile. Unix \n" +
+ " paths of course have no such problems: /xyz/c/myfile \n" +
+ " \n");
+
// and ask the parser to check comments for us
System.exit(parser.check(wantedComments));
}
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index fb5754856..796281db9 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -349,11 +349,14 @@ static int yylook(void) {
return DOXYGENPOSTSTRING;
}
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) {
- /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
- yylval.str = NewString(loc);
- Setline(yylval.str, Scanner_start_line(scan));
- Setfile(yylval.str, Scanner_file(scan));
- return DOXYGENSTRING;
+ /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
+ /* ignore comments like / * * * and / * * /, which are also ignored by Doxygen */
+ if (loc[3] != '*' && loc[3] != '/') {
+ yylval.str = NewString(loc);
+ Setline(yylval.str, Scanner_start_line(scan));
+ Setfile(yylval.str, Scanner_file(scan));
+ return DOXYGENSTRING;
+ }
}
}
}
diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp
index 667e4f74e..83b08ba39 100644
--- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp
+++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp
@@ -549,6 +549,10 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) {
}
}
+ if (indent == 0) { // we can't indent the first line less than 0
+ indent = 1;
+ }
+
// Create the first line of Javadoc comment.
string indentStr(indent - 1, ' ');
string translatedStr = indentStr + "/**";