1. Georg Brandl
  2. sphinx

Commits

armin.ronacher  committed 267ccbd

Fixed docstring dedenting and made the html writer more configurable in the sense that it doesn't change behavior based on the builder name any longer.

  • Participants
  • Parent commits 93def76
  • Branches default

Comments (0)

Files changed (4)

File CHANGES

View file
 * The `automodule` directive now supports the ``synopsis``,
   ``deprecated`` and ``platform`` options.
 
+* The HTML builders have two additional attributes now that can be used
+  to disable the anchor-link creation after headlines and definition
+  links.  EXPERIMENTAL
+
 
 Release 0.4.1 (Jul 5, 2008)
 ===========================

File sphinx/builder.py

View file
     supported_image_types = ['image/svg+xml', 'image/png', 'image/gif',
                              'image/jpeg']
     searchindex_filename = 'searchindex.json'
+    add_header_links = True
+    add_definition_links = True
 
     def init(self):
         """Load templates."""
     copysource = False
     supported_image_types = ['image/png', 'image/gif', 'image/jpeg']
 
+    # don't add links
+    add_header_links = False
+    add_definition_links = False
+
     def init(self):
         StandaloneHTMLBuilder.init(self)
         # the output files for HTML help must be .html only

File sphinx/ext/autodoc.py

View file
 """
 
 import re
+import sys
 import types
 import inspect
 import textwrap
     of nested_parse().)  An empty line is added to act as a separator between
     this docstring and following content.
     """
-    if not s or s.isspace():
-        return ['']
-    s = s.expandtabs()
-    nl = s.rstrip().find('\n')
-    if nl == -1:
-        # Only one line...
-        return [s.strip(), '']
-    # The first line may be indented differently...
-    firstline = s[:nl].strip()
-    otherlines = textwrap.dedent(s[nl+1:])
-    return [firstline] + otherlines.splitlines() + ['']
+    lines = s.expandtabs().splitlines()
+    # Find minimum indentation of any non-blank lines after first line.
+    margin = sys.maxint
+    for line in lines[1:]:
+        content = len(line.lstrip())
+        if content:
+            indent = len(line) - content
+            margin = min(margin, indent)
+    # Remove indentation.
+    if lines:
+        lines[0] = lines[0].lstrip()
+    if margin < sys.maxint:
+        for i in range(1, len(lines)): lines[i] = lines[i][margin:]
+    # Remove any trailing or leading blank lines.
+    while lines and not lines[-1]:
+        lines.pop()
+    while lines and not lines[0]:
+        lines.pop(0)
+    return lines
 
 
 def get_module_charset(module):
         # unqualified :members: given
         if what == 'module':
             # for implicit module members, check __module__ to avoid documenting
-            # imported objects
-            members_check_module = True
+            # imported objects if __all__ is not defined
+            members_check_module = not hasattr(todoc, '__all__')
             all_members = inspect.getmembers(todoc)
         else:
             if options.inherited_members:

File sphinx/htmlwriter.py

View file
         if node.parent['desctype'] in ('class', 'exception'):
             self.body.append('%s ' % node.parent['desctype'])
     def depart_desc_signature(self, node):
-        if node['ids'] and self.builder.name != 'htmlhelp':
+        if node['ids'] and self.builder.add_definition_links:
             self.body.append(u'<a class="headerlink" href="#%s" ' % node['ids'][0] +
                              u'title="Permalink to this definition">\u00B6</a>')
         self.body.append('</dt>\n')
 
     def depart_title(self, node):
         close_tag = self.context[-1]
-        if self.builder.name != 'htmlhelp' and \
+        if self.builder.add_header_links and \
                (close_tag.startswith('</h') or
                 close_tag.startswith('</a></h')) and \
                node.parent.hasattr('ids') and node.parent['ids']: