Package mvpa :: Package base :: Module dochelpers
[hide private]
[frames] | no frames]

Module dochelpers

source code

Various helpers to improve docstrings and textual output
Functions [hide private]
 
_rst(s, snotrst='')
Produce s only in __rst mode
source code
 
rstUnderline(text, markup)
Add and underline RsT string matching the length of the given string.
source code
 
singleOrPlural(single, plural, n)
Little helper to spit out single or plural version of a word.
source code
 
handleDocString(text, polite=True)
Take care of empty and non existing doc strings.
source code
 
_indent(text, istr=' ')
Simple indenter
source code
 
_splitOutParametersStr(initdoc)
Split documentation into (header, parameters, suffix)
source code
 
_parseParameters(paramdoc)
Parse parameters and return list of (name, full_doc_string)
source code
 
enhancedDocString(item, *args, **kwargs)
Generate enhanced doc strings for various items.
source code
 
table2string(table, out=None)
Given list of lists figure out their common widths and print to out
source code
Variables [hide private]
  __in_ipython = externals.exists('running ipython env')
  __add_init2doc = True
  __rst_mode = 1
  _rst_sep = "`"
  _rst_sep2 = ":"
  __parameters_str_re = re.compile("[\n^]\s*:?Parameters?:?\s*\n")
regexp to match :Parameter: and :Parameters: stand alone in a line
  __re_params = re.compile('(?:\n\S.*?)+$')
  __re_spliter1 = re.compile('(?:\n|\A)(?=\S)')
  __re_spliter2 = re.compile('[\n:]')

Imports: re, textwrap, N, ceil, StringIO, cfg, externals, debug, Release


Function Details [hide private]

_splitOutParametersStr(initdoc)

source code 
Split documentation into (header, parameters, suffix)
Parameters:
  • initdoc (string) - The documentation string

_parseParameters(paramdoc)

source code 

Parse parameters and return list of (name, full_doc_string)

It is needed to remove multiple entries for the same parameter like it could be with adding parameters from the parent class

It assumes that previousely parameters were unwrapped, so their documentation starts at the begining of the string, like what should it be after _splitOutParametersStr

enhancedDocString(item, *args, **kwargs)

source code 

Generate enhanced doc strings for various items.

It is to be used from a collector, ie whenever class is already created

Parameters:

item : basestring or class
What object requires enhancing of documentation
*args : list
Includes base classes to look for parameters, as well, first item must be a dictionary of locals if item is given by a string
force_extend : bool
Either to force looking for the documentation in the parents. By default force_extend = False, and lookup happens only if kwargs is one of the arguments to the respective function (e.g. item.__init__)
skip_params : list of basestring
List of parameters (in addition to [kwargs]) which should not be added to the documentation of the class.

table2string(table, out=None)

source code 
Given list of lists figure out their common widths and print to out
Parameters:
  • table (list of lists of strings) - What is aimed to be printed
  • out (None or stream) - Where to print. If None -- will print and return string
Returns:
string if out was None