Beispiel #1
0
def docstring_to_rest(docs: str) -> str:
    """Converts docstring into valid rest."""

    # This is awful and I should feel bad
    #docs = re.sub(r'^(\s*)## (.*)$', r'\1**\2**', docs, flags=re.M)
    docs = re.sub(r'(^|\s|-)%([A-Z_0-9]+)\b', r'\1:c:macro:`\2`', docs)
    docs = re.sub(r'(^|\s)#(\w+)\b', r'\1:class:`\2`', docs)
    docs = re.sub(r'(^|\s)@(\w+)\b', r'\1:c:data:`\2`', docs)
    docs = re.sub(r'\b([A-Z_]+\(\))', r':c:macro:`\1`', docs)
    docs = re.sub(r'([^`]|\b)([A-Za-z0-9_]+\(\))', r'\1:c:func:`\2`', docs)

    # Code snippets
    code = re.findall(r'\|\[.*$\n([^\]]+)', docs, flags=re.M)
    for c in code:
        docs = docs.replace(c, indent(c, '  '))
    docs = re.sub(
        r'( *)\|\[(?:<!-- language="(?P<language>\w+)" -->)?(?P<body>(?:(?:.|\n)(?!\]\|))+)\s?\]\|',
        r'\n\1.. code-block:: \g<language>\n\g<body>', docs)  # FIXME

    #docs = re.sub(
    #    r'( *)\|\[(?:<!-- language="(?:\w+)" -->)?(?P<body>(?:(?:.|\n)(?!\]\|))+)\s?\]\|',
    #    r'\n\1::\n\g<body>', docs)  # FIXME

    # Handle remaining markdown
    return M2R().parse(docs).strip()
Beispiel #2
0
def read(fname):
    dname = os.path.dirname(__file__)
    fname = os.path.join(dname, fname)

    with open(fname) as f:
        contents = f.read()
        sanatized = cleanhtml(contents)

        try:
            from m2r import M2R
            m2r = M2R()
            return m2r(sanatized)
        except:
            return sanatized
Beispiel #3
0
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'tensorforce', u'TensorForce Documentation',
              [author], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'TensorForce', u'TensorForce Documentation', author,
     'TensorForce', 'One line description of project.', 'Miscellaneous'),
]

m2r = M2R()


def process_docstring(app, what, name, obj, options, lines):
    """Enable markdown syntax in docstrings"""

    markdown = "\n".join(lines)

    # ast = cm_parser.parse(markdown)
    # html = cm_renderer.render(ast)
    rest = m2r(markdown)

    rest.replace("\r\n", "\n")
    del lines[:]
    lines.extend(rest.split("\n"))
Beispiel #4
0
                from py_backwards.compiler import compile_files
            target = (sys.version_info[0], sys.version_info[1])
            compile_files(in_dir, out_dir, target)
        else:
            raise Exception('Could not find package directory')
else:
    packages = ['pyppeteer']
    package_dir = {'pyppeteer': 'pyppeteer'}

readme_file = path.join(basedir, 'README.md')
with open(readme_file) as f:
    src = f.read()

try:
    from m2r import M2R
    readme = M2R()(src)
except ImportError:
    readme = src

requirements = [
    'pyee',
    'websockets',
]

test_requirements = [
    'syncer',
    'tornado>=5',
]

setup(
    name='pyppeteer',
Beispiel #5
0
def get_long_description(file):
    """Get the long description from the README file."""
    m2r = M2R()
    with open(file, encoding='utf-8') as f:
        return m2r(f.read())
Beispiel #6
0
 def conv(self, src, **kwargs):
     self.md = M2R(**kwargs)
     out = self.md(src)
     self.check_rst(out)
     return out