2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-27 07:02:15 +00:00

epydoc friendlier formatting

[SVN r39371]
This commit is contained in:
Nikolay Mladenov
2007-09-18 17:32:06 +00:00
parent 92460adce6
commit 7eb0c678ee
9 changed files with 132 additions and 109 deletions

View File

@@ -84,24 +84,27 @@
(2, 4.25, 'wow')
>>> q.f1()
(1, 4.25, 'wow')
>>> q.f2.__doc__.splitlines()[-3]
"f2( (X)self [, (int)x [, (float)y [, (str)z]]]) -> tuple : f2's docstring"
>>> q.f2.__doc__.splitlines()[1]
'f2( (X)self [, (int)x [, (float)y [, (str)z]]]) -> tuple :'
>>> X.f.__doc__.splitlines()[:2]
["f( (X)self, (int)x, (float)y, (str)z) -> tuple : This is X.f's docstring", ' C++ signature:']
>>> q.f2.__doc__.splitlines()[2]
" f2's docstring"
>>> X.f.__doc__.splitlines()[1:5]
['f( (X)self, (int)x, (float)y, (str)z) -> tuple :', " This is X.f's docstring", '', ' C++ signature :']
>>> xfuncs = (X.inner0, X.inner1, X.inner2, X.inner3, X.inner4, X.inner5)
>>> for f in xfuncs:
... print f(q,1).value(),
... print f(q, n = 1).value(),
... print f(q, n = 0).value(),
... print f.__doc__.splitlines()[:2]
1 1 0 ['inner0( (X)self, (bool)n) -> Y : docstring', ' C++ signature:']
1 1 0 ['inner1( (X)self, (bool)n) -> Y : docstring', ' C++ signature:']
1 1 0 ['inner2( (X)self, (bool)n) -> Y : docstring', ' C++ signature:']
1 1 0 ['inner3( (X)self, (bool)n) -> Y : docstring', ' C++ signature:']
1 1 0 ['inner4( (X)self, (bool)n) -> Y : docstring', ' C++ signature:']
1 1 0 ['inner5( (X)self, (bool)n) -> Y : docstring', ' C++ signature:']
... print f.__doc__.splitlines()[1:5]
1 1 0 ['inner0( (X)self, (bool)n) -> Y :', ' docstring', '', ' C++ signature :']
1 1 0 ['inner1( (X)self, (bool)n) -> Y :', ' docstring', '', ' C++ signature :']
1 1 0 ['inner2( (X)self, (bool)n) -> Y :', ' docstring', '', ' C++ signature :']
1 1 0 ['inner3( (X)self, (bool)n) -> Y :', ' docstring', '', ' C++ signature :']
1 1 0 ['inner4( (X)self, (bool)n) -> Y :', ' docstring', '', ' C++ signature :']
1 1 0 ['inner5( (X)self, (bool)n) -> Y :', ' docstring', '', ' C++ signature :']
>>> x = X(a1 = 44, a0 = 22)
>>> x.inner0(0).value()

View File

@@ -64,23 +64,23 @@
... except TypeError: pass
... else: print 'expected a TypeError exception'
>>> print look.__doc__.splitlines()[0]
look( (X)arg1) -> int :
>>> print look.__doc__.splitlines()[1]
look( (X)arg1) -> int :
>>> print steal.__doc__.splitlines()[0]
steal( (X)arg1) -> int :
>>> print steal.__doc__.splitlines()[1]
steal( (X)arg1) -> int :
>>> print maybe_steal.__doc__.splitlines()[0]
maybe_steal( (X)arg1, (bool)arg2) -> int :
>>> print maybe_steal.__doc__.splitlines()[1]
maybe_steal( (X)arg1, (bool)arg2) -> int :
>>> print make.__doc__.splitlines()[0]
make() -> X :
>>> print make.__doc__.splitlines()[1]
make() -> X :
>>> print callback.__doc__.splitlines()[0]
callback( (object)arg1) -> X :
>>> print callback.__doc__.splitlines()[1]
callback( (object)arg1) -> X :
>>> print extract.__doc__.splitlines()[0]
extract( (object)arg1) -> X :
>>> print extract.__doc__.splitlines()[1]
extract( (object)arg1) -> X :
'''

View File

@@ -17,8 +17,8 @@
>>> y_equality(y, y)
1
>>> print y_identity.__doc__.splitlines()[0]
y_identity( (Y)arg1) -> object :
>>> print y_identity.__doc__.splitlines()[1]
y_identity( (Y)arg1) -> object :
'''
def run(args = None):

View File

