[Epydoc-commits] SF.net SVN: epydoc: [1674] trunk/epydoc/src/epydoc
Brought to you by:
edloper
|
From: <ed...@us...> - 2008-01-29 06:03:38
|
Revision: 1674
http://epydoc.svn.sourceforge.net/epydoc/?rev=1674&view=rev
Author: edloper
Date: 2008-01-28 22:03:36 -0800 (Mon, 28 Jan 2008)
Log Message:
-----------
- Applied sourceforge patch #1678242 -- added command-line option
'-src-code-tab-width'.
Modified Paths:
--------------
trunk/epydoc/src/epydoc/cli.py
trunk/epydoc/src/epydoc/docwriter/html.py
trunk/epydoc/src/epydoc/docwriter/html_colorize.py
Modified: trunk/epydoc/src/epydoc/cli.py
===================================================================
--- trunk/epydoc/src/epydoc/cli.py 2008-01-29 05:42:58 UTC (rev 1673)
+++ trunk/epydoc/src/epydoc/cli.py 2008-01-29 06:03:36 UTC (rev 1674)
@@ -136,8 +136,8 @@
list_classes_separately=False, graph_font=None, graph_font_size=None,
include_source_code=True, pstat_files=[], simple_term=False, fail_on=None,
exclude=[], exclude_parse=[], exclude_introspect=[],
- external_api=[],external_api_file=[],external_api_root=[],
- redundant_details=False)
+ external_api=[], external_api_file=[], external_api_root=[],
+ redundant_details=False, src_code_tab_width=8)
def parse_arguments():
# Construct the option parser.
@@ -338,6 +338,11 @@
"its own section, instead of listing them under their "
"containing module."))
+ output_group.add_option('--src-code-tab-width',
+ action='store', type='int', dest='src_code_tab_width',
+ help=("When generating HTML output, sets the number of spaces "
+ "each tab in source code listings is replaced with."))
+
# The group of external API options.
# Skip if the module couldn't be imported (usually missing docutils)
if xlink is not None:
@@ -573,6 +578,8 @@
options.show_frames = _str_to_bool(val, optname)
elif optname in ('separate-classes', 'separate_classes'):
options.list_classes_separately = _str_to_bool(val, optname)
+ elif optname in ('src-code-tab-width', 'src_code_tab_width'):
+ options.src_code_tab_width = _str_to_int(val, optname)
# External API
elif optname in ('external-api', 'external_api'):
Modified: trunk/epydoc/src/epydoc/docwriter/html.py
===================================================================
--- trunk/epydoc/src/epydoc/docwriter/html.py 2008-01-29 05:42:58 UTC (rev 1673)
+++ trunk/epydoc/src/epydoc/docwriter/html.py 2008-01-29 06:03:36 UTC (rev 1674)
@@ -291,6 +291,9 @@
@type include_log: C{boolean}
@keyword include_log: If true, the the footer will include an
href to the page 'epydoc-log.html'.
+ @type src_code_tab_width: C{int}
+ @keyword src_code_tab_width: Number of spaces to replace each tab
+ with in source code listings.
"""
self.docindex = docindex
@@ -354,6 +357,10 @@
self._include_log = kwargs.get('include_log', False)
"""Are we generating an HTML log page?"""
+
+ self._src_code_tab_width = kwargs.get('src_code_tab_width', 8)
+ """Number of spaces to replace each tab with in source code
+ listings."""
self._callgraph_cache = {}
"""Map the callgraph L{uid<DotGraph.uid>} to their HTML
@@ -797,7 +804,8 @@
self.href(doc, label='%s %s' % (self.doc_kind(doc), name)))
out('<pre class="py-src">\n')
out(PythonSourceColorizer(filename, name, self.docindex,
- self.url, name_to_docs).colorize())
+ self.url, name_to_docs,
+ self._src_code_tab_width).colorize())
out('</pre>\n<br />\n')
# Footer
Modified: trunk/epydoc/src/epydoc/docwriter/html_colorize.py
===================================================================
--- trunk/epydoc/src/epydoc/docwriter/html_colorize.py 2008-01-29 05:42:58 UTC (rev 1673)
+++ trunk/epydoc/src/epydoc/docwriter/html_colorize.py 2008-01-29 06:03:36 UTC (rev 1674)
@@ -324,7 +324,8 @@
GUESS_LINK_TARGETS = False
def __init__(self, module_filename, module_name,
- docindex=None, url_func=None, name_to_docs=None):
+ docindex=None, url_func=None, name_to_docs=None,
+ tab_width=8):
"""
Create a new HTML colorizer for the specified module.
@@ -406,6 +407,9 @@
#: Can be C{'func'}, C{'class'}, C{None}.
self.def_type = None
+ #: The number of spaces to replace each tab in source code with
+ self.tab_width = tab_width
+
def find_line_offsets(self):
"""
@@ -450,7 +454,7 @@
# Load the module's text.
self.text = open(self.module_filename).read()
- self.text = self.text.expandtabs().rstrip()+'\n'
+ self.text = self.text.expandtabs(self.tab_width).rstrip()+'\n'
# Construct the line_offsets table.
self.find_line_offsets()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|