Add support for doxygen:alias feature

This allows to replace non-standard Doxygen commands with some (fixed) text
instead of just ignoring them, as was already possible with the feature
doxygen:ignore.
This commit is contained in:
Vadim Zeitlin 2017-02-01 02:06:16 +01:00
commit 751f617aac
7 changed files with 144 additions and 4 deletions

View file

@ -583,6 +583,7 @@ $(eval HAS_DOXYGEN := $($(LANGUAGE)_HAS_DOXYGEN))
ifdef HAS_DOXYGEN
DOXYGEN_TEST_CASES += \
doxygen_parsing \
doxygen_alias \
doxygen_ignore \
doxygen_basic_translate \
doxygen_basic_notranslate \

View file

@ -0,0 +1,22 @@
%module doxygen_alias
#ifdef SWIGJAVA
%feature("doxygen:alias:nullptr") "null"
#elif defined(SWIGPYTHON)
%feature("doxygen:alias:nullptr") "None"
#else
%feature("doxygen:alias:nullptr") "NULL"
#endif
%inline %{
class Something {};
/**
A function returning something.
@returns A new object which may be @nullptr.
*/
Something* make_something() { return 0; }
%}

View file

@ -0,0 +1,32 @@
import doxygen_alias.*;
import com.sun.javadoc.*;
import java.util.HashMap;
public class doxygen_alias_runme {
static {
try {
System.loadLibrary("doxygen_alias");
} catch (UnsatisfiedLinkError e) {
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);
System.exit(1);
}
}
public static void main(String argv[])
{
CommentParser parser = new CommentParser();
com.sun.tools.javadoc.Main.execute("doxygen_alias runtime test",
"CommentParser",
new String[]{"-quiet", "doxygen_alias"});
HashMap<String, String> wantedComments = new HashMap<String, String>();
wantedComments.put("doxygen_alias.doxygen_alias.make_something()",
" A function returning something.<br>\n" +
" <br>\n" +
" @return A new object which may be null.\n" +
"");
System.exit(parser.check(wantedComments));
}
}

View file

@ -0,0 +1,12 @@
#!/usr/bin/python
import doxygen_alias
import inspect
import commentVerifier
commentVerifier.check(inspect.getdoc(doxygen_alias.make_something),
"""\
A function returning something.
:rtype: :py:class:`Something`
:return: A new object which may be None.""")