[Python-modules-commits] [recommonmark] 01/03: Import recommonmark_0.4.0+ds.orig.tar.xz

Jerome Benoit calculus-guest at moszumanska.debian.org
Tue Oct 4 00:54:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

calculus-guest pushed a commit to branch master
in repository recommonmark.

commit f3314d3175e00c7ef5fa3fea03654fa5bc833a69
Author: Jerome Benoit <calculus at rezozer.net>
Date:   Tue Oct 4 01:40:19 2016 +0100

    Import recommonmark_0.4.0+ds.orig.tar.xz
---
 PKG-INFO                  |  10 ++
 recommonmark/__init__.py  |   1 +
 recommonmark/parser.py    | 288 ++++++++++++++++++++++++++++++++++++++++
 recommonmark/scripts.py   |  60 +++++++++
 recommonmark/states.py    | 142 ++++++++++++++++++++
 recommonmark/transform.py | 325 ++++++++++++++++++++++++++++++++++++++++++++++
 setup.py                  |  26 ++++
 7 files changed, 852 insertions(+)

diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..7f06425
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: recommonmark
+Version: 0.4.0
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: UNKNOWN
+Author-email: UNKNOWN
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
diff --git a/recommonmark/__init__.py b/recommonmark/__init__.py
new file mode 100644
index 0000000..abeeedb
--- /dev/null
+++ b/recommonmark/__init__.py
@@ -0,0 +1 @@
+__version__ = '0.4.0'
diff --git a/recommonmark/parser.py b/recommonmark/parser.py
new file mode 100644
index 0000000..748a4b9
--- /dev/null
+++ b/recommonmark/parser.py
@@ -0,0 +1,288 @@
+from contextlib import contextmanager
+import itertools
+
+from docutils import parsers, nodes
+
+from CommonMark import DocParser, HTMLRenderer
+from warnings import warn
+
+__all__ = ['CommonMarkParser']
+
+
+def flatten(iterator):
+    return itertools.chain.from_iterable(iterator)
+
+
+class _SectionHandler(object):
+
+    def __init__(self, document):
+        self._level_to_elem = {0: document}
+
+    def _parent_elem(self, child_level):
+        parent_level = max(level for level in self._level_to_elem
+                           if child_level > level)
+        return self._level_to_elem[parent_level]
+
+    def _prune_levels(self, limit_level):
+        self._level_to_elem = dict((level, elem)
+                                   for level, elem in self._level_to_elem.items()
+                                   if level <= limit_level)
+
+    def add_new_section(self, section, level):
+        parent = self._parent_elem(level)
+        parent.append(section)
+        self._level_to_elem[level] = section
+        self._prune_levels(level)
+
+
+class CommonMarkParser(parsers.Parser):
+
+    """Parser of recommonmark."""
+    supported = ('md', 'markdown')
+
+    def convert_blocks(self, blocks):
+        for block in blocks:
+            self.convert_block(block)
+
+    def convert_block(self, block):
+        if (block.t == "Document"):
+            self.convert_blocks(block.children)
+        elif (block.t == "ATXHeader") or (block.t == "SetextHeader"):
+            self.section(block)
+        elif (block.t == "Paragraph"):
+            self.paragraph(block)
+        elif (block.t == "BlockQuote"):
+            self.blockquote(block)
+        elif (block.t == "ListItem"):
+            self.list_item(block)
+        elif (block.t == "List"):
+            self.list_block(block)
+        elif (block.t == "IndentedCode"):
+            self.verbatim(block.string_content)
+        elif (block.t == "FencedCode"):
+            if len(block.strings) and len(block.strings[0]):
+                self.code(block.strings[0].strip(), block.string_content)
+            else:
+                self.verbatim(block.string_content)
+        elif (block.t == "ReferenceDef"):
+            self.reference(block)
+        elif (block.t == "HorizontalRule"):
+            self.horizontal_rule()
+        elif (block.t == "HtmlBlock"):
+            self.html_block(block)
+        else:
+            warn("Unsupported block type: " + block.t)
+
+    def parse(self, inputstring, document):
+        self.setup_parse(inputstring, document)
+
+        self.document = document
+        self.current_node = document
+        self.section_handler = _SectionHandler(document)
+
+        parser = DocParser()
+
+        ast = parser.parse(inputstring + '\n')
+
+        self.convert_block(ast)
+
+        self.finish_parse()
+
+    @contextmanager
+    def _temp_current_node(self, current_node):
+        saved_node = self.current_node
+        self.current_node = current_node
+        yield
+        self.current_node = saved_node
+
+    # Blocks
+    def section(self, block):
+        new_section = nodes.section()
+        new_section.line = block.start_line
+        new_section['level'] = block.level
+
+        title_node = nodes.title()
+        title_node.line = block.start_line
+        append_inlines(title_node, block.inline_content)
+        new_section.append(title_node)
+        name = nodes.fully_normalize_name(title_node.astext())
+        new_section['names'].append(name)
+        self.current_node.document.note_implicit_target(new_section, new_section)
+        new_section['ids'].append(nodes.make_id(name))
+
+        self.section_handler.add_new_section(new_section, block.level)
+        self.current_node = new_section
+
+    def verbatim(self, text):
+        verbatim_node = nodes.literal_block()
+        text = ''.join(flatten(text))
+        if text.endswith('\n'):
+            text = text[:-1]
+        verbatim_node.append(nodes.Text(text))
+        self.current_node.append(verbatim_node)
+
+    def code(self, language, text):
+        node = nodes.literal_block(text, text, language=language)
+        self.current_node.append(node)
+
+    def paragraph(self, block):
+        p = nodes.paragraph()
+        p.line = block.start_line
+        append_inlines(p, block.inline_content)
+        self.current_node.append(p)
+
+    def blockquote(self, block):
+        q = nodes.block_quote()
+        q.line = block.start_line
+
+        with self._temp_current_node(q):
+            self.convert_blocks(block.children)
+
+        self.current_node.append(q)
+
+    def list_item(self, block):
+        node = nodes.list_item()
+        node.line = block.start_line
+
+        with self._temp_current_node(node):
+            self.convert_blocks(block.children)
+
+        self.current_node.append(node)
+
+    def list_block(self, block):
+        list_node = None
+        if (block.list_data['type'] == "Bullet"):
+            list_node = nodes.bullet_list()
+        else:
+            list_node = nodes.enumerated_list()
+        list_node.line = block.start_line
+
+        with self._temp_current_node(list_node):
+            self.convert_blocks(block.children)
+
+        self.current_node.append(list_node)
+
+    def html_block(self, block):
+        raw_node = nodes.raw('', block.string_content, format='html')
+        raw_node.line = block.start_line
+        self.current_node.append(raw_node)
+
+    def horizontal_rule(self):
+        transition_node = nodes.transition()
+        self.current_node.append(transition_node)
+
+    def reference(self, block):
+        target_node = nodes.target()
+        target_node.line = block.start_line
+
+        target_node['names'].append(make_refname(block.label))
+
+        target_node['refuri'] = block.destination
+
+        if block.title:
+            target_node['title'] = block.title
+
+        self.current_node.append(target_node)
+
+
+def make_refname(label):
+    return text_only(label).lower()
+
+
+def text_only(nodes):
+    return "".join(s.c if s.t == "Str" else text_only(s.children)
+                   for s in nodes)
+
+# Inlines
+
+
+def emph(inlines):
+    emph_node = nodes.emphasis()
+    append_inlines(emph_node, inlines)
+    return emph_node
+
+
+def strong(inlines):
+    strong_node = nodes.strong()
+    append_inlines(strong_node, inlines)
+    return strong_node
+
+
+def inline_code(inline):
+    literal_node = nodes.literal()
+    literal_node.append(nodes.Text(inline.c))
+    return literal_node
+
+
+def inline_html(inline):
+    literal_node = nodes.raw('', inline.c, format='html')
+    return literal_node
+
+
+def inline_entity(inline):
+    val = HTMLRenderer().renderInline(inline)
+    entity_node = nodes.paragraph('', val, format='html')
+    return entity_node
+
+
+def reference(block):
+    ref_node = nodes.reference()
+
+    label = make_refname(block.label)
+
+    ref_node['name'] = label
+    if block.destination is not None:
+        ref_node['refuri'] = block.destination
+    else:
+        ref_node['refname'] = label
+        # self.document.note_refname(ref_node)
+
+    if block.title:
+        ref_node['title'] = block.title
+
+    append_inlines(ref_node, block.label)
+    return ref_node
+
+
+def image(block):
+    img_node = nodes.image()
+
+    img_node['uri'] = block.destination
+
+    if block.title:
+        img_node['title'] = block.title
+
+    img_node['alt'] = text_only(block.label)
+    return img_node
+
+
+def parse_inline(parent_node, inline):
+    node = None
+    if (inline.t == "Str"):
+        node = nodes.Text(inline.c)
+    elif (inline.t == "Softbreak"):
+        node = nodes.Text('\n')
+    elif inline.t == "Emph":
+        node = emph(inline.c)
+    elif inline.t == "Strong":
+        node = strong(inline.c)
+    elif inline.t == "Link":
+        node = reference(inline)
+    elif inline.t == "Image":
+        node = image(inline)
+    elif inline.t == "Code":
+        node = inline_code(inline)
+    elif inline.t == "Html":
+        node = inline_html(inline)
+    elif (inline.t == "Entity"):
+        node = inline_entity(inline)
+    else:
+        warn("Unsupported inline type " + inline.t)
+        return
+    node.line = inline.start_line
+    parent_node.append(node)
+
+
+def append_inlines(parent_node, inlines):
+    for i in range(len(inlines)):
+        parse_inline(parent_node, inlines[i])
diff --git a/recommonmark/scripts.py b/recommonmark/scripts.py
new file mode 100644
index 0000000..ce0aaae
--- /dev/null
+++ b/recommonmark/scripts.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+'''
+File: scripts.py
+Author: Steve Genoud
+Date: 2013-08-25
+Description: Scripts loaded by setuptools entry points
+'''
+
+
+try:
+    import locale
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
+
+from docutils.core import publish_cmdline, default_description
+from recommonmark.parser import CommonMarkParser
+
+
+def cm2html():
+    description = ('Generate html document from markdown sources. ' + default_description)
+    publish_cmdline(writer_name='html',
+                    parser=CommonMarkParser(),
+                    description=description)
+
+
+def cm2man():
+    description = ('Generate a manpage from markdown sources. ' + default_description)
+    publish_cmdline(writer_name='manpage',
+                    parser=CommonMarkParser(),
+                    description=description)
+
+
+def cm2xml():
+    description = ('Generate XML document from markdown sources. ' + default_description)
+    publish_cmdline(writer_name='xml',
+                    parser=CommonMarkParser(),
+                    description=description)
+
+
+def cm2pseudoxml():
+    description = ('Generate pseudo-XML document from markdown sources. ' + default_description)
+    publish_cmdline(writer_name='pseudoxml',
+                    parser=CommonMarkParser(),
+                    description=description)
+
+
+def cm2latex():
+    description = ('Generate latex document from markdown sources. ' + default_description)
+    publish_cmdline(writer_name='latex',
+                    parser=CommonMarkParser(),
+                    description=description)
+
+
+def cm2xetex():
+    description = ('Generate xetex document from markdown sources. ' + default_description)
+    publish_cmdline(writer_name='latex',
+                    parser=CommonMarkParser(),
+                    description=description)
diff --git a/recommonmark/states.py b/recommonmark/states.py
new file mode 100644
index 0000000..d926998
--- /dev/null
+++ b/recommonmark/states.py
@@ -0,0 +1,142 @@
+"""Implement statemachine and state that are needed to Generate Derivatives."""
+from docutils.statemachine import StateMachineWS
+from docutils.parsers.rst import languages
+from docutils.parsers.rst.states import Struct, RSTState, Inliner
+from docutils.parsers.rst.roles import role
+from docutils.parsers.rst.directives import directive
+
+
+class DummyStateMachine(StateMachineWS):
+
+    """A dummy state machine that mimicks the property of statemachine.
+
+    This state machine cannot be used for parsing, it is only used to generate
+    directive and roles. Usage:
+    - Call `reset` to reset the state
+    - Then call `run_directive` or `run_role` to generate the node.
+    """
+
+    def __init__(self):
+        self.memo = Struct(title_styles=[],
+                           inliner=None)
+        self.state = RSTState(self)
+        self.input_offset = 0
+
+    def reset(self, document, parent, level):
+        """Reset the state of state machine.
+
+        After reset, self and self.state can be used to
+        passed to docutils.parsers.rst.Directive.run
+
+        Parameters
+        ----------
+        document: docutils document
+            Current document of the node.
+        parent: parent node
+            Parent node that will be used to interpret role and directives.
+        level: int
+            Current section level.
+        """
+        self.language = languages.get_language(
+            document.settings.language_code)
+        # setup memo
+        self.memo.document = document
+        self.memo.reporter = document.reporter
+        self.memo.language = self.language
+        self.memo.section_level = level
+        # setup inliner
+        if self.memo.inliner is None:
+            self.memo.inliner = Inliner()
+            self.memo.inliner.init_customizations(document.settings)
+        inliner = self.memo.inliner
+        inliner.reporter = document.reporter
+        inliner.document = document
+        inliner.language = self.language
+        inliner.parent = parent
+        # setup self
+        self.document = document
+        self.reporter = self.memo.reporter
+        self.node = parent
+        self.state.runtime_init()
+        self.input_lines = document['source']
+
+    def run_directive(self, name,
+                      arguments=None,
+                      options=None,
+                      content=None):
+        """Generate directive node given arguments.
+
+        Parameters
+        ----------
+        name : str
+            name of directive.
+        arguments : list
+            list of positional arguments.
+        options : dict
+            key value arguments.
+        content : content
+            content of the directive
+
+        Returns
+        -------
+        node : docutil Node
+            Node generated by the arguments.
+        """
+        if options is None:
+            options = {}
+        if content is None:
+            content = []
+        if arguments is None:
+            arguments = []
+        direc, msg = directive(name,
+                               self.language,
+                               self.document)
+        direc = direc(name=name,
+                      arguments=arguments,
+                      options=options,
+                      content=content,
+                      lineno=self.node.line,
+                      content_offset=0,
+                      block_text='Dummy BlockText',
+                      state=self.state,
+                      state_machine=self)
+        return direc.run()
+
+    def run_role(self, name,
+                 options=None,
+                 content=None):
+        """Generate a role node.
+
+        options : dict
+            key value arguments.
+        content : content
+            content of the directive
+
+        Returns
+        -------
+        node : docutil Node
+            Node generated by the arguments.
+        """
+        if options is None:
+            options = {}
+        if content is None:
+            content = []
+        role_fn, msg = role(name,
+                            self.language,
+                            self.node.line,
+                            self.reporter)
+        vec, msg = role_fn(name,
+                           rawtext=str(content),
+                           text=str(content),
+                           lineno=self.node.line,
+                           inliner=self.memo.inliner,
+                           options=options,
+                           content=content)
+        assert len(vec) == 1, 'only support one list in role'
+        return vec[0]
+
+    def get_source_and_line(self, lineno=None):
+        if lineno:
+            return (self.document['source'], lineno)
+        else:
+            return (self.document['source'], self.node.line)
diff --git a/recommonmark/transform.py b/recommonmark/transform.py
new file mode 100644
index 0000000..48a93be
--- /dev/null
+++ b/recommonmark/transform.py
@@ -0,0 +1,325 @@
+"""Implement some common transforms on parsed AST."""
+import os
+import sys
+from .states import DummyStateMachine
+from docutils import nodes, transforms
+from docutils.statemachine import StringList
+
+
+class AutoStructify(transforms.Transform):
+
+    """Automatically try to transform blocks to sphinx directives.
+
+    This class is designed to handle AST generated by CommonMarkParser.
+    """
+    # set to a high priority so it can be applied first for markdown docs
+    default_priority = 1000
+    suffix_set = set(['md', 'rst'])
+
+    default_config = {
+        'enable_auto_doc_ref': True,
+        'auto_toc_tree_section': None,
+        'enable_auto_toc_tree': True,
+        'enable_eval_rst': True,
+        'enable_math': True,
+        'enable_inline_math': True,
+        'url_resolver': lambda x: x,
+    }
+
+    def parse_ref(self, ref):
+        """Analyze the ref block, and return the information needed.
+
+        Parameters
+        ----------
+        ref : nodes.reference
+
+        Returns
+        -------
+        result : tuple of (str, str, str)
+            The returned result is tuple of (title, uri, docpath).
+            title is the display title of the ref.
+            uri is the html uri of to the ref after resolve.
+            docpath is the absolute document path to the document, if
+            the target corresponds to an internal document, this can bex None
+        """
+        assert isinstance(ref, nodes.reference)
+        title = None
+        if len(ref.children) == 0:
+            title = ref['name']
+        elif isinstance(ref.children[0], nodes.Text):
+            title = ref.children[0].astext()
+        uri = ref['refuri']
+        if uri.find('://') != -1:
+            return (title, uri, None)
+        anchor = None
+        arr = uri.split('#')
+        if len(arr) == 2:
+            anchor = arr[1]
+        if len(arr) > 2 or len(arr[0]) == 0:
+            return (title, uri, None)
+        uri = arr[0]
+
+        abspath = os.path.abspath(os.path.join(self.file_dir, uri))
+        relpath = os.path.relpath(abspath, self.root_dir)
+        suffix = abspath.rsplit('.', 1)
+        if len(suffix) == 2 and suffix[1] in AutoStructify.suffix_set and (
+                os.path.exists(abspath) and abspath.startswith(self.root_dir)):
+            docpath = '/' + relpath.rsplit('.', 1)[0]
+            # rewrite suffix to html, this is suboptimal
+            uri = docpath + '.html'
+            if anchor is None:
+                return (title, uri, docpath)
+            else:
+                return (title, uri + '#' + anchor, None)
+        else:
+            # use url resolver
+            if self.url_resolver:
+                uri = self.url_resolver(relpath)
+            if anchor:
+                uri += '#' + anchor
+            return (title, uri, None)
+
+    def auto_toc_tree(self, node):
+        """Try to convert a list block to toctree in rst.
+
+        This function detects if the matches the condition and return
+        a converted toc tree node. The matching condition:
+        The list only contains one level, and only contains references
+
+        Parameters
+        ----------
+        node: nodes.Sequential
+            A list node in the doctree
+
+        Returns
+        -------
+        tocnode: docutils node
+            The converted toc tree node, None if conversion is not possible.
+        """
+        if not self.config['enable_auto_toc_tree']:
+            return None
+        # when auto_toc_tree_section is set
+        # only auto generate toctree under the specified section title
+        sec = self.config['auto_toc_tree_section']
+        if sec is not None:
+            if node.parent is None:
+                return None
+            if not isinstance(node.parent, nodes.section):
+                return None
+            title = node.parent.children[0]
+            if not isinstance(title, nodes.title):
+                return None
+            if title.astext().strip() != sec:
+                return None
+
+        numbered = None
+        if isinstance(node, nodes.bullet_list):
+            numbered = 0
+        elif isinstance(node, nodes.enumerated_list):
+            numbered = 1
+
+        if numbered is None:
+            return None
+        refs = []
+        for nd in node.children[:]:
+            assert isinstance(nd, nodes.list_item)
+            if len(nd.children) != 1:
+                return None
+            par = nd.children[0]
+            if not isinstance(par, nodes.paragraph):
+                return None
+            if len(par.children) != 1:
+                return None
+            ref = par.children[0]
+            if not isinstance(ref, nodes.reference):
+                return None
+            title, uri, docpath = self.parse_ref(ref)
+            if title is None or uri.startswith('#'):
+                return None
+            if docpath:
+                refs.append((title, docpath))
+            else:
+                refs.append((title, uri))
+        self.state_machine.reset(self.document,
+                                 node.parent,
+                                 self.current_level)
+        return self.state_machine.run_directive(
+            'toctree',
+            options={'maxdepth': 1, 'numbered': numbered},
+            content=['%s <%s>' % (k, v) for k, v in refs])
+
+    def auto_doc_ref(self, node):
+        """Try to convert a reference to docref in rst.
+
+        Parameters
+        ----------
+        node : nodes.reference
+           A reference node in doctree.
+
+        Returns
+        -------
+        tocnode: docutils node
+            The converted toc tree node, None if conversion is not possible.
+        """
+        if not self.config['enable_auto_doc_ref']:
+            return None
+        assert isinstance(node, nodes.reference)
+        title, uri, docpath = self.parse_ref(node)
+        if title is None:
+            return None
+        if docpath:
+            content = u'%s <%s>' % (title, docpath)
+            self.state_machine.reset(self.document,
+                                     node.parent,
+                                     self.current_level)
+            return self.state_machine.run_role('doc', content=content)
+        else:
+            # inplace modify uri
+            node['refuri'] = uri
+            return None
+
+    def auto_inline_code(self, node):
+        """Try to automatically generate nodes for inline literals.
+
+        Parameters
+        ----------
+        node : nodes.literal
+            Original codeblock node
+        Returns
+        -------
+        tocnode: docutils node
+            The converted toc tree node, None if conversion is not possible.
+        """
+        assert isinstance(node, nodes.literal)
+        if len(node.children) != 1:
+            return None
+        content = node.children[0]
+        if not isinstance(content, nodes.Text):
+            return None
+        content = content.astext().strip()
+        if content.startswith('$') and content.endswith('$'):
+            if not self.config['enable_inline_math']:
+                return None
+            content = content[1:-1]
+            self.state_machine.reset(self.document,
+                                     node.parent,
+                                     self.current_level)
+            return self.state_machine.run_role('math', content=content)
+        else:
+            return None
+
+    def auto_code_block(self, node):
+        """Try to automatically generate nodes for codeblock syntax.
+
+        Parameters
+        ----------
+        node : nodes.literal_block
+            Original codeblock node
+        Returns
+        -------
+        tocnode: docutils node
+            The converted toc tree node, None if conversion is not possible.
+        """
+        assert isinstance(node, nodes.literal_block)
+        if 'language' not in node:
+            return None
+        self.state_machine.reset(self.document,
+                                 node.parent,
+                                 self.current_level)
+        content = node.rawsource.split('\n')
+        language = node['language']
+        if language == 'math':
+            if self.config['enable_math']:
+                return self.state_machine.run_directive(
+                    'math', content=content)
+        elif language == 'eval_rst':
+            if self.config['enable_eval_rst']:
+                # allow embed non section level rst
+                node = nodes.section()
+                self.state_machine.state.nested_parse(
+                    StringList(content, source=node.rawsource),
+                    0, node=node, match_titles=False)
+                return node.children[:]
+        else:
+            return self.state_machine.run_directive(
+                'code-block', arguments=[language],
+                content=content)
+        return None
+
+    def find_replace(self, node):
+        """Try to find replace node for current node.
+
+        Parameters
+        ----------
+        node : docutil node
+            Node to find replacement for.
+
+        Returns
+        -------
+        nodes : node or list of node
+            The replacement nodes of current node.
+            Returns None if no replacement can be found.
+        """
+        newnode = None
+        if isinstance(node, nodes.Sequential):
+            newnode = self.auto_toc_tree(node)
+        elif isinstance(node, nodes.reference):
+            newnode = self.auto_doc_ref(node)
+        elif isinstance(node, nodes.literal_block):
+            newnode = self.auto_code_block(node)
+        elif isinstance(node, nodes.literal):
+            newnode = self.auto_inline_code(node)
+        return newnode
+
+    def traverse(self, node):
+        """Traverse the document tree rooted at node.
+
+        node : docutil node
+            current root node to traverse
+        """
+        old_level = self.current_level
+        if isinstance(node, nodes.section):
+            if 'level' in node:
+                self.current_level = node['level']
+        to_visit = []
+        to_replace = []
+        for c in node.children[:]:
+            newnode = self.find_replace(c)
+            if newnode is not None:
+                to_replace.append((c, newnode))
+            else:
+                to_visit.append(c)
+
+        for oldnode, newnodes in to_replace:
+            node.replace(oldnode, newnodes)
+
+        for child in to_visit:
+            self.traverse(child)
+        self.current_level = old_level
+
+    def apply(self):
+        """Apply the transformation by configuration."""
+        # only transform markdowns
+        source = self.document['source']
+        if not source.endswith('.md'):
+            return
+
+        self.reporter = self.document.reporter
+        self.reporter.info('AutoStructify: %s' % source)
+
+        config = self.default_config.copy()
+        try:
+            new_cfg = self.document.settings.env.config.recommonmark_config
+            config.update(new_cfg)
+        except:
+            self.reporter.warning('recommonmark_config not setted,'
+                                  ' proceed default setting')
+        self.url_resolver = config['url_resolver']
+        assert callable(self.url_resolver)
+
+        self.config = config
+        self.state_machine = DummyStateMachine()
+        self.current_level = 0
+        self.file_dir = os.path.abspath(os.path.dirname(self.document['source']))
+        self.root_dir = os.path.abspath(self.document.settings.env.srcdir)
+        self.traverse(self.document)
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..e4c1fb0
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+'''
+File: setup.py
+Author: Steve Genoud and Luca Barbato
+Date: 2014-10-17
+'''
+from setuptools import setup
+import recommonmark
+
+setup(name='recommonmark',
+      version=recommonmark.__version__,
+      install_requires=[
+          'commonmark<=0.5.4',
+          'docutils>=0.11'
+      ],
+      entry_points={'console_scripts': [
+          'cm2html = recommonmark.scripts:cm2html',
+          'cm2latex = recommonmark.scripts:cm2latex',
+          'cm2man = recommonmark.scripts:cm2man',
+          'cm2pseudoxml = recommonmark.scripts:cm2pseudoxml',
+          'cm2xetex = recommonmark.scripts:cm2xetex',
+          'cm2xml = recommonmark.scripts:cm2xml',
+      ]},
+      packages=['recommonmark']
+     )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/recommonmark.git



More information about the Python-modules-commits mailing list