summaryrefslogtreecommitdiff
path: root/numpy/doc/constants.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-10-11 10:33:17 +0000
committerPauli Virtanen <pav@iki.fi>2009-10-11 10:33:17 +0000
commit295e24af415bb49f12a632f0e27fb9e2a1099ea2 (patch)
tree4db90d03e5a98bcebd62cb5b42a15afc8e2ef22e /numpy/doc/constants.py
parent72c9eea9e58f9b57f97a32a3ab9e3ca9b25dd736 (diff)
downloadnumpy-295e24af415bb49f12a632f0e27fb9e2a1099ea2.tar.gz
doc.constants: work around some Sphinx formatting issues
Diffstat (limited to 'numpy/doc/constants.py')
-rw-r--r--numpy/doc/constants.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/numpy/doc/constants.py b/numpy/doc/constants.py
index 7a9105667..2e30374fb 100644
--- a/numpy/doc/constants.py
+++ b/numpy/doc/constants.py
@@ -7,7 +7,10 @@ Numpy includes several constants:
%(constant_list)s
"""
-import textwrap
+#
+# Note: the docstring is autogenerated.
+#
+import textwrap, re
# Maintain same format as in numpy.add_newdocs
constants = []
@@ -362,8 +365,23 @@ if __doc__:
constants_str = []
constants.sort()
for name, doc in constants:
- constants_str.append(""".. const:: %s\n %s""" % (
- name, textwrap.dedent(doc).replace("\n", "\n ")))
+ s = textwrap.dedent(doc).replace("\n", "\n ")
+
+ # Replace sections by rubrics
+ lines = s.split("\n")
+ new_lines = []
+ for line in lines:
+ m = re.match(r'^(\s+)[-=]+\s*$', line)
+ if m and new_lines:
+ prev = textwrap.dedent(new_lines.pop())
+ new_lines.append('%s.. rubric:: %s' % (m.group(1), prev))
+ new_lines.append('')
+ else:
+ new_lines.append(line)
+ s = "\n".join(new_lines)
+
+ # Done.
+ constants_str.append(""".. const:: %s\n %s""" % (name, s))
constants_str = "\n".join(constants_str)
__doc__ = __doc__ % dict(constant_list=constants_str)