Skip to content

Commit

Permalink
FIX: Does this sort out the import?
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed Jan 12, 2024
1 parent ccafa90 commit 876ccd4
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ ghostdriver.log
.nox/*

venv*
.idea/*
11 changes: 9 additions & 2 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions m2r2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from .constants import *
from .typing import *
from .rst_parser import *
from .rst_renderer import *
from .m2r2 import M2R, convert
from .sphinx.m2r2 import setup
from .sphinx_m2r2 import setup

__all__ = ("M2R", "convert", "setup")

# __all__ = ("M2R", "convert", "setup", "rst")
2 changes: 1 addition & 1 deletion m2r2/cli/m2r2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from argparse import ArgumentParser, Namespace

from m2r2 import convert
from ..m2r2 import convert

parser = ArgumentParser()
options = Namespace()
Expand Down
2 changes: 1 addition & 1 deletion m2r2/rst/directives.py → m2r2/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from docutils import io, nodes, statemachine, utils
from docutils.parsers import rst

from m2r2 import M2R
from .m2r2 import M2R


class MdInclude(rst.Directive):
Expand Down
8 changes: 3 additions & 5 deletions m2r2/m2r2.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from __future__ import print_function, unicode_literals

import mistune
from pkg_resources import get_distribution

from .constants import PROLOG
from .rst.parser import RestBlockParser, RestInlineParser
from .rst.renderer import RestRenderer
from .rst_parser import RestBlockParser, RestInlineParser
from .rst_renderer import RestRenderer

__version__ = get_distribution("m2r2").version

print("at M2R")

class M2R(mistune.Markdown):
def __init__(self, renderer=None, block=None, inline=None, plugins=None):
Expand Down
2 changes: 1 addition & 1 deletion m2r2/parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from docutils import statemachine
from docutils.parsers import rst

from m2r2 import M2R
from .m2r2 import M2R


class M2RParser(rst.Parser):
Expand Down
Empty file removed m2r2/rst/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Empty file removed m2r2/sphinx/__init__.py
Empty file.
8 changes: 5 additions & 3 deletions m2r2/sphinx/m2r2.py → m2r2/sphinx_m2r2.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from m2r2.m2r2 import __version__
from m2r2.parser import M2RParser
from m2r2.rst.directives import MdInclude
from .m2r2 import __version__
from .parser import M2RParser
from .directives import MdInclude

_is_sphinx = False


def setup(app):
print("m2r2 setup.")
"""When used for sphinx extension."""
global _is_sphinx
_is_sphinx = True
Expand All @@ -21,6 +22,7 @@ def setup(app):
except (TypeError, AttributeError):
app.add_source_suffix(".md", "markdown")
app.add_source_parser(M2RParser)
print("included mdinclude")
app.add_directive("mdinclude", MdInclude)
metadata = dict(
version=__version__,
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def cop(session):
def bandit(session):
"""Run bandit."""
session.install("bandit")
session.run("bandit", "-r", "m2r2.py", "-ll", "-c", "bandit.yaml")
session.run("bandit", "-r", "sphinx_m2r2.py", "-ll", "-c", "bandit.yaml")


@nox.session(reuse_venv=True, python="3.7")
Expand Down
9 changes: 2 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@
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:
with open(readme_file) as f:
readme = f.read()
with open(readme_file) as f:
readme = f.read()


__version__ = "2.0.0rc1"
Expand Down

0 comments on commit 876ccd4

Please sign in to comment.