From 5230afb3e1ce626cfcb34dd720dbb277e025da6c Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 4 Aug 2019 17:32:53 -0500 Subject: [PATCH] Add new doxygen test doxygen_code_blocks This does somewhat more detailed testing of the code block parsing, and also exercises the language identification of python doctest features. For now, it is only tested by python (javadoc translation may not correctly handle some of the characters that are used here). --- Examples/test-suite/common.mk | 1 + Examples/test-suite/doxygen_code_blocks.i | 56 +++++++++++++++++++ .../python/doxygen_code_blocks_runme.py | 53 ++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 Examples/test-suite/doxygen_code_blocks.i create mode 100644 Examples/test-suite/python/doxygen_code_blocks_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 7aa0e91d1..93128afd4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -630,6 +630,7 @@ DOXYGEN_TEST_CASES += \ doxygen_translate \ doxygen_translate_all_tags \ doxygen_translate_links \ + doxygen_code_blocks \ $(DOXYGEN_TEST_CASES:=.cpptest): SWIGOPT += -doxygen diff --git a/Examples/test-suite/doxygen_code_blocks.i b/Examples/test-suite/doxygen_code_blocks.i new file mode 100644 index 000000000..220ae13a3 --- /dev/null +++ b/Examples/test-suite/doxygen_code_blocks.i @@ -0,0 +1,56 @@ +%module doxygen_code_blocks + +// This test is only used with Python + +%inline %{ + +/** + * \brief Test for code blocks + * + * \code + * simple code block + * \endcode + * + * More advanced usage with C++ characters: + * \code + * std::vector first; // empty vector of ints + * std::vector second (4,100); // four ints with value 100 + * std::vector third (second.begin(),second.end()); // iterating through second + * std::vector fourth (third); // a copy of third + * // the iterator constructor can also be used to construct from arrays: + * int myints[] = {16,2,77,29}; + * std::vector fifth (myints, myints + sizeof(myints) / sizeof(int) ); + * + * std::cout << "The contents of fifth are:"; + * for (std::vector::iterator it = fifth.begin(); it != fifth.end(); ++it) + * std::cout << ' ' << *it; + * std::cout << '\n'; + * \endcode + * + * A code block for C: + * \code{.c} + * printf("hello world"); + * \endcode + * + * A code block for Java: + * \code{.java} + * public class HelloWorld { + * public static void main(String[] args) { + * // Prints "Hello, World" to the terminal window. + * System.out.println("Hello, World"); + * } + * } + * \endcode + * + * A code block for python: + * \code{.py} + * print('hello world') + * \endcode + */ +int function() +{ + return 0; +} + + +%} diff --git a/Examples/test-suite/python/doxygen_code_blocks_runme.py b/Examples/test-suite/python/doxygen_code_blocks_runme.py new file mode 100644 index 000000000..a421c8267 --- /dev/null +++ b/Examples/test-suite/python/doxygen_code_blocks_runme.py @@ -0,0 +1,53 @@ +import doxygen_code_blocks +import inspect +import string +import sys +import comment_verifier + +comment_verifier.check(inspect.getdoc(doxygen_code_blocks.function), + """\ +Test for code blocks + +.. code-block:: c++ + + simple code block + +More advanced usage with C++ characters: + +.. code-block:: c++ + + std::vector first; // empty vector of ints + std::vector second (4,100); // four ints with value 100 + std::vector third (second.begin(),second.end()); // iterating through second + std::vector fourth (third); // a copy of third + // the iterator constructor can also be used to construct from arrays: + int myints[] = {16,2,77,29}; + std::vector fifth (myints, myints + sizeof(myints) / sizeof(int) ); + + std::cout << "The contents of fifth are:"; + for (std::vector::iterator it = fifth.begin(); it != fifth.end(); ++it) + std::cout << ' ' << *it; + std::cout << '\\n'; + +A code block for C: + +.. code-block:: c + + printf("hello world"); + +A code block for Java: + +.. code-block:: java + + public class HelloWorld { + public static void main(String[] args) { + // Prints "Hello, World" to the terminal window. + System.out.println("Hello, World"); + } + } + +A code block for python: + +.. code-block:: python + + print('hello world')""")