@@ -113,19 +113,22 @@
... doc = obj.__doc__.splitlines()
... return "\\n".join(["|"+doc[i] for i in args])
>>> print selected_doc(X.__init__, 0, 1, 3, 4)
|__init__( (object)self [, (int)a [, (str)b [, (str)c [, (float)d]]]]) -> None : doc of init
| C++ signature:
| __init__( (object)self, (str)s, (bool)b) -> None :
| C++ signature:
>>> print selected_doc(X.__init__, 1, 2, 4, 7, 9)
|__init__( (object)self [, (int)a [, (str)b [, (str)c [, (float)d]]]]) -> None :
| doc of init
| C++ signature :
|__init__( (object)self, (str)s, (bool)b) -> None :
| C++ signature :
>>> print selected_doc(Y.__init__, 0, 1)
|__init__( (object)arg1) -> None : doc of Y init
| C++ signature:
>>> print selected_doc(Y.__init__, 1, 2, 4)
|__init__( (object)arg1) -> None :
| doc of Y init
| C++ signature :
>>> print selected_doc(X.bar2, 0, 1)
|bar2( (X)arg1 [, (int)arg2 [, (str)arg3 [, (str)arg4 [, (float)arg5]]]]) -> Y : doc of X::bar2
| C++ signature:
>>> print selected_doc(X.bar2, 1, 2, 4)
|bar2( (X)arg1 [, (int)arg2 [, (str)arg3 [, (str)arg4 [, (float)arg5]]]]) -> Y :
| doc of X::bar2
| C++ signature :
"""
def run(args = None):

View File

@@ -8,98 +8,113 @@
... doc = obj.__doc__.splitlines()
... return "\\n".join(["|"+doc[i] for i in args])
>>> print selected_doc(X.__init__, 0, 1, 2)
|__init__( (object)self, (int)value) -> None : this is the __init__ function
|its documentation has two lines.
| C++ signature:
>>> print selected_doc(X.__init__, 1, 2, 3, 4, 5)
|__init__( (object)self, (int)value) -> None :
| this is the __init__ function
| its documentation has two lines.
|
| C++ signature :
>>> print selected_doc(X.value, 0, 1, 3, 4)
|value( (X)self) -> int : gets the value of the object
| C++ signature:
| value( (X)self) -> int : also gets the value of the object
| C++ signature:
>>> print selected_doc(X.value, 1, 2, 4, 7, 8, 10)
|value( (X)self) -> int :
| gets the value of the object
| C++ signature :
|value( (X)self) -> int :
| also gets the value of the object
| C++ signature :
>>> print selected_doc(create, 0, 1)
|create( (int)value) -> X : creates a new X object
| C++ signature:
>>> print selected_doc(create, 1, 2, 3, 4)
|create( (int)value) -> X :
| creates a new X object
|
| C++ signature :
>>> print selected_doc(fact, 0, 1)
|fact( (int)n) -> int : compute the factorial
| C++ signature:
>>> print selected_doc(fact, 1, 2, 3, 4)
|fact( (int)n) -> int :
| compute the factorial
|
| C++ signature :
>>> len(fact_usr_off_1.__doc__.splitlines())
3
>>> print selected_doc(fact_usr_off_1, 0, 1)
|fact_usr_off_1( (int)n) -> int :
| C++ signature:
5
>>> print selected_doc(fact_usr_off_1, 1, 3)
|fact_usr_off_1( (int)n) -> int :
| C++ signature :
>>> len(fact_usr_on_1.__doc__.splitlines())
3
>>> print selected_doc(fact_usr_on_1, 0, 1)
|fact_usr_on_1( (int)n) -> int : usr on 1
| C++ signature:
6
>>> print selected_doc(fact_usr_on_1, 1, 2, 4)
|fact_usr_on_1( (int)n) -> int :
| usr on 1
| C++ signature :
>>> len(fact_usr_off_2.__doc__.splitlines())
3
>>> print selected_doc(fact_usr_off_2, 0,1)
|fact_usr_off_2( (int)n) -> int :
| C++ signature:
5
>>> print selected_doc(fact_usr_off_2, 1, 3)
|fact_usr_off_2( (int)n) -> int :
| C++ signature :
>>> len(fact_usr_on_2.__doc__.splitlines())
3
>>> print selected_doc(fact_usr_on_2, 0, 1)
|fact_usr_on_2( (int)n) -> int : usr on 2
| C++ signature:
6
>>> print selected_doc(fact_usr_on_2, 1, 2, 4)
|fact_usr_on_2( (int)n) -> int :
| usr on 2
| C++ signature :
>>> len(fact_sig_off_1.__doc__.splitlines())
1
>>> print selected_doc(fact_sig_off_1, 0)
2
>>> print selected_doc(fact_sig_off_1, 1)
|sig off 1
>>> len(fact_sig_on_1.__doc__.splitlines())
3
>>> print selected_doc(fact_sig_on_1, 0, 1)
|fact_sig_on_1( (int)n) -> int : sig on 1
| C++ signature:
6
>>> print selected_doc(fact_sig_on_1, 1, 2, 4)
|fact_sig_on_1( (int)n) -> int :
| sig on 1
| C++ signature :
>>> len(fact_sig_off_2.__doc__.splitlines())
1
>>> print selected_doc(fact_sig_off_2, 0)
2
>>> print selected_doc(fact_sig_off_2, 1)
|sig off 2
>>> len(fact_sig_on_2.__doc__.splitlines())
3
>>> print selected_doc(fact_sig_on_2, 0, 1)
|fact_sig_on_2( (int)n) -> int : sig on 2
| C++ signature:
6
>>> print selected_doc(fact_sig_on_2, 1, 2, 4)
|fact_sig_on_2( (int)n) -> int :
| sig on 2
| C++ signature :
>>> print fact_usr_off_sig_off_1.__doc__
None
>>> len(fact_usr_on_sig_on_1.__doc__.splitlines())
3
>>> print selected_doc(fact_usr_on_sig_on_1, 0, 1)
|fact_usr_on_sig_on_1( (int)n) -> int : usr on sig on 1
| C++ signature:
6
>>> print selected_doc(fact_usr_on_sig_on_1, 1, 2, 4)
|fact_usr_on_sig_on_1( (int)n) -> int :
| usr on sig on 1
| C++ signature :
>>> len(fact_usr_on_sig_off_1.__doc__.splitlines())
1
>>> print selected_doc(fact_usr_on_sig_off_1, 0)
2
>>> print selected_doc(fact_usr_on_sig_off_1, 1)
|usr on sig off 1
>>> len(fact_usr_on_sig_on_2.__doc__.splitlines())
3
>>> print selected_doc(fact_usr_on_sig_on_2, 0, 1)
|fact_usr_on_sig_on_2( (int)n) -> int : usr on sig on 2
| C++ signature:
6
>>> print selected_doc(fact_usr_on_sig_on_2, 1, 2, 4)
|fact_usr_on_sig_on_2( (int)n) -> int :
| usr on sig on 2
| C++ signature :
>>> print fact_usr_on_psig_on_csig_off_1.__doc__
fact_usr_on_psig_on_csig_off_1( (int)n) -> int : usr on psig on csig off 1
>>> print selected_doc(fact_usr_on_psig_on_csig_off_1, 1, 2)
|fact_usr_on_psig_on_csig_off_1( (int)n) -> int :
| usr on psig on csig off 1
>>> print selected_doc(fact_usr_on_psig_off_csig_on_1, 0, 1)
>>> print selected_doc(fact_usr_on_psig_off_csig_on_1, 1, 3)
|usr on psig off csig on 1
| C++ signature:
|C++ signature :
>>> print fact_usr_off_psig_on_csig_off_1.__doc__
>>> print fact_usr_off_psig_on_csig_off_1.__doc__.splitlines()[1]
fact_usr_off_psig_on_csig_off_1( (int)n) -> int
>>> print selected_doc(fact_usr_off_psig_off_csig_on_1,0)
| C++ signature:
>>> print selected_doc(fact_usr_off_psig_off_csig_on_1,1)
|C++ signature :
'''

View File

@@ -14,17 +14,17 @@
... except TypeError: pass
... else: print 'no error'
>>> print x_value.__doc__.splitlines()[0]
x_value( (X)arg1) -> int :
>>> print x_value.__doc__.splitlines()[1]
x_value( (X)arg1) -> int :
>>> print make_x.__doc__.splitlines()[0]
make_x( (object)arg1) -> X :
>>> print make_x.__doc__.splitlines()[1]
make_x( (object)arg1) -> X :
>>> print X.value.__doc__.splitlines()[0]
value( (X)arg1) -> int :
>>> print X.value.__doc__.splitlines()[1]
value( (X)arg1) -> int :
>>> print X.set.__doc__.splitlines()[0]
set( (X)arg1, (object)arg2) -> None :
>>> print X.set.__doc__.splitlines()[1]
set( (X)arg1, (object)arg2) -> None :
'''

View File

@@ -80,8 +80,10 @@
>>> f.set(1,1.0,"1")
>>> f.a(), f.b(), f.n()
(1, 1.0, '1')
>>> f.set2.__doc__.splitlines()[-3]
"set2( (Bar)arg1 [, (int)arg2 [, (float)arg3 [, (str)arg4]]]) -> None : set2's docstring"
>>> f.set2.__doc__.splitlines()[1]
'set2( (Bar)arg1 [, (int)arg2 [, (float)arg3 [, (str)arg4]]]) -> None :'
>>> f.set2.__doc__.splitlines()[2]
" set2's docstring"
'''

View File

@@ -183,8 +183,8 @@ are a complicated constructor and member function, respectively.
>>> dd = take_d(d_as_a)
>>> dd.name()
'D'
>>> print g.__doc__.splitlines()[0]
g( (Simple)arg1) -> Simple :
>>> print g.__doc__.splitlines()[1]
g( (Simple)arg1) -> Simple :
"""

View File

@@ -5,7 +5,7 @@
>>> from pytype_function_ext import *
>>> print (' ').join(func.__doc__.splitlines())
func( (A)arg1) -> A : C++ signature: struct B func(struct B)
func( (A)arg1) -> A : C++ signature : struct B func(struct B)
"""
def run(args = None):