Пример #1
0
 def test_parse_file(self):
     output = parse_from_file(test_md)
     with open(test_rst) as f:
         expected = f.read()
     self.assertEqual(output.strip(), expected.strip())
Пример #2
0
__summary__ = "This package creates a framework for python packages to be built."
__uri__ = "https://github.com/kyhau/python-repo-template"

__requirements__ = []

__entry_points__ = {
    "console_scripts": [
        "new_module = module.main:main",
    ],
}

__long_description__ = ""
try:
    # Reformat description as PyPi use ReStructuredText rather than Markdown
    import m2r2
    __long_description__ = m2r2.parse_from_file(
        os.path.join(base_dir, "README.md"))
except (ImportError, IOError, OSError) as e:
    import logging
    logging.warning(f"m2r conversion failed: {e}")

CLASSIFIERS = [
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.6",
    "Programming Language :: Python :: 3.7",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3 :: Only",
]

setup(
Пример #3
0
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import os
import sys
import inspect
import shutil

__location__ = os.path.join(
    os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))

import m2r2

readme_rst_content = m2r2.parse_from_file(
    os.path.join(__location__, "..", "README.md"))
with open(os.path.join(__location__, "README.rst"), "w") as f:
    f.write(readme_rst_content)

# Try to import win32com, otherwise use mocking
try:
    import win32com
except ImportError:
    sys.path.insert(0, os.path.join(__location__, "../mocking"))

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.join(__location__, "../src"))

# -- Run sphinx-apidoc ------------------------------------------------------
Пример #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from os import path

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

readme_file = path.join(path.dirname(path.abspath(__file__)), "README.md")
try:
    from m2r2 import parse_from_file

    readme = parse_from_file(readme_file)
except ImportError:
    with open(readme_file) as f:
        readme = f.read()

__version__ = "0.2.5"

install_requires = ["mistune", "docutils"]
test_requirements = ["pygments"]
if sys.version_info < (3, 3):
    test_requirements.append("mock")

setup(
    name="m2r2",
    version=__version__,
    description="Markdown and reStructuredText in a single file.",
Пример #5
0
import re
import m2r2

files = [
    'Manual',
    'Exchange-Markets-By-Country',
    'Exchange-Markets',
]

for file in files:
    rst = m2r2.parse_from_file('./wiki/' + file + '.md',
                               'utf-8',
                               parse_relative_links=True,
                               anonymous_references=True)
    blank_lines = re.sub('- \n {5}.. image', '- .. image', rst)
    indent_level = re.sub(':(target|alt):', r'  :\1:', blank_lines)
    reference_links = re.sub(r'<(\w+)-(\w+)-(\w+)-(\w+)>`', r'<\1 \2 \3 \4>`',
                             indent_level)
    reference_links2 = re.sub(r'<(\w+)-(\w+)-(\w+)>`', r'<\1 \2 \3>`',
                              reference_links)
    reference_links3 = re.sub(r'<(\w+)-(\w+)>`', r'<\1 \2>`', reference_links2)
    remove_sublinks = re.sub(r'^\* :ref:`.+`$\n', '', reference_links3, 0,
                             re.MULTILINE)
    fix_table = re.sub(r'(_\n {5}- \n\n)', '_\n     -\n     -\n',
                       remove_sublinks)

    with open('./doc/' + file + '.rst', 'w') as f:
        f.write(fix_table)