summaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/doxygen_code_blocks_runme.py
blob: 46a0a3d8457e8cb34393500fc61a9a4e72e11b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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<int> first;                                // empty vector of ints
    std::vector<int> second (4,100);                       // four ints with value 100
    std::vector<int> third (second.begin(),second.end());  // iterating through second
    std::vector<int> 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<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );

    std::cout << "The contents of fifth are:";
    for (std::vector<int>::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')

A python doctest example:

>>> 1 + 1
2""")