[Epydoc-commits] SF.net SVN: epydoc: [1456] trunk/epydoc/src/epydoc/test
Brought to you by:
edloper
From: <ed...@us...> - 2007-02-11 05:28:17
|
Revision: 1456 http://svn.sourceforge.net/epydoc/?rev=1456&view=rev Author: edloper Date: 2007-02-10 21:28:16 -0800 (Sat, 10 Feb 2007) Log Message: ----------- - Moved various test functions from doctest files (eg, runbuilder, runparser, etc) to a single epydoc.test.util module, so they can be shared between different doctest files. (E.g., the restructuredtext.doctest file needed to make use of the runbuilder function defined in docbuilder.doctest). - Moved all tests that depend on docutils to restructuredtext.doctest - Marked restructuredtext.doctest as requiring the docutils module Modified Paths: -------------- trunk/epydoc/src/epydoc/test/docbuilder.doctest trunk/epydoc/src/epydoc/test/docintrospecter.doctest trunk/epydoc/src/epydoc/test/docparser.doctest trunk/epydoc/src/epydoc/test/encoding.doctest trunk/epydoc/src/epydoc/test/restructuredtext.doctest Modified: trunk/epydoc/src/epydoc/test/docbuilder.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/docbuilder.doctest 2007-02-11 05:25:21 UTC (rev 1455) +++ trunk/epydoc/src/epydoc/test/docbuilder.doctest 2007-02-11 05:28:16 UTC (rev 1456) @@ -12,130 +12,38 @@ name of a variable in the module whose documentation should be built, instead of bilding docs for the whole module. - >>> import tempfile, re, os, os.path, textwrap, sys - >>> from epydoc.docbuilder import build_doc - >>> from epydoc.apidoc import ClassDoc, RoutineDoc - >>> from epydoc.markup import ParsedDocstring + >>> from epydoc.test.util import runbuilder - >>> def to_plain(docstring): - ... """Conver a parsed docstring into plain text""" - ... if isinstance(docstring, ParsedDocstring): - ... docstring = docstring.to_plaintext(None) - ... return docstring.rsplit() - - >>> def fun_to_plain(val_doc): - ... """Convert parsed docstrings in text from a RoutineDoc""" - ... for k, v in val_doc.arg_types.items(): - ... val_doc.arg_types[k] = to_plain(v) - ... for i, (k, v) in enumerate(val_doc.arg_descrs): - ... val_doc.arg_descrs[i] = (k, to_plain(v)) - - >>> def runbuilder(s, attribs='', build=None, exclude=''): - ... # Write it to a temp file. - ... tmp_dir = tempfile.mkdtemp() - ... out = open(os.path.join(tmp_dir, 'epydoc_test.py'), 'w') - ... out.write(textwrap.dedent(s)) - ... out.close() - ... # Build it. - ... val_doc = build_doc(os.path.join(tmp_dir, 'epydoc_test.py')) - ... if build: val_doc = val_doc.variables[build].value - ... # Display it. - ... if isinstance(val_doc, ClassDoc): - ... for val in val_doc.variables.values(): - ... if isinstance(val.value, RoutineDoc): - ... fun_to_plain(val.value) - ... s = val_doc.pp(include=attribs.split(),exclude=exclude.split()) - ... s = re.sub(r"(filename = ).*", r"\1...", s) - ... s = re.sub(r"(<module 'epydoc_test' from ).*", r'\1...', s) - ... s = re.sub(r"(<function \w+ at )0x\w+>", r"\1...>", s) - ... s = re.sub(r"(<\w+ object at )0x\w+>", r"\1...>", s) - ... print s - ... # Clean up. - ... os.unlink(os.path.join(tmp_dir, 'epydoc_test.py')) - ... try: os.unlink(os.path.join(tmp_dir, 'epydoc_test.pyc')) - ... except OSError: pass - ... os.rmdir(tmp_dir) - ... del sys.modules['epydoc_test'] - Docformat selection =================== The docstrings format can be selected using the ``__docformat__`` module -variable. +variable. In the second example below, where docformat='plaintext', +the string "@ivar x: ..." will not be treated as a field, since the +docstring format is plaintext. >>> runbuilder(s=''' - ... __docformat__ = 'restructuredtext' - ... + ... __docformat__ = 'epytext' ... class Foo: - ... """Testing defining_module - ... - ... :cvar `c`: class var in class docstring - ... :type `c`: str - ... """ - ... c = 'abc' - ... - ... def __init__(self): - ... #: A funny number - ... #: - ... #: :type: float - ... self.x = 108.0 - ... - ... y = property( - ... fget=lambda self: 42, - ... doc="""A property has no defining module - ... - ... :type: int - ... """) - ... - ... def f(self): - ... """A function has a defining module - ... - ... :rtype: int - ... """ - ... return 42 + ... """@ivar x: description...""" ... ''', - ... build='Foo', - ... attribs="variables name value type_descr return_type descr") + ... build='Foo', attribs='descr variables') ClassDoc for epydoc_test.Foo [0] - +- descr = u'Testing defining_module' + +- descr = None +- variables - +- __init__ => VariableDoc for epydoc_test.Foo.__init__ [1] - | +- descr = None - | +- name = '__init__' - | +- type_descr = None - | +- value - | +- RoutineDoc for epydoc_test.Foo.__init__ [2] - | +- descr = None - | +- return_type = None - +- c => VariableDoc for epydoc_test.Foo.c [3] - | +- descr = u'class var in class docstring' - | +- name = 'c' - | +- type_descr = u'str' - | +- value - | +- GenericValueDoc [4] - | +- descr = None - +- f => VariableDoc for epydoc_test.Foo.f [5] - | +- descr = None - | +- name = 'f' - | +- type_descr = None - | +- value - | +- RoutineDoc for epydoc_test.Foo.f [6] - | +- descr = u'A function has a defining module' - | +- return_type = u'int' - +- x => VariableDoc for epydoc_test.Foo.x [7] - | +- descr = u'A funny number' - | +- name = u'x' - | +- type_descr = u'float' - | +- value = <UNKNOWN> - +- y => VariableDoc for epydoc_test.Foo.y [8] - +- descr = None - +- name = 'y' - +- type_descr = None - +- value - +- PropertyDoc for epydoc_test.Foo.y [9] - +- descr = u'A property has no defining module' - +- type_descr = u'int' + +- x => VariableDoc for epydoc_test.Foo.x [1] + +- descr = u'description...\n\n' + >>> runbuilder(s=''' + ... __docformat__ = 'plaintext' + ... class Foo: + ... """@var x: description...""" + ... ''', + ... build='Foo', attribs='descr variables') + ClassDoc for epydoc_test.Foo [0] + +- descr = u'@var x: description...\n' + +- variables = {} + Stuff from future doesn't appear as variable. >>> runbuilder(s=""" @@ -381,45 +289,3 @@ +- type_descr = u'date\n\n' +- value = <UNKNOWN> -Also reST consolidated fields are not a problem. - - >>> runbuilder(s=''' - ... __docformat__ = 'restructuredtext' - ... class Foo: - ... """This is the object docstring - ... - ... :Parameters: - ... `a` : string - ... init param. - ... - ... :Exceptions: - ... * `ValueError`: frobnication error - ... init param. - ... - ... :IVariables: - ... `a` : date - ... instance var. - ... """ - ... def __init__(self, a): - ... pass - ... ''', - ... build="Foo", - ... attribs="variables name value exception_descrs " - ... "posargs vararg kwarg type_descr arg_types arg_descrs") - ClassDoc for epydoc_test.Foo [0] - +- variables - +- __init__ => VariableDoc for epydoc_test.Foo.__init__ [1] - | +- name = '__init__' - | +- type_descr = None - | +- value - | +- RoutineDoc for epydoc_test.Foo.__init__ [2] - | +- arg_descrs = [([u'a'], [u'init', u'param.'])] - | +- arg_types = {u'a': [u'string']} - | +- exception_descrs = [(DottedName(u'ValueError'), ... - | +- kwarg = None - | +- posargs = ['self', 'a'] - | +- vararg = None - +- a => VariableDoc for epydoc_test.Foo.a [3] - +- name = u'a' - +- type_descr = u'date' - +- value = <UNKNOWN> Modified: trunk/epydoc/src/epydoc/test/docintrospecter.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/docintrospecter.doctest 2007-02-11 05:25:21 UTC (rev 1455) +++ trunk/epydoc/src/epydoc/test/docintrospecter.doctest 2007-02-11 05:28:16 UTC (rev 1456) @@ -15,36 +15,7 @@ name of a variable in the module whose value should be introspected, instead of introspecting the whole module. - >>> import tempfile, re, os, os.path, textwrap, sys - >>> from epydoc.docintrospecter import introspect_docs - >>> def runintrospecter(s, attribs='', introspect=None, exclude=''): - ... # Write it to a temp file. - ... tmp_dir = tempfile.mkdtemp() - ... out = open(os.path.join(tmp_dir, 'epydoc_test.py'), 'w') - ... out.write(textwrap.dedent(s)) - ... out.close() - ... # Import it. - ... sys.path.insert(0, tmp_dir) - ... if introspect is None: - ... import epydoc_test as val - ... else: - ... exec("from epydoc_test import %s as val" % introspect) - ... del sys.path[0] - ... # Introspect it. - ... val_doc = introspect_docs(val) - ... # Display it. - ... s = val_doc.pp(include=attribs.split(),exclude=exclude.split()) - ... s = re.sub(r"(filename = ).*", r"\1...", s) - ... s = re.sub(r"(<module 'epydoc_test' from ).*", r'\1...', s) - ... s = re.sub(r"(<function \w+ at )0x\w+>", r"\1...>", s) - ... s = re.sub(r"(<\w+ object at )0x\w+>", r"\1...>", s) - ... print s - ... # Clean up. - ... os.unlink(os.path.join(tmp_dir, 'epydoc_test.py')) - ... try: os.unlink(os.path.join(tmp_dir, 'epydoc_test.pyc')) - ... except OSError: pass - ... os.rmdir(tmp_dir) - ... del sys.modules['epydoc_test'] + >>> from epydoc.test.util import runintrospecter Module Variables ================ Modified: trunk/epydoc/src/epydoc/test/docparser.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/docparser.doctest 2007-02-11 05:25:21 UTC (rev 1455) +++ trunk/epydoc/src/epydoc/test/docparser.doctest 2007-02-11 05:28:16 UTC (rev 1456) @@ -15,30 +15,7 @@ module that should be displayed (but the whole module will always be inspected; this just selects what to display). - >>> import tempfile, re, os, os.path, textwrap - >>> from epydoc.apidoc import ClassDoc - >>> from epydoc.docparser import parse_docs - >>> def runparser(s, attribs='', show=None, exclude=''): - ... # Write it to a temp file. - ... tmp_dir = tempfile.mkdtemp() - ... out = open(os.path.join(tmp_dir, 'test.py'), 'w') - ... out.write(textwrap.dedent(s)) - ... out.close() - ... # Parse it. - ... val_doc = parse_docs(out.name) - ... if show is not None: - ... for name in show.split('.'): - ... if isinstance(val_doc, ClassDoc): - ... val_doc = val_doc.local_variables[name].value - ... else: - ... val_doc = val_doc.variables[name].value - ... # Display it. - ... s = val_doc.pp(include=attribs.split(), exclude=exclude.split()) - ... s = re.sub(r"filename = .*", "filename = ...", s) - ... print s - ... # Clean up. - ... os.unlink(os.path.join(tmp_dir, 'test.py')) - ... os.rmdir(tmp_dir) + >>> from epydoc.test.util import runparser Module Variables from Assignment Statements =========================================== Modified: trunk/epydoc/src/epydoc/test/encoding.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/encoding.doctest 2007-02-11 05:25:21 UTC (rev 1455) +++ trunk/epydoc/src/epydoc/test/encoding.doctest 2007-02-11 05:28:16 UTC (rev 1456) @@ -2,7 +2,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test Function ============= -The following function is used as an end-to-end test for unicode +The function `testencoding` is used as an end-to-end test for unicode encodings. It takes a given string, writes it to a python file, and processes that file's documentation. It then generates HTML output from the documentation, extracts all docstrings from the generated @@ -10,59 +10,9 @@ docstrings, it monkey-patches the HMTLwriter.docstring_to_html() method.) - >>> # Display warninings & errors: - >>> from epydoc import log - >>> log.register_logger(log.SimpleLogger()) + >>> from epydoc.test.util import print_warnings, testencoding + >>> print_warnings() - >>> # Other imports: - >>> import tempfile, os, re, textwrap, sys - >>> from epydoc.docbuilder import build_doc_index - >>> from epydoc.docwriter.html import HTMLWriter - - >>> # Monkey-patch the write function: - >>> def docstring_to_html(self, parsed_docstring, w=None, i=0): - ... s = parsed_docstring.to_html(None).strip() - ... s = s.encode('ascii', 'xmlcharrefreplace') - ... s = remove_surrogates(s) - ... print s - ... return '' - >>> HTMLWriter.docstring_to_html = docstring_to_html - - >>> # The actual test function: - >>> def test(s, introspect=True, parse=True, debug=False): - ... # Write s to a temporary file. - ... tmp_dir = tempfile.mkdtemp() - ... path = os.path.join(tmp_dir, 'enc_test.py') - ... out = open(path, 'w') - ... out.write(textwrap.dedent(s)) - ... out.close() - ... # Build docs for it - ... docindex = build_doc_index([path], introspect, parse) - ... if docindex is None: return - ... try: del sys.modules['enc_test'] - ... except: pass - ... # Write html output. - ... writer = HTMLWriter(docindex, mark_docstrings=True) - ... writer.write(tmp_dir) - ... for file in os.listdir(tmp_dir): - ... os.unlink(os.path.join(tmp_dir,file)) - ... os.rmdir(tmp_dir) - -The following is a helper function, used to convert two-character -surrogate sequences into single characters. This is needed because -some systems create surrogates but others don't. - - >>> def remove_surrogates(s): - ... pieces = re.split('(&#\d+;)', s) - ... for i in range(3, len(pieces)-1, 2): - ... if pieces[i-1] != '': continue - ... high,low = int(pieces[i-2][2:-1]), int(pieces[i][2:-1]) - ... if 0xd800 <= high <= 0xdbff and 0xdc00 <= low <= 0xdfff: - ... pieces[i-2] = '&#%d;' % (((high&0x3ff)<<10) + - ... (low&0x3ff) + 0x10000) - ... pieces[i] = '' - ... return ''.join(pieces) - Encoding Tests ============== This section tests the output for a variety of different encodings. @@ -72,27 +22,27 @@ Tests for several Microsoft codepges: - >>> test('''# -*- coding: cp874 -*- + >>> testencoding('''# -*- coding: cp874 -*- ... """abc ABC 123 \x80 \x85""" ... ''') abc ABC 123 € … - >>> test('''# -*- coding: cp1250 -*- + >>> testencoding('''# -*- coding: cp1250 -*- ... """abc ABC 123 \x80 \x82 \x84 \x85 \xff""" ... ''') abc ABC 123 € ‚ „ … ˙ - >>> test('''# -*- coding: cp1251 -*- + >>> testencoding('''# -*- coding: cp1251 -*- ... """abc ABC 123 \x80 \x81 \x82 \xff""" ... ''') abc ABC 123 Ђ Ѓ ‚ я - >>> test('''# -*- coding: cp1252 -*- + >>> testencoding('''# -*- coding: cp1252 -*- ... """abc ABC 123 \x80 \x82 \x83 \xff""" ... ''') abc ABC 123 € ‚ ƒ ÿ - >>> test('''# -*- coding: cp1253 -*- + >>> testencoding('''# -*- coding: cp1253 -*- ... """abc ABC 123 \x80 \x82 \x83 \xfe""" ... ''') abc ABC 123 € ‚ ƒ ώ @@ -115,21 +65,21 @@ >>> utf8_bom = '\xef\xbb\xbf' >>> # UTF-8 with a coding directive: - >>> test("# -*- coding: utf-8 -*-\n"+utf8_test) + >>> testencoding("# -*- coding: utf-8 -*-\n"+utf8_test) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   >>> # UTF-8 with a BOM & a coding directive: - >>> test(utf8_bom+"# -*- coding: utf-8 -*-\n"+utf8_test) + >>> testencoding(utf8_bom+"# -*- coding: utf-8 -*-\n"+utf8_test) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   >>> # UTF-8 with a BOM & no coding directive: - >>> test(utf8_bom+utf8_test) + >>> testencoding(utf8_bom+utf8_test) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> @@ -137,30 +87,30 @@ Tests for KOI8-R: - >>> test('''# -*- coding: koi8-r -*- + >>> testencoding('''# -*- coding: koi8-r -*- ... """abc ABC 123 \x80 \x82 \x83 \xff""" ... ''') abc ABC 123 ─ ┌ ┐ Ъ Tests for 'coding' directive on the second line: - >>> test('''\n# -*- coding: cp1252 -*- + >>> testencoding('''\n# -*- coding: cp1252 -*- ... """abc ABC 123 \x80 \x82 \x83 \xff""" ... ''') abc ABC 123 € ‚ ƒ ÿ - >>> test('''# comment on the first line.\n# -*- coding: cp1252 -*- + >>> testencoding('''# comment on the first line.\n# -*- coding: cp1252 -*- ... """abc ABC 123 \x80 \x82 \x83 \xff""" ... ''') abc ABC 123 € ‚ ƒ ÿ - >>> test("\n# -*- coding: utf-8 -*-\n"+utf8_test) + >>> testencoding("\n# -*- coding: utf-8 -*-\n"+utf8_test) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   - >>> test("# comment\n# -*- coding: utf-8 -*-\n"+utf8_test) + >>> testencoding("# comment\n# -*- coding: utf-8 -*-\n"+utf8_test) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> @@ -168,7 +118,7 @@ Tests for shift-jis - >>> test('''# -*- coding: shift_jis -*- + >>> testencoding('''# -*- coding: shift_jis -*- ... """abc ABC 123 \xA1 \xA2 \xA3""" ... ''') abc ABC 123 。 「 」 @@ -177,12 +127,12 @@ ================ Make sure that we use the coding for both str and unicode docstrings. - >>> test('''# -*- coding: utf-8 -*- + >>> testencoding('''# -*- coding: utf-8 -*- ... """abc ABC 123 \xc2\x80 \xdf\xbf \xe0\xa0\x80""" ... ''') abc ABC 123 € ߿ ࠀ - >>> test('''# -*- coding: utf-8 -*- + >>> testencoding('''# -*- coding: utf-8 -*- ... u"""abc ABC 123 \xc2\x80 \xdf\xbf \xe0\xa0\x80""" ... ''') abc ABC 123 € ߿ ࠀ @@ -199,7 +149,7 @@ as latin-1. An example of this is a non-unicode docstring for properties: - >>> test('''# -*- coding: utf-8 -*- + >>> testencoding('''# -*- coding: utf-8 -*- ... p=property(doc="""\xc2\x80""") ... ''') # doctest: +ELLIPSIS <property object at ...>'s docstring is not a unicode string, but it contains non-ascii data -- treating it as latin-1. @@ -210,33 +160,33 @@ This section checks to make sure that both introspection & parsing are getting the right results. - >>> test("# -*- coding: utf-8 -*-\n"+utf8_test, introspect=False) + >>> testencoding("# -*- coding: utf-8 -*-\n"+utf8_test, introspect=False) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   - >>> test(utf8_bom+"# -*- coding: utf-8 -*-\n"+utf8_test, introspect=False) + >>> testencoding(utf8_bom+"# -*- coding: utf-8 -*-\n"+utf8_test, introspect=False) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   - >>> test(utf8_bom+utf8_test, introspect=False) + >>> testencoding(utf8_bom+utf8_test, introspect=False) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   - >>> test("# -*- coding: utf-8 -*-\n"+utf8_test, parse=False) + >>> testencoding("# -*- coding: utf-8 -*-\n"+utf8_test, parse=False) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   - >>> test(utf8_bom+"# -*- coding: utf-8 -*-\n"+utf8_test, parse=False) + >>> testencoding(utf8_bom+"# -*- coding: utf-8 -*-\n"+utf8_test, parse=False) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> 0x10000-0x10ffff range: 𐀀 𐀁   - >>> test(utf8_bom+utf8_test, parse=False) + >>> testencoding(utf8_bom+utf8_test, parse=False) <p>abc ABC 123</p> <p>0x80-0x7ff range: €  ߾ ߿</p> <p>0x800-0xffff range: ࠀ ࠁ  </p> @@ -246,7 +196,7 @@ ============== Make sure that docstrings are rendered correctly in different contexts. - >>> test('''# -*- coding: utf-8 -*- + >>> testencoding('''# -*- coding: utf-8 -*- ... """ ... @var x: abc ABC 123 \xc2\x80 \xdf\xbf \xe0\xa0\x80 ... @group \xc2\x80: x @@ -254,7 +204,7 @@ ... ''') abc ABC 123 € ߿ ࠀ - >>> test('''# -*- coding: utf-8 -*- + >>> testencoding('''# -*- coding: utf-8 -*- ... def f(x): ... """ ... abc ABC 123 \xc2\x80 \xdf\xbf \xe0\xa0\x80 @@ -274,7 +224,7 @@ abc ABC 123 € ߿ ࠀ abc ABC 123 € ߿ ࠀ - >>> test('''# -*- coding: utf-8 -*- + >>> testencoding('''# -*- coding: utf-8 -*- ... class A: ... """ ... abc ABC 123 \xc2\x80 \xdf\xbf \xe0\xa0\x80 Modified: trunk/epydoc/src/epydoc/test/restructuredtext.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/restructuredtext.doctest 2007-02-11 05:25:21 UTC (rev 1455) +++ trunk/epydoc/src/epydoc/test/restructuredtext.doctest 2007-02-11 05:28:16 UTC (rev 1456) @@ -1,5 +1,6 @@ -Regression Testing for plaintext -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Regression Testing for restructuredtext +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:RequireModule: docutils Summary ======= @@ -108,3 +109,125 @@ <span class="py-keyword">def</span> <span class="py-defname">__init__</span>(self): <span class="py-keyword">pass</span></pre> <BLANKLINE> + +Consolidated Fields +=================== + + >>> from epydoc.test.util import runbuilder + + >>> runbuilder(s=''' + ... __docformat__ = 'restructuredtext' + ... class Foo: + ... """This is the object docstring + ... + ... :Parameters: + ... `a` : string + ... init param. + ... + ... :Exceptions: + ... * `ValueError`: frobnication error + ... init param. + ... + ... :IVariables: + ... `a` : date + ... instance var. + ... """ + ... def __init__(self, a): + ... pass + ... ''', + ... build="Foo", + ... attribs="variables name value exception_descrs " + ... "posargs vararg kwarg type_descr arg_types arg_descrs") + ClassDoc for epydoc_test.Foo [0] + +- variables + +- __init__ => VariableDoc for epydoc_test.Foo.__init__ [1] + | +- name = '__init__' + | +- type_descr = None + | +- value + | +- RoutineDoc for epydoc_test.Foo.__init__ [2] + | +- arg_descrs = [([u'a'], [u'init', u'param.'])] + | +- arg_types = {u'a': [u'string']} + | +- exception_descrs = [(DottedName(u'ValueError'), ... + | +- kwarg = None + | +- posargs = ['self', 'a'] + | +- vararg = None + +- a => VariableDoc for epydoc_test.Foo.a [3] + +- name = u'a' + +- type_descr = u'date' + +- value = <UNKNOWN> + +Misc rst constructs +=================== + + >>> runbuilder(s=''' + ... __docformat__ = 'restructuredtext' + ... + ... class Foo: + ... """Testing defining_module + ... + ... :cvar `c`: class var in class docstring + ... :type `c`: str + ... """ + ... c = 'abc' + ... + ... def __init__(self): + ... #: A funny number + ... #: + ... #: :type: float + ... self.x = 108.0 + ... + ... y = property( + ... fget=lambda self: 42, + ... doc="""A property has no defining module + ... + ... :type: int + ... """) + ... + ... def f(self): + ... """A function has a defining module + ... + ... :rtype: int + ... """ + ... return 42 + ... ''', + ... build='Foo', + ... attribs="variables name value type_descr return_type descr") + ClassDoc for epydoc_test.Foo [0] + +- descr = u'Testing defining_module' + +- variables + +- __init__ => VariableDoc for epydoc_test.Foo.__init__ [1] + | +- descr = None + | +- name = '__init__' + | +- type_descr = None + | +- value + | +- RoutineDoc for epydoc_test.Foo.__init__ [2] + | +- descr = None + | +- return_type = None + +- c => VariableDoc for epydoc_test.Foo.c [3] + | +- descr = u'class var in class docstring' + | +- name = 'c' + | +- type_descr = u'str' + | +- value + | +- GenericValueDoc [4] + | +- descr = None + +- f => VariableDoc for epydoc_test.Foo.f [5] + | +- descr = None + | +- name = 'f' + | +- type_descr = None + | +- value + | +- RoutineDoc for epydoc_test.Foo.f [6] + | +- descr = u'A function has a defining module' + | +- return_type = u'int' + +- x => VariableDoc for epydoc_test.Foo.x [7] + | +- descr = u'A funny number' + | +- name = u'x' + | +- type_descr = u'float' + | +- value = <UNKNOWN> + +- y => VariableDoc for epydoc_test.Foo.y [8] + +- descr = None + +- name = 'y' + +- type_descr = None + +- value + +- PropertyDoc for epydoc_test.Foo.y [9] + +- descr = u'A property has no defining module' + +- type_descr = u'int' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |