Ñò
¢ÔëJc @ sÛ d Z d d k Z d d k Z d d k Z d Z d Z d d „ Z d e f d „ ƒ YZ d e
f d „ ƒ YZ d
e
f d „ ƒ YZ d e
f d
„ ƒ YZ
e d j o0 d d k Z e i e i Z e i d e ƒ n d S( sn
asciidocapi - AsciiDoc API wrapper class.
The AsciiDocAPI class provides an API for executing asciidoc. Minimal example
compiles `mydoc.txt` to `mydoc.html`:
import asciidocapi
asciidoc = asciidocapi.AsciiDocAPI()
asciidoc.execute('mydoc.txt')
- Full documentation in asciidocapi.txt.
- See the doctests below for more examples.
Doctests:
1. Check execution:
>>> import StringIO
>>> infile = StringIO.StringIO('Hello *{author}*')
>>> outfile = StringIO.StringIO()
>>> asciidoc = AsciiDocAPI()
>>> asciidoc.options('--no-header-footer')
>>> asciidoc.attributes['author'] = 'Joe Bloggs'
>>> asciidoc.execute(infile, outfile, backend='html4')
>>> print outfile.getvalue()
Hello Joe Bloggs
>>> asciidoc.attributes['author'] = 'Bill Smith'
>>> infile = StringIO.StringIO('Hello _{author}_')
>>> outfile = StringIO.StringIO()
>>> asciidoc.execute(infile, outfile, backend='docbook')
>>> print outfile.getvalue()
Hello Bill Smith
2. Check error handling:
>>> import StringIO
>>> asciidoc = AsciiDocAPI()
>>> infile = StringIO.StringIO('---------')
>>> outfile = StringIO.StringIO()
>>> asciidoc.execute(infile, outfile)
Traceback (most recent call last):
File "", line 1, in
File "asciidocapi.py", line 189, in execute
raise AsciiDocError(self.messages[-1])
AsciiDocError: ERROR: : line 1: [blockdef-listing] missing closing delimiter
Copyright (C) 2009 Stuart Rackham. Free use of this software is granted
under the terms of the GNU General Public License (GPL).
iÿÿÿÿNs 0.1.1s 8.4.1c C sx | d j o t i i d d ƒ } n xK | i t i ƒ D]3 } t i i | | ƒ } t i i | ƒ o | Sq9 Wd Sd S( s=
Find file fname in paths. Return None if not found.
t PATHt N( t Nonet ost environt gett splitt pathsept patht joint isfile( t fnameR t dirt fpath( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt find_in_path= s
t
AsciiDocErrorc B s e Z RS( ( t __name__t
__module__( ( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR K s t Optionsc B s2 e Z d Z g d „ Z d d „ Z d d „ Z RS( s-
Stores asciidoc(1) command options.
c C s | | _ d S( N( t values( t selfR ( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt __init__S s c C s | i | | ƒ d S( s Shortcut for append method.N( t append( R t namet value( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt __call__U s c C sC t | ƒ t t f j o t | ƒ } n | i i | | f ƒ d S( N( t typet intt floatt strR R ( R R R ( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR X s N( R R t __doc__R R R R ( ( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR O s t Versionc B s e Z d Z d „ Z d „ Z RS( s÷
Parse and compare AsciiDoc version numbers. Instance attributes:
string: String version number '.[.][suffix]'.
major: Integer major version number.
minor: Integer minor version number.
micro: Integer micro version number.
suffix: Suffix (begins with non-numeric character) is ignored when
comparing.
Doctest examples:
>>> Version('8.2.5') < Version('8.3 beta 1')
True
>>> Version('8.3.0') == Version('8.3. beta 1')
True
>>> Version('8.2.0') < Version('8.20')
True
>>> Version('8.20').major
8
>>> Version('8.20').minor
20
>>> Version('8.20').micro
0
>>> Version('8.20').suffix
''
>>> Version('8.20 beta 1').suffix
'beta 1'
c C s | | _ t i d | i ƒ } | p t d | i ƒ ‚ n | i ƒ } t | d ƒ | _ t | d ƒ | _ t | d p d ƒ | _ | d p d | _ d S( Ns# ^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$s invalid version number: %si i i t 0i R (
t stringt ret matcht
ValueErrort groupsR t majort minort microt suffix( R t versiont reoR% ( ( sF /Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR } s c C se t | i | i ƒ } | d j o? t | i | i ƒ } | d j o t | i | i ƒ } qa n | S( Ni ( t cmpR&