From 7eb0c678ee2b5059034b8f10864a4c7dbca8634a Mon Sep 17 00:00:00 2001 From: Nikolay Mladenov Date: Tue, 18 Sep 2007 17:32:06 +0000 Subject: [PATCH] epydoc friendlier formatting [SVN r39371] --- test/args.py | 25 ++++---- test/auto_ptr.py | 24 +++---- test/back_reference.py | 4 +- test/defaults.py | 25 ++++---- test/docstring.py | 135 ++++++++++++++++++++++------------------ test/implicit.py | 16 ++--- test/keywords_test.py | 6 +- test/newtest.py | 4 +- test/pytype_function.py | 2 +- 9 files changed, 132 insertions(+), 109 deletions(-) diff --git a/test/args.py b/test/args.py index 15be2b97..44a9cd25 100644 --- a/test/args.py +++ b/test/args.py @@ -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() diff --git a/test/auto_ptr.py b/test/auto_ptr.py index a1e24392..2e4bed61 100644 --- a/test/auto_ptr.py +++ b/test/auto_ptr.py @@ -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 : ''' diff --git a/test/back_reference.py b/test/back_reference.py index ed595ad0..6705ee7b 100644 --- a/test/back_reference.py +++ b/test/back_reference.py @@ -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): diff --git a/test/defaults.py b/test/defaults.py index 153f7de1..e68293df 100644 --- a/test/defaults.py +++ b/test/defaults.py @@ -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): diff --git a/test/docstring.py b/test/docstring.py index 2ad98139..528ce845 100644 --- a/test/docstring.py +++ b/test/docstring.py @@ -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 : ''' diff --git a/test/implicit.py b/test/implicit.py index f99c8d88..ac82d948 100644 --- a/test/implicit.py +++ b/test/implicit.py @@ -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 : ''' diff --git a/test/keywords_test.py b/test/keywords_test.py index 7f5da987..261de0b3 100644 --- a/test/keywords_test.py +++ b/test/keywords_test.py @@ -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" ''' diff --git a/test/newtest.py b/test/newtest.py index 23c4298a..1862dcb4 100644 --- a/test/newtest.py +++ b/test/newtest.py @@ -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 : """ diff --git a/test/pytype_function.py b/test/pytype_function.py index d2f46c9f..2ca13c7f 100755 --- a/test/pytype_function.py +++ b/test/pytype_function.py @@ -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):