Skip to content

Commit

Permalink
Unify docs for docutils.rst/py back into .py
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 27, 2018
1 parent e93f66b commit de407e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
29 changes: 4 additions & 25 deletions docs/api/docutils.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
:mod:`zope.configuration.docutils`
==================================
=============================
zope.configuration.docutils
=============================

.. module:: zope.configuration.docutils

.. autofunction:: wrap

Examples:

.. doctest::

>>> from zope.configuration.docutils import wrap
>>> print(wrap('foo bar')[:-2])
foo bar
>>> print(wrap('foo bar', indent=2)[:-2])
foo bar
>>> print(wrap('foo bar, more foo bar', 10)[:-2])
foo bar,
more foo
bar
>>> print(wrap('foo bar, more foo bar', 10, 2)[:-2])
foo bar,
more foo
bar

.. autofunction:: makeDocStructures
.. automodule:: zope.configuration.docutils
34 changes: 27 additions & 7 deletions src/zope/configuration/docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,24 @@
whitespace = re.compile('[ \t\n\r]+')

def wrap(text, width=78, indent=0):
"""Makes sure that we keep a line length of a certain width.
"""
Makes sure that we keep a line length of a certain width.
Examples:
>>> from zope.configuration.docutils import wrap
>>> print(wrap('foo bar')[:-2])
foo bar
>>> print(wrap('foo bar', indent=2)[:-2])
foo bar
>>> print(wrap('foo bar, more foo bar', 10)[:-2])
foo bar,
more foo
bar
>>> print(wrap('foo bar, more foo bar', 10, 2)[:-2])
foo bar,
more foo
bar
"""
paras = para_sep.split(text.strip())

Expand Down Expand Up @@ -54,15 +71,18 @@ def wrap(text, width=78, indent=0):


def makeDocStructures(context):
"""Creates two structures that provide a friendly format for
"""
makeDocStructures(context) -> namespaces, subdirs
Creates two structures that provide a friendly format for
documentation.
'namespaces' is a dictionary that maps namespaces to a directives
dictionary with the key being the name of the directive and the value is a
tuple: (schema, handler, info).
*namespaces* is a dictionary that maps namespaces to a directives
dictionary with the key being the name of the directive and the
value is a tuple: (schema, handler, info).
'subdirs' maps a (namespace, name) pair to a list of subdirectives that
have the form (namespace, name, schema, info).
*subdirs* maps a (namespace, name) pair to a list of subdirectives
that have the form (namespace, name, schema, info).
"""
namespaces = {}
subdirs = {}
Expand Down

0 comments on commit de407e5

Please sign in to comment.