Doug Hellmann avatar Doug Hellmann committed 1574d3a Merge

merge heads after paverutils change

Comments (0)

Files changed (4)

 a4498fcaf56502fbdfef12a41f7bb93cefbbdeb3 ansi-0.5
 9ccb32d8f5ea45d3366c43a176fde120da1031e9 ansi-0.5.1
 c6403ab574b2afc7fef732739903349afe0144dc doxylink-0.2
+8348f54ac9d71b42f3067f507c72a698df985011 bitbucket-1.0

paverutils/README

 sphinxcontrib.paverutils
 ########################
 
-This module provides an alternative integration of Sphinx and Paver_. It supports calling
-Sphinx from within Paver using multiple configurations, and does not assume you only want
-to build HTML output.
+This module provides an alternative integration of Sphinx and
+Paver_. It supports calling Sphinx from within Paver using multiple
+configurations, and does not assume you only want to build HTML
+output.
 
 Basic Usage
 ===========
 
-To use this module, import it in your pavement.py file as ``from sphinxcontrib import
-paverutils``, then define option Bundles for "html" and/or "pdf" output using the options
-described in the task help.
+To use this module, import it in your pavement.py file as ``from
+sphinxcontrib import paverutils``, then define option Bundles for
+"html" and/or "pdf" output using the options described in the task
+help.
 
 For example::
 
 Tasks
 =====
 
-After you have imported ``sphinxcontrib.paverutils`` in your ``pavement.py`` file, Paver will show two additional tasks.  ``html`` takes the place of the task defined in ``paver.doctools`` and can be used to build HTML output.  ``pdf`` uses the LaTeX builder and an external toolset such as TeXLive_ to create a PDF manual.
+After you have imported ``sphinxcontrib.paverutils`` in your
+``pavement.py`` file, Paver will show two additional tasks.  ``html``
+takes the place of the task defined in ``paver.doctools`` and can be
+used to build HTML output.  ``pdf`` uses the LaTeX builder and an
+external toolset such as TeXLive_ to create a PDF manual.
 
 Configuration Parameters
 ========================
   default: ``html``
 
 template_args
-  dictionary of values to be passed as name-value pairs to the HTML builder
+  dictionary of values to be passed as name-value pairs to the HTML
+  builder
 
   default: ``{}``
 
 
     .. {{{end}}}
 
-The lines prefixed with ``..`` are comments, and do not appear in the final HTML or PDF output.
+The lines prefixed with ``..`` are comments, and do not appear in the
+final HTML or PDF output.
 
 Arguments:
 
   If False, the output is passed to rstrip() then one newline is added.  If
   True, newlines are added to the output until it ends in 2.
 
-
+break_lines_at=0
+  Integer indicating the length where lines should be broken and
+  continued on the next line.  Defaults to 0, meaning no special
+  handling should be done.
 
 
 .. note::
 =====
 
 PyMOTW_
-    The Python Module of the Week package is built using Paver and Sphinx, including three forms of HTML and a PDF.
+    The Python Module of the Week package is built using Paver and
+    Sphinx, including three forms of HTML and a PDF.
 
 virtualenvwrapper_
-    The documentation for virtualenvwrapper includes the packaged HTML and a website using alternate templates.
+    The documentation for virtualenvwrapper includes the packaged HTML
+    and a website using alternate templates.
 
 .. _Paver: http://www.blueskyonmars.com/projects/paver/
 
 History
 =======
 
+1.3
+---
+
+Added simple line-splitting to ``run_script()``.
+
 1.2
 ---
 
 1.0
 ---
 
-First public release based on the versions of these functions developed for PyMOTW_.
+First public release based on the versions of these functions
+developed for PyMOTW_.

paverutils/setup.py

 requires = ['Sphinx>=0.6', 'Paver>=1.0.1']
 
 NAME='sphinxcontrib-paverutils'
-VERSION='1.2'
+VERSION='1.3'
 
 setup(
     name=NAME,

paverutils/sphinxcontrib/paverutils.py

 
 
 def run_script(input_file, script_name, 
-                interpreter='python',
-                include_prefix=True, 
-                ignore_error=False, 
-                trailing_newlines=True,
-                ):
+               interpreter='python',
+               include_prefix=True, 
+               ignore_error=False, 
+               trailing_newlines=True,
+               break_lines_at=0,
+               ):
     """Run a script in the context of the input_file's directory, 
     return the text output formatted to be included as an rst
     literal text block.
        Boolean controlling whether the trailing newlines are added to the output.
        If False, the output is passed to rstrip() then one newline is added.  If
        True, newlines are added to the output until it ends in 2.
+
+     break_lines_at=0
+       Integer indicating the length where lines should be broken and
+       continued on the next line.  Defaults to 0, meaning no special
+       handling should be done.
+       
     """
     rundir = path(input_file).dirname()
     if interpreter:
     else:
         response = ''
     response += '\t$ %(cmd)s\n\t' % vars()
-    response += '\n\t'.join(output_text.splitlines())
+    lines = output_text.splitlines()
+
+    # Deal with lines that might be too long
+    if break_lines_at:
+        broken_lines = []
+        for l in lines:
+            while l:
+                part, l = l[:break_lines_at], l[break_lines_at:]
+                broken_lines.append(part)
+        lines = broken_lines
+                
+    response += '\n\t'.join(lines)
     if trailing_newlines:
         while not response.endswith('\n\n'):
             response += '\n'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.