]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/docstring.py
1 # Copyright David Abrahams & Ralf W. Grosse-Kunsteve 2004-2006.
2 # Distributed under the Boost Software License, Version 1.0. (See accompanying
3 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 >>> from docstring_ext import *
7 >>> def selected_doc(obj, *args):
8 ... doc = obj.__doc__.splitlines()
9 ... return "\\n".join(["|"+doc[i] for i in args])
11 >>> print(selected_doc(X.__init__, 1, 2, 3, 4, 5))
12 |__init__( (object)self, (int)value) -> None :
13 | this is the __init__ function
14 | its documentation has two lines.
18 >>> print(selected_doc(X.value, 1, 2, 4, 7, 8, 10))
19 |value( (X)self) -> int :
20 | gets the value of the object
22 |value( (X)self) -> int :
23 | also gets the value of the object
26 >>> print(selected_doc(create, 1, 2, 3, 4))
27 |create( (int)value) -> X :
28 | creates a new X object
32 >>> print(selected_doc(fact, 1, 2, 3, 4))
33 |fact( (int)n) -> int :
34 | compute the factorial
38 >>> len(fact_usr_off_1.__doc__.splitlines())
40 >>> print(selected_doc(fact_usr_off_1, 1, 3))
41 |fact_usr_off_1( (int)n) -> int :
43 >>> len(fact_usr_on_1.__doc__.splitlines())
45 >>> print(selected_doc(fact_usr_on_1, 1, 2, 4))
46 |fact_usr_on_1( (int)n) -> int :
49 >>> len(fact_usr_off_2.__doc__.splitlines())
51 >>> print(selected_doc(fact_usr_off_2, 1, 3))
52 |fact_usr_off_2( (int)n) -> int :
54 >>> len(fact_usr_on_2.__doc__.splitlines())
56 >>> print(selected_doc(fact_usr_on_2, 1, 2, 4))
57 |fact_usr_on_2( (int)n) -> int :
62 >>> len(fact_sig_off_1.__doc__.splitlines())
64 >>> print(selected_doc(fact_sig_off_1, 1))
66 >>> len(fact_sig_on_1.__doc__.splitlines())
68 >>> print(selected_doc(fact_sig_on_1, 1, 2, 4))
69 |fact_sig_on_1( (int)n) -> int :
73 >>> len(fact_sig_off_2.__doc__.splitlines())
75 >>> print(selected_doc(fact_sig_off_2, 1))
77 >>> len(fact_sig_on_2.__doc__.splitlines())
79 >>> print(selected_doc(fact_sig_on_2, 1, 2, 4))
80 |fact_sig_on_2( (int)n) -> int :
85 >>> print(fact_usr_off_sig_off_1.__doc__)
87 >>> len(fact_usr_on_sig_on_1.__doc__.splitlines())
89 >>> print(selected_doc(fact_usr_on_sig_on_1, 1, 2, 4))
90 |fact_usr_on_sig_on_1( (int)n) -> int :
94 >>> len(fact_usr_on_sig_off_1.__doc__.splitlines())
96 >>> print(selected_doc(fact_usr_on_sig_off_1, 1))
98 >>> len(fact_usr_on_sig_on_2.__doc__.splitlines())
100 >>> print(selected_doc(fact_usr_on_sig_on_2, 1, 2, 4))
101 |fact_usr_on_sig_on_2( (int)n) -> int :
105 >>> print(selected_doc(fact_usr_on_psig_on_csig_off_1, 1, 2))
106 |fact_usr_on_psig_on_csig_off_1( (int)n) -> int :
107 | usr on psig on csig off 1
109 >>> print(selected_doc(fact_usr_on_psig_off_csig_on_1, 1, 3))
110 |usr on psig off csig on 1
113 >>> print(fact_usr_off_psig_on_csig_off_1.__doc__.splitlines()[1])
114 fact_usr_off_psig_on_csig_off_1( (int)n) -> int
116 >>> print(selected_doc(fact_usr_off_psig_off_csig_on_1,1))
122 def run(args
= None):
131 result
= doctest
.testmod(sys
.modules
.get(__name__
))
135 docmodule
= lambda m
: re
.sub(".\10", "", pydoc
.text
.docmodule(m
))
137 print('printing module help:')
138 print(docmodule(docstring_ext
))
140 print('********* failed **********')
142 result
= list(result
)
148 if __name__
== '__main__':
152 if (status
== 0): print("Done.")