[Python-checkins] r64844 - in doctools/trunk: CHANGES sphinx/builder.py sphinx/ext/autodoc.py sphinx/htmlwriter.py

armin.ronacher python-checkins at python.org
Thu Jul 10 15:59:59 CEST 2008


Author: armin.ronacher
Date: Thu Jul 10 15:59:59 2008
New Revision: 64844
Log:
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.
Modified:
 doctools/trunk/CHANGES
 doctools/trunk/sphinx/builder.py
 doctools/trunk/sphinx/ext/autodoc.py
 doctools/trunk/sphinx/htmlwriter.py
Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Thu Jul 10 15:59:59 2008
@@ -15,6 +15,10 @@
 * 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)
 ===========================
Modified: doctools/trunk/sphinx/builder.py
==============================================================================
--- doctools/trunk/sphinx/builder.py	(original)
+++ doctools/trunk/sphinx/builder.py	Thu Jul 10 15:59:59 2008
@@ -301,6 +301,8 @@
 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."""
@@ -810,6 +812,10 @@
 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
Modified: doctools/trunk/sphinx/ext/autodoc.py
==============================================================================
--- doctools/trunk/sphinx/ext/autodoc.py	(original)
+++ doctools/trunk/sphinx/ext/autodoc.py	Thu Jul 10 15:59:59 2008
@@ -12,6 +12,7 @@
 """
 
 import re
+import sys
 import types
 import inspect
 import textwrap
@@ -158,17 +159,25 @@
 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):
@@ -441,8 +450,8 @@
 # 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:
Modified: doctools/trunk/sphinx/htmlwriter.py
==============================================================================
--- doctools/trunk/sphinx/htmlwriter.py	(original)
+++ doctools/trunk/sphinx/htmlwriter.py	Thu Jul 10 15:59:59 2008
@@ -71,7 +71,7 @@
 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')
@@ -342,7 +342,7 @@
 
 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']:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /