Skip to content

Commit feea39f

Browse files
committed
Add new test doxygen_basic_translate_style3.i
This is used to test the "///" style of doxygen comments. Previously, newlines in these doxygen comments were not handled correctly.
1 parent b93597b commit feea39f

File tree

4 files changed

+279
-0
lines changed

4 files changed

+279
-0
lines changed

Examples/test-suite/common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ DOXYGEN_TEST_CASES += \
622622
doxygen_basic_notranslate \
623623
doxygen_basic_translate \
624624
doxygen_basic_translate_style2 \
625+
doxygen_basic_translate_style3 \
625626
doxygen_ignore \
626627
doxygen_misc_constructs \
627628
doxygen_nested_class \
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
%module doxygen_basic_translate_style3
2+
3+
%include "doxygen_basic_translate.h"
4+
5+
%inline %{
6+
7+
/// \brief
8+
/// Brief description.
9+
///
10+
/// The comment text.
11+
///
12+
/// \author Some author
13+
///
14+
/// \return Some number
15+
///
16+
/// \sa function2
17+
int function()
18+
{
19+
return 0;
20+
}
21+
22+
/// A test of a very very very very very very very very very very very very very very very very
23+
/// very very very very very long comment string.
24+
void function2()
25+
{
26+
}
27+
28+
/// A test for overloaded functions
29+
/// This is function \b one
30+
void function3(int a)
31+
{
32+
}
33+
34+
/// A test for overloaded functions
35+
/// This is function \b two
36+
void function3(int a, int b)
37+
{
38+
}
39+
40+
/// A test of some mixed tag usage
41+
/// \if CONDITION
42+
/// This \a code fragment shows us something \.
43+
/// \par Minuses:
44+
/// \arg it's senseless
45+
/// \arg it's stupid
46+
/// \arg it's null
47+
///
48+
/// \warning This may not work as expected
49+
/// \code
50+
/// int main() { while(true); }
51+
///
52+
/// // Test blank line in code block
53+
/// \endcode
54+
/// \endif
55+
void function4()
56+
{
57+
}
58+
59+
60+
void function5(int a)
61+
{
62+
}
63+
///< This is a post comment.
64+
65+
/// Test for default args
66+
/// @param a Some parameter, default is 42
67+
void function6(int a=42)
68+
{
69+
}
70+
71+
class Shape
72+
{
73+
public:
74+
typedef Shape* superType;
75+
};
76+
77+
/// Test for a parameter with difficult type
78+
/// (mostly for python)
79+
/// @param a Very strange param
80+
void function7(Shape::superType *a[10])
81+
{
82+
}
83+
84+
/// Multiple parameters test.
85+
///
86+
/// @param y Vertical coordinate.
87+
/// @param x Horizontal coordinate.
88+
/// @return Arc tangent of @c y/x.
89+
double Atan2(double y, double x)
90+
{
91+
return 0;
92+
}
93+
94+
/// Comment at the end of file should be ignored.
95+
%}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
import doxygen_basic_translate_style3.*;
3+
import com.sun.javadoc.*;
4+
import java.util.HashMap;
5+
6+
public class doxygen_basic_translate_style3_runme {
7+
static {
8+
try {
9+
System.loadLibrary("doxygen_basic_translate_style3");
10+
} catch (UnsatisfiedLinkError e) {
11+
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
12+
System.exit(1);
13+
}
14+
}
15+
16+
public static void main(String argv[])
17+
{
18+
/*
19+
Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
20+
and calls the start() method of that class with parsed information.
21+
*/
22+
CommentParser parser = new CommentParser();
23+
com.sun.tools.javadoc.Main.execute("doxygen_basic_translate_style3 runtime test",
24+
"CommentParser",
25+
new String[]{"-quiet", "doxygen_basic_translate_style3"});
26+
27+
HashMap<String, String> wantedComments = new HashMap<String, String>();
28+
29+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function()",
30+
" \n" +
31+
" Brief description.\n" +
32+
" \n" +
33+
" The comment text.\n" +
34+
" @author Some author\n" +
35+
" @return Some number\n" +
36+
" @see function2\n" +
37+
" \n" +
38+
"");
39+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function2()",
40+
" A test of a very very very very very very very very very very very very very very very very \n" +
41+
" very very very very very long comment string. \n" +
42+
" \n" +
43+
"");
44+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function4()",
45+
" A test of some mixed tag usage \n" +
46+
" If: CONDITION {\n" +
47+
" This <i>code </i>fragment shows us something . \n" +
48+
" <p alt=\"Minuses: \">\n" +
49+
" <li>it's senseless \n" +
50+
" </li><li>it's stupid \n" +
51+
" </li><li>it's null \n" +
52+
" \n" +
53+
" </li></p>Warning: This may not work as expected \n" +
54+
" \n" +
55+
" {@code \n" +
56+
"int main() { while(true); } \n" +
57+
"\n" +
58+
"// Test blank line in code block \n" +
59+
" }\n" +
60+
" }\n" +
61+
" \n" +
62+
"");
63+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function3(int)",
64+
" A test for overloaded functions \n" +
65+
" This is function <b>one </b>\n" +
66+
" \n" +
67+
"");
68+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function5(int)",
69+
" This is a post comment. \n" +
70+
"");
71+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function6(int)",
72+
" Test for default args \n" +
73+
" @param a Some parameter, default is 42" +
74+
" \n" +
75+
"");
76+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function6()",
77+
" Test for default args \n" +
78+
" \n" +
79+
"");
80+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function7(doxygen_basic_translate_style3.SWIGTYPE_p_p_p_Shape)",
81+
" Test for a parameter with difficult type \n" +
82+
" (mostly for python) \n" +
83+
" @param a Very strange param \n" +
84+
"");
85+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function3(int, int)",
86+
" A test for overloaded functions \n" +
87+
" This is function <b>two </b>\n" +
88+
" \n" +
89+
"");
90+
wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.Atan2(double, double)",
91+
" Multiple parameters test.\n" +
92+
" \n" +
93+
" @param y Vertical coordinate.\n" +
94+
" @param x Horizontal coordinate.\n" +
95+
" @return Arc tangent of <code>y/x</code>.\n" +
96+
"");
97+
98+
// and ask the parser to check comments for us
99+
System.exit(parser.check(wantedComments));
100+
}
101+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import doxygen_basic_translate_style3
2+
import inspect
3+
import string
4+
import sys
5+
import comment_verifier
6+
7+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function),
8+
"""\
9+
Brief description.
10+
11+
The comment text.
12+
13+
Author: Some author
14+
15+
:rtype: int
16+
:return: Some number
17+
18+
See also: function2"""
19+
)
20+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function2),
21+
"""\
22+
A test of a very very very very very very very very very very very very very very very very
23+
very very very very very long comment string."""
24+
)
25+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function3),
26+
"""*Overload 1:*
27+
A test for overloaded functions
28+
This is function **one**
29+
30+
|
31+
32+
*Overload 2:*
33+
A test for overloaded functions
34+
This is function **two**"""
35+
)
36+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function4),
37+
"""\
38+
A test of some mixed tag usage
39+
If: CONDITION {
40+
This *code* fragment shows us something .
41+
Title: Minuses:
42+
* it\'s senseless
43+
* it\'s stupid
44+
* it\'s null
45+
46+
Warning: This may not work as expected
47+
48+
.. code-block:: c++
49+
50+
int main() { while(true); }
51+
52+
// Test blank line in code block
53+
}"""
54+
)
55+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function5),
56+
"""This is a post comment."""
57+
)
58+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function6),
59+
"""\
60+
Test for default args
61+
:type a: int
62+
:param a: Some parameter, default is 42"""
63+
)
64+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function7),
65+
"""\
66+
Test for a parameter with difficult type
67+
(mostly for python)
68+
:type a: :py:class:`Shape`
69+
:param a: Very strange param"""
70+
)
71+
72+
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.Atan2),
73+
"""\
74+
Multiple parameters test.
75+
76+
:type y: float
77+
:param y: Vertical coordinate.
78+
:type x: float
79+
:param x: Horizontal coordinate.
80+
:rtype: float
81+
:return: Arc tangent of ``y/x``."""
82+
)

0 commit comments

Comments
 (0)