Skip to content

Commit

Permalink
Cleanup uses of ellipsis and excess doctest comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed May 17, 2017
1 parent ad4789a commit 87dc2e9
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/zope/app/apidoc/README.rst
Expand Up @@ -52,7 +52,7 @@ Now we can instantiate the class (which is usually done when traversing
>>> modules
[u'Interface', u'ZCML']

>>> doc['ZCML'] #doctest:+ELLIPSIS
>>> doc['ZCML']
<zope.app.apidoc.zcmlmodule.ZCMLModule object at ...>


Expand Down
2 changes: 1 addition & 1 deletion src/zope/app/apidoc/browser/nodevmode.rst
Expand Up @@ -14,5 +14,5 @@ assume that their instances are running in developer mode, while they aren't.
>>> browser.handleErrors = False
>>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
>>> browser.open("http://localhost/++apidoc++")
>>> browser.contents # doctest: +ELLIPSIS
>>> browser.contents
'...API documentation is disabled...'
18 changes: 9 additions & 9 deletions src/zope/app/apidoc/classregistry.rst
Expand Up @@ -69,18 +69,18 @@ There are two API methods specific to the class registry:
This method returns all classes that implement the specified interface:

>>> from pprint import pprint
>>> pprint(reg.getClassesThatImplement(IA)) #doctest:+ELLIPSIS
[('A', <class '...A'>),
('A2', <class '...A2'>),
('B', <class ...B...>),
('B2', <class '...B2'>)]
>>> pprint(reg.getClassesThatImplement(IA))
[('A', <class 'zope.app.apidoc.doctest.A'>),
('A2', <class 'zope.app.apidoc.doctest.A2'>),
('B', <class 'zope.app.apidoc.doctest.B'>),
('B2', <class 'zope.app.apidoc.doctest.B2'>)]

>>> pprint(reg.getClassesThatImplement(IB)) #doctest:+ELLIPSIS
[('B', <class ...B...>),
('B2', <class '...B2'>)]
>>> pprint(reg.getClassesThatImplement(IB))
[('B', <class 'zope.app.apidoc.doctest.B'>),
('B2', <class 'zope.app.apidoc.doctest.B2'>)]

>>> pprint(reg.getClassesThatImplement(IC))
[('C', <class '...C'>)]
[('C', <class 'zope.app.apidoc.doctest.C'>)]

>>> pprint(reg.getClassesThatImplement(ID))
[]
Expand Down
14 changes: 7 additions & 7 deletions src/zope/app/apidoc/codemodule/README.rst
Expand Up @@ -146,11 +146,11 @@ and methods of this class::
[]

>>> klass.getMethods()[0]
('get', <... APIDocumentation.get...>,
('get', <function APIDocumentation.get at ...>,
<InterfaceClass zope.interface.common.mapping.IReadMapping>)

>>> klass.getConstructor()
<... APIDocumentation.__init__...>
<function APIDocumentation.__init__ at ...>

Let's have a closer look at the `getAttributes()` method. First we create an
interface called `IBlah` that is implemented by the class `Blah`:
Expand All @@ -177,8 +177,8 @@ listed in the interface. Now we create the class documentation wrapper:
>>> from pprint import pprint
>>> pprint(klass.getAttributes())
[('bar', 'b', None),
('bli', 'i', <InterfaceClass ...builtin....IBlie>),
('foo', 'f', <InterfaceClass ...builtin....IBlah>)]
('bli', 'i', <InterfaceClass __builtin__.IBlie>),
('foo', 'f', <InterfaceClass __builtin__.IBlah>)]

So, the function returns a list of tuples of the form (name, value,
interface), where the interface is the interface in which the attribute was
Expand Down Expand Up @@ -211,8 +211,8 @@ Now we create the class documentation wrapper:
and get the method documentation:

>>> pprint(klass.getMethods())
[('bar', <... Blah.bar...>, None),
('foo', <... Blah.foo...>, <InterfaceClass ...builtin....IBlah>)]
[('bar', <function Blah.bar at ...>, None),
('foo', <function Blah.foo at ...>, <InterfaceClass __builtin__.IBlah>)]


.. cleanup
Expand Down Expand Up @@ -324,7 +324,7 @@ the attributes of the XML element,
the configuration context for the directive, which can be used to resolve
objects and/or generate absolute paths of files,

>>> root.context #doctest:+ELLIPSIS
>>> root.context
<zope.configuration.config.ConfigurationMachine object at ...>

the parser info object,
Expand Down
18 changes: 0 additions & 18 deletions src/zope/app/apidoc/codemodule/browser/introspector.rst
Expand Up @@ -144,26 +144,18 @@ Now the introspector will show the file and allow you to click on it:
>>> print(browser.contents)
<!DOCTYPE...
...
<BLANKLINE>
<div>
<h2>Mapping Items</h2>
<BLANKLINE>
<div class="indent">
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<ul class="attr-list">
<li>
<BLANKLINE>
<b>
<code>'file.txt'</code>
</b>
<br />
<a href="++items++file.txt/@@introspector.html">
<code>&lt;zope.app.file.file.File object at ...&gt;</code>
</a>
<BLANKLINE>
<BLANKLINE>
(<span>type:</span>
<a href="http://localhost/++apidoc++/Code/zope/container/contained/ContainedProxy/index.html">
<code>ContainedProxy</code></a>)
Expand All @@ -177,28 +169,19 @@ provides is the Dublin Core:
<!DOCTYPE...
...
<h2>Annotations</h2>
<BLANKLINE>
<div class="indent">
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<ul class="attr-list">
<li>
<BLANKLINE>
<b>
<code>'zope.app.dublincore.ZopeDublinCore'</code>
</b>
<br />
<a href="++annotations++zope.app.dublincore.ZopeDublinCore/@@introspector.html">
<code>...</code>
</a>
<BLANKLINE>
<BLANKLINE>
(<span>type:</span>
<a href="http://localhost/++apidoc++/Code/zope/dublincore/annotatableadapter/ZDCAnnotationData/index.html">
<code>ZDCAnnotationData</code></a>)
<BLANKLINE>
<BLANKLINE>
</li>
</ul>
</div>
Expand All @@ -217,7 +200,6 @@ the exact constructor signature varies depending on Python version
<!DOCTYPE...
...
<h2 ...>Constructor</h2>
<BLANKLINE>
<div class="indent">
<div>
<b><code>__init__(..., **kwargs)</code>
Expand Down
12 changes: 0 additions & 12 deletions src/zope/app/apidoc/codemodule/module.py
Expand Up @@ -55,18 +55,6 @@ def __init__(self, parent, name, module, setup=True):
if setup:
self.__setup()

def __XXXrepr__(self):
cls = self.__class__
path = []
i = self
while i is not None:
path.append(getattr(i, '__name__', '') or '')
i = i.__parent__
path.reverse()
path = '.'.join(path)
return "<%s.%s '%s' at %s>" % (cls.__module__, cls.__name__,
path, id(self))

def __setup(self):
"""Setup the module sub-tree."""
# Detect packages
Expand Down
12 changes: 6 additions & 6 deletions src/zope/app/apidoc/component.rst
Expand Up @@ -216,13 +216,13 @@ Now let's have a look what we have:

>>> regs = list(component.getUtilities(IFooBar))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
>>> regs
[UtilityRegistration(<BaseGlobalComponents base>, IFooBar, u'',
<zope.app.apidoc.doctest.MyFooBar object at ...>, None, u'')]

>>> regs = list(component.getUtilities(IFoo))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
>>> regs
[UtilityRegistration(<BaseGlobalComponents base>, IFoo, u'',
<zope.app.apidoc.doctest.MyFoo object at ...>, None, u''),
UtilityRegistration(<BaseGlobalComponents base>, IFooBar, u'',
Expand Down Expand Up @@ -321,9 +321,9 @@ object references. This may change.
This function returns the info dictionary of a type.

>>> pprint(component.getTypeInfoDictionary(tuple), width=1)
{'module': '...builtin...',
{'module': '__builtin__',
'name': 'tuple',
'url': '...builtin.../tuple'}
'url': '__builtin__/tuple'}


`getSpecificationInfoDictionary(spec)`
Expand Down Expand Up @@ -351,9 +351,9 @@ Let's now look at the behavior when passing a type:
>>> pprint(component.getSpecificationInfoDictionary(tupleSpec))
{'isInterface': False,
'isType': True,
'module': '...builtin...',
'module': '__builtin__',
'name': 'tuple',
'url': '...builtin.../tuple'}
'url': '__builtin__/tuple'}

For the type, we simply reuse the type info dictionary function.

Expand Down
4 changes: 2 additions & 2 deletions src/zope/app/apidoc/interface.rst
Expand Up @@ -103,7 +103,7 @@ ignores methods and fields.

>>> attrs = interface.getAttributes(IFoo)
>>> attrs.sort()
>>> attrs #doctest: +ELLIPSIS
>>> attrs
[('baz', <zope.interface.interface.Attribute object at ...>)]


Expand All @@ -114,7 +114,7 @@ This function returns a (name, method) tuple for every declared method in the
interface.

>>> methods = sorted(interface.getMethods(IFoo))
>>> methods #doctest: +ELLIPSIS
>>> methods
[('blah', <zope.interface.interface.Method object at ...>)]


Expand Down
4 changes: 2 additions & 2 deletions src/zope/app/apidoc/presentation.rst
Expand Up @@ -266,7 +266,7 @@ should be returned:

>>> regs = list(presentation.getViews(IFoo))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
>>> regs
[AdapterRegistration(<BaseGlobalComponents base>,
[IFoo, IBrowserRequest], Interface, 'blah', None, u''),
AdapterRegistration(<BaseGlobalComponents base>,
Expand All @@ -276,7 +276,7 @@ should be returned:

>>> regs = list(presentation.getViews(Interface, IHTTPRequest))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
>>> regs
[AdapterRegistration(<BaseGlobalComponents base>,
[Interface, IHTTPRequest], Interface, 'bar', None, u'')]

Expand Down
6 changes: 6 additions & 0 deletions src/zope/app/apidoc/tests.py
Expand Up @@ -154,6 +154,12 @@ def rootLocation(obj, name):
(re.compile(r"u('[^']*')"), r"\1"),
(re.compile(r"b('[^']*')"), r"\1"),
(re.compile("__builtin__"), 'builtins'),
# repr of old style class is different on py2
(re.compile("<class zope.app.apidoc.doctest.B.*>"),
"<class 'zope.app.apidoc.doctest.B'>"),
# there are no unbound methods on python 3
(re.compile("<unbound method ([^>]*)>"),
r"<function \1 at 0xabc>")
)

def standard_checker(*extra_patterns):
Expand Down
2 changes: 1 addition & 1 deletion src/zope/app/apidoc/typemodule/type.py
Expand Up @@ -49,7 +49,7 @@ class TypeInterface(ReadContainerBase):
>>> typeiface.get('Foo').__class__ == Foo
True
>>> typeiface.items() #doctest:+ELLIPSIS
>>> typeiface.items()
[(u'Foo', <zope.app.apidoc.typemodule.type.Foo object at ...>)]
"""
Expand Down
4 changes: 2 additions & 2 deletions src/zope/app/apidoc/zcmlmodule/browser.rst
Expand Up @@ -102,7 +102,7 @@ Returns the interface details class for the schema.

>>> iface_details = details.getSchema()

>>> iface_details #doctest:+ELLIPSIS
>>> iface_details
<zope.app.apidoc.ifacemodule.browser.InterfaceDetails object at ...>

>>> iface_details.context
Expand Down Expand Up @@ -208,7 +208,7 @@ but if we add one

the result becomes more interesting:

>>> pprint(details.getSubdirectives(), width=1) #doctest:+ELLIPSIS
>>> pprint(details.getSubdirectives(), width=1)
[{'handler': {'path': 'None.handler', 'url': None},
'info': 'info',
'name': 'foo',
Expand Down

0 comments on commit 87dc2e9

Please sign in to comment.