Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👌 IMPROVE: Use __all__ to signal re-exports #120

Merged
merged 11 commits into from
Dec 1, 2021
10 changes: 10 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# 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.
#
from glob import glob
import os

# import sys
Expand Down Expand Up @@ -103,6 +104,15 @@ def run_apidoc(app):
ignore_paths = [
os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths
]
# functions from these modules are all imported in the __init__.py with __all__
for rule in ("block", "core", "inline"):
for path in glob(
os.path.normpath(
os.path.join(this_folder, f"../markdown_it/rules_{rule}/*.py")
)
):
if os.path.basename(path) not in ("__init__.py", f"state_{rule}.py"):
ignore_paths.append(path)

if os.path.exists(api_folder):
shutil.rmtree(api_folder)
Expand Down
6 changes: 3 additions & 3 deletions markdown_it/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .main import MarkdownIt # noqa: F401


__all__ = ("MarkdownIt",)
__version__ = "1.1.0"

from .main import MarkdownIt
7 changes: 4 additions & 3 deletions markdown_it/helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Functions for parsing Links
"""
from .parse_link_label import parseLinkLabel # noqa: F401
from .parse_link_destination import parseLinkDestination # noqa: F401
from .parse_link_title import parseLinkTitle # noqa: F401
__all__ = ("parseLinkLabel", "parseLinkDestination", "parseLinkTitle")
from .parse_link_label import parseLinkLabel
from .parse_link_destination import parseLinkDestination
from .parse_link_title import parseLinkTitle
4 changes: 3 additions & 1 deletion markdown_it/presets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from . import commonmark, default, zero # noqa: F401
__all__ = ("commonmark", "default", "zero", "js_default", "gfm_like")

from . import commonmark, default, zero

js_default = default

Expand Down
39 changes: 27 additions & 12 deletions markdown_it/rules_block/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
from .state_block import StateBlock # noqa: F401
from .paragraph import paragraph # noqa: F401
from .heading import heading # noqa: F401
from .lheading import lheading # noqa: F401
from .code import code # noqa: F401
from .fence import fence # noqa: F401
from .hr import hr # noqa: F401
from .list import list_block # noqa: F401
from .reference import reference # noqa: F401
from .blockquote import blockquote # noqa: F401
from .html_block import html_block # noqa: F401
from .table import table # noqa: F401
__all__ = (
"StateBlock",
"paragraph",
"heading",
"lheading",
"code",
"fence",
"hr",
"list_block",
"reference",
"blockquote",
"html_block",
"table",
)

from .state_block import StateBlock
from .paragraph import paragraph
from .heading import heading
from .lheading import lheading
from .code import code
from .fence import fence
from .hr import hr
from .list import list_block
from .reference import reference
from .blockquote import blockquote
from .html_block import html_block
from .table import table
24 changes: 17 additions & 7 deletions markdown_it/rules_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from .state_core import StateCore # noqa: F401
from .normalize import normalize # noqa: F401
from .block import block # noqa: F401
from .inline import inline # noqa: F401
from .replacements import replace # noqa: F401
from .smartquotes import smartquotes # noqa: F401
from .linkify import linkify # noqa: F401
__all__ = (
"StateCore",
"normalize",
"block",
"inline",
"replace",
"smartquotes",
"linkify",
)

from .state_core import StateCore
from .normalize import normalize
from .block import block
from .inline import inline
from .replacements import replace
from .smartquotes import smartquotes
from .linkify import linkify
44 changes: 30 additions & 14 deletions markdown_it/rules_inline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
from .state_inline import StateInline # noqa: F401
from .text import text # noqa: F401
from .text_collapse import text_collapse # noqa: F401
from .balance_pairs import link_pairs # noqa: F401
from .escape import escape # noqa: F401
from .newline import newline # noqa: F401
from .backticks import backtick # noqa: F401
from . import emphasis # noqa: F401
from .image import image # noqa: F401
from .link import link # noqa: F401
from .autolink import autolink # noqa: F401
from .entity import entity # noqa: F401
from .html_inline import html_inline # noqa: F401
from . import strikethrough # noqa: F401
__all__ = (
"StateInline",
"text",
"text_collapse",
"link_pairs",
"escape",
"newline",
"backtick",
"emphasis",
"image",
"link",
"autolink",
"entity",
"html_inline",
"strikethrough",
)
from .state_inline import StateInline
from .text import text
from .text_collapse import text_collapse
from .balance_pairs import link_pairs
from .escape import escape
from .newline import newline
from .backticks import backtick
from . import emphasis
from .image import image
from .link import link
from .autolink import autolink
from .entity import entity
from .html_inline import html_inline
from . import strikethrough
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ warn_unused_ignores = True
warn_redundant_casts = True
no_implicit_optional = True
strict_equality = True
implicit_reexport = False

[mypy-tests.test_plugins.*]
ignore_errors = True
Expand Down