Line | |
---|
1 | # Copyright David Abrahams 2004. Distributed under the Boost |
---|
2 | # Software License, Version 1.0. (See accompanying |
---|
3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | ''' |
---|
5 | >>> from docstring_ext import * |
---|
6 | |
---|
7 | >>> def printdoc(x): |
---|
8 | ... print x.__doc__ |
---|
9 | |
---|
10 | >>> printdoc(X) |
---|
11 | A simple class wrapper around a C++ int |
---|
12 | includes some error-checking |
---|
13 | |
---|
14 | >>> printdoc(X.__init__) |
---|
15 | this is the __init__ function |
---|
16 | its documentation has two lines. |
---|
17 | |
---|
18 | >>> printdoc(create) |
---|
19 | creates a new X object |
---|
20 | |
---|
21 | >>> printdoc(fact) |
---|
22 | compute the factorial |
---|
23 | ''' |
---|
24 | |
---|
25 | def check_double_string(): |
---|
26 | """ |
---|
27 | >>> assert check_double_string() == True |
---|
28 | """ |
---|
29 | from docstring_ext import X |
---|
30 | return X.value.__doc__ == "gets the value of the object\n\nalso gets the value of the object" |
---|
31 | |
---|
32 | def run(args = None): |
---|
33 | import sys |
---|
34 | import doctest |
---|
35 | |
---|
36 | if args is not None: |
---|
37 | sys.argv = args |
---|
38 | |
---|
39 | import docstring_ext |
---|
40 | |
---|
41 | result = doctest.testmod(sys.modules.get(__name__)) |
---|
42 | |
---|
43 | import pydoc |
---|
44 | import re |
---|
45 | docmodule = lambda m: re.sub(".\10", "", pydoc.text.docmodule(m)) |
---|
46 | try: |
---|
47 | print 'printing module help:' |
---|
48 | print docmodule(docstring_ext) |
---|
49 | except object, x: |
---|
50 | print '********* failed **********' |
---|
51 | print x |
---|
52 | result = list(result) |
---|
53 | result[0] += 1 |
---|
54 | return tuple(result) |
---|
55 | |
---|
56 | return result |
---|
57 | |
---|
58 | if __name__ == '__main__': |
---|
59 | print "running..." |
---|
60 | import sys |
---|
61 | status = run()[0] |
---|
62 | if (status == 0): print "Done." |
---|
63 | sys.exit(status) |
---|
Note: See
TracBrowser
for help on using the repository browser.