Package doconce :: Module common
[hide private]
[frames] | no frames]

Module common

source code

This module contains data structures used in translation of the Doconce format to other formats. Some convenience functions used in translation modules (latex.py, html.py, etc.) are also included in here.

Functions [hide private]
 
where()
Return the location where the doconce package is installed.
source code
 
indent_lines(text, format, indentation=' ')
Indent each line in the string text, provided in a format for HTML, LaTeX, epytext, ..., by the blank string indentation.
source code
 
table_analysis(table)
Return max width of each column.
source code
 
ref2equations(filestr)
Replace references to equations: (ref{my:label}) -> Equation (my:label) (ref{my:label1})-(ref{my:label2}) -> Equations (my:label1)-(my:label2) (ref{my:label1}) and (ref{my:label2}) -> Equations (my:label1) and (my:label2) (ref{my:label1}), (ref{my:label2}) and (ref{my:label3}) -> Equations (my:label1), (my:label2) and (ref{my:label2})
source code
 
default_movie(m)
Replace a movie entry by a proper URL with text.
source code
 
remove_code_and_tex(filestr)
Remove verbatim and latex (math) code blocks from the file and store separately in lists (code_blocks and tex_blocks).
source code
 
insert_code_and_tex(filestr, code_blocks, tex_blocks, format) source code
 
plain_exercise(exer) source code
Variables [hide private]
  _CODE_BLOCK = '<<<!!CODE_BLOCK'
  _MATH_BLOCK = '<<<!!MATH_BLOCK'
  BLANKLINE = {'cwiki': '\n', 'epytext': '\n', 'gwiki': '\n', 'h...
  FILENAME_EXTENSION = {'cwiki': '.cwiki', 'epytext': '.epytext'...
  LIST = {'cwiki': {'description': {'begin': '\n', 'end': '\n\n'...
  CODE = {}
  ARGLIST = {'cwiki': {'class variable': '*class variable*', 'in...
  DEFAULT_ARGLIST = {'class variable': 'class variable', 'instan...
  TABLE = {}
  FIGURE_EXT = {'cwiki': ('.png', '.gif', '.jpg', '.jpeg'), 'gwi...
  CROSS_REFS = {}
  INDEX_BIB = {}
  INTRO = {'cwiki': '', 'gwiki': '', 'html': '<?xml version="1.0...
  OUTRO = {'html': '\n</body>\n</html>\n ', 'latex': '\n\n\\p...
  EXERCISE = {}
  inline_tag_begin = '(?P<begin>(^|[(\\s]))'
  inline_tag_end = '(?P<end>($|[.,?!;:)\\s]))'
  inline_tag_before = '(?<=^(|[(\\s])))'
  inline_tag_after = '(?=($|[.,?!;:)\\s]))'
  _linked_files = '\\s*"(?P<url>([^"]+?\\.html?|[^"]+?\\.txt|[^"...
  INLINE_TAGS = {'abstract': '^\\s*__(?P<type>Abstract|Summary)....
  INLINE_TAGS_SUBST = {'cwiki': {'abstract': '\\n//\\g<type>.// ...
  heading_error = ('(^ [_=]+[^_=]*|^[_=]+[^ _=]*$)', 'Initial sp...
  INLINE_TAGS_BUGS = {'bold': ('(?P<begin>(^|[(\\s]))(?P<subst>_...
  LIST_SYMBOL = {'*': 'itemize', '-': 'description', 'o': 'enume...
  __package__ = 'doconce'
Function Details [hide private]

indent_lines(text, format, indentation=' ')

source code 

Indent each line in the string text, provided in a format for HTML, LaTeX, epytext, ..., by the blank string indentation. Return new version of text.

remove_code_and_tex(filestr)

source code 

Remove verbatim and latex (math) code blocks from the file and store separately in lists (code_blocks and tex_blocks). The function insert_code_and_tex will insert these blocks again.


Variables Details [hide private]

BLANKLINE

Value:
{'cwiki': '''
''',
 'epytext': '''
''',
 'gwiki': '''
''',
 'html': '''
<P>
...

FILENAME_EXTENSION

Value:
{'cwiki': '.cwiki',
 'epytext': '.epytext',
 'gwiki': '.gwiki',
 'html': '.html',
 'latex': '.p.tex',
 'mwiki': '.mwiki',
 'pandoc': '.mkd',
 'pdflatex': '.p.tex',
...

LIST

Value:
{'cwiki': {'description': {'begin': '''
''',
                           'end': '''

''',
                           'item': '* %s '},
           'enumerate': {'begin': '\n', 'end': '\n\n', 'item': '#'},
           'itemize': {'begin': '\n', 'end': '\n\n', 'item': '*'},
...

ARGLIST

Value:
{'cwiki': {'class variable': '*class variable*',
           'instance variable': '*instance variable*',
           'keyword': '*keyword argument*',
           'module variable': '*module variable*',
           'parameter': '*argument*',
           'return': '*return value(s)*'},
 'epytext': {'class variable': '@cvar',
             'instance variable': '@ivar',
...

DEFAULT_ARGLIST

Value:
{'class variable': 'class variable',
 'instance variable': 'instance variable',
 'keyword': 'keyword argument',
 'module variable': 'module variable',
 'parameter': 'argument',
 'return': 'return value(s)'}

FIGURE_EXT

Value:
{'cwiki': ('.png', '.gif', '.jpg', '.jpeg'),
 'gwiki': ('.png', '.gif', '.jpg', '.jpeg'),
 'html': ('.png', '.gif', '.jpg', '.jpeg'),
 'latex': ('.eps', '.ps'),
 'mwiki': ('.png', '.gif', '.jpg', '.jpeg'),
 'pdflatex': ('.jpg', '.jpeg', '.png', '.pdf'),
 'rst': ('.png', '.gif', '.jpg', '.jpeg', '.eps', '.ps'),
 'sphinx': ('.png', '.gif', '.jpg', '.jpeg')}

INTRO

Value:
{'cwiki': '',
 'gwiki': '',
 'html': '''<?xml version="1.0" encoding="utf-8" ?>
<!--
Automatically generated HTML file from Doconce source
(http://code.google.com/p/doconce/)
-->

...

OUTRO

Value:
{'html': '''
</body>
</html>
    ''',
 'latex': '''

\\printindex

...

_linked_files

Value:
'\\s*"(?P<url>([^"]+?\\.html?|[^"]+?\\.txt|[^"]+?\\.pdf|[^"]+?\\.f|[^"\
]+?\\.c|[^"]+?\\.cpp|[^"]+?\\.cxx|[^"]+?\\.py|[^"]+?\\.java|[^"]+?\\.p\
l|[^"]+?\\.sh|[^"]+?\\.csh|[^"]+?\\.zsh|[^"]+?\\.ksh|[^"]+?\\.tar\\.gz\
|[^"]+?\\.tar|[^"]+?\\.f77|[^"]+?\\.f90|[^"]+?\\.f95))"'

INLINE_TAGS

Value:
{'abstract': '^\\s*__(?P<type>Abstract|Summary).__\\s*(?P<text>.+?)(?P\
<rest>\\s*[_=]{3,9})',
 'author': '^AUTHOR:\\s*(?P<name>.+?)(,|\\s+at\\s+)(?P<institution>.+)\
\\s*$',
 'bold': '(?P<begin>(^|[(\\s]))_(?P<subst>[^ `][^\\]_`]*)_(?P<end>($|[\
.,?!;:)\\s]))',
 'chapter': '^\\s*[_=]{9}\\s*(?P<subst>[^ =-].+?)\\s*[_=]+\\s*$',
 'citation': ' cite\\{(?P<subst>[^}]+)\\}',
...

INLINE_TAGS_SUBST

Value:
{'cwiki': {'abstract': '\\n//\\g<type>.// \\g<text>\\g<rest>',
           'author': <function cwiki_author at 0x1bec848>,
           'bold': '\\g<begin>**\\g<subst>**\\g<end>',
           'chapter': '''


= \\g<subst> =\\n''',
           'comment': '<wiki:comment> %s </wiki:comment>',
...

heading_error

Value:
('(^ [_=]+[^_=]*|^[_=]+[^ _=]*$)',
 'Initial spaces or missing underscore(s) or = at the end')

INLINE_TAGS_BUGS

Value:
{'bold': ('(?P<begin>(^|[(\\s]))(?P<subst>_ [^_]*_)(?P<end>($|[.,?!;:)\
\\s]))',
          'Space after first _ in inline boldface expressions'),
 'emphasize': None,
 'math': ('(?P<begin>(^|[(\\s]))(?P<subst>\\$ [^$]*\\$)(?P<end>($|[.,?\
!;:)\\s]))',
          'Space after first $ in inline math expressions'),
 'paragraph': ('(^ [_=]+[^_=]*|^[_=]+[^ _=]*$)', 'Initial spaces or mi\
...

LIST_SYMBOL

Value:
{'*': 'itemize', '-': 'description', 'o': 'enumerate'}