Skip to content

Commit 73763b3

Browse files
hukkinhukkinj1chrisjsewell
authored
👌 IMPROVE: Use __all__ to signal re-exports (#120)
Co-authored-by: Taneli Hukkinen <[email protected]> Co-authored-by: Chris Sewell <[email protected]>
1 parent 22a65b3 commit 73763b3

File tree

8 files changed

+95
-40
lines changed

8 files changed

+95
-40
lines changed

docs/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13+
from glob import glob
1314
import os
1415

1516
# import sys
@@ -103,6 +104,15 @@ def run_apidoc(app):
103104
ignore_paths = [
104105
os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths
105106
]
107+
# functions from these modules are all imported in the __init__.py with __all__
108+
for rule in ("block", "core", "inline"):
109+
for path in glob(
110+
os.path.normpath(
111+
os.path.join(this_folder, f"../markdown_it/rules_{rule}/*.py")
112+
)
113+
):
114+
if os.path.basename(path) not in ("__init__.py", f"state_{rule}.py"):
115+
ignore_paths.append(path)
106116

107117
if os.path.exists(api_folder):
108118
shutil.rmtree(api_folder)

markdown_it/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .main import MarkdownIt # noqa: F401
2-
3-
1+
__all__ = ("MarkdownIt",)
42
__version__ = "1.1.0"
3+
4+
from .main import MarkdownIt

markdown_it/helpers/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Functions for parsing Links
22
"""
3-
from .parse_link_label import parseLinkLabel # noqa: F401
4-
from .parse_link_destination import parseLinkDestination # noqa: F401
5-
from .parse_link_title import parseLinkTitle # noqa: F401
3+
__all__ = ("parseLinkLabel", "parseLinkDestination", "parseLinkTitle")
4+
from .parse_link_label import parseLinkLabel
5+
from .parse_link_destination import parseLinkDestination
6+
from .parse_link_title import parseLinkTitle

markdown_it/presets/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from . import commonmark, default, zero # noqa: F401
1+
__all__ = ("commonmark", "default", "zero", "js_default", "gfm_like")
2+
3+
from . import commonmark, default, zero
24

35
js_default = default
46

markdown_it/rules_block/__init__.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1-
from .state_block import StateBlock # noqa: F401
2-
from .paragraph import paragraph # noqa: F401
3-
from .heading import heading # noqa: F401
4-
from .lheading import lheading # noqa: F401
5-
from .code import code # noqa: F401
6-
from .fence import fence # noqa: F401
7-
from .hr import hr # noqa: F401
8-
from .list import list_block # noqa: F401
9-
from .reference import reference # noqa: F401
10-
from .blockquote import blockquote # noqa: F401
11-
from .html_block import html_block # noqa: F401
12-
from .table import table # noqa: F401
1+
__all__ = (
2+
"StateBlock",
3+
"paragraph",
4+
"heading",
5+
"lheading",
6+
"code",
7+
"fence",
8+
"hr",
9+
"list_block",
10+
"reference",
11+
"blockquote",
12+
"html_block",
13+
"table",
14+
)
15+
16+
from .state_block import StateBlock
17+
from .paragraph import paragraph
18+
from .heading import heading
19+
from .lheading import lheading
20+
from .code import code
21+
from .fence import fence
22+
from .hr import hr
23+
from .list import list_block
24+
from .reference import reference
25+
from .blockquote import blockquote
26+
from .html_block import html_block
27+
from .table import table

markdown_it/rules_core/__init__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
from .state_core import StateCore # noqa: F401
2-
from .normalize import normalize # noqa: F401
3-
from .block import block # noqa: F401
4-
from .inline import inline # noqa: F401
5-
from .replacements import replace # noqa: F401
6-
from .smartquotes import smartquotes # noqa: F401
7-
from .linkify import linkify # noqa: F401
1+
__all__ = (
2+
"StateCore",
3+
"normalize",
4+
"block",
5+
"inline",
6+
"replace",
7+
"smartquotes",
8+
"linkify",
9+
)
10+
11+
from .state_core import StateCore
12+
from .normalize import normalize
13+
from .block import block
14+
from .inline import inline
15+
from .replacements import replace
16+
from .smartquotes import smartquotes
17+
from .linkify import linkify

markdown_it/rules_inline/__init__.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
from .state_inline import StateInline # noqa: F401
2-
from .text import text # noqa: F401
3-
from .text_collapse import text_collapse # noqa: F401
4-
from .balance_pairs import link_pairs # noqa: F401
5-
from .escape import escape # noqa: F401
6-
from .newline import newline # noqa: F401
7-
from .backticks import backtick # noqa: F401
8-
from . import emphasis # noqa: F401
9-
from .image import image # noqa: F401
10-
from .link import link # noqa: F401
11-
from .autolink import autolink # noqa: F401
12-
from .entity import entity # noqa: F401
13-
from .html_inline import html_inline # noqa: F401
14-
from . import strikethrough # noqa: F401
1+
__all__ = (
2+
"StateInline",
3+
"text",
4+
"text_collapse",
5+
"link_pairs",
6+
"escape",
7+
"newline",
8+
"backtick",
9+
"emphasis",
10+
"image",
11+
"link",
12+
"autolink",
13+
"entity",
14+
"html_inline",
15+
"strikethrough",
16+
)
17+
from .state_inline import StateInline
18+
from .text import text
19+
from .text_collapse import text_collapse
20+
from .balance_pairs import link_pairs
21+
from .escape import escape
22+
from .newline import newline
23+
from .backticks import backtick
24+
from . import emphasis
25+
from .image import image
26+
from .link import link
27+
from .autolink import autolink
28+
from .entity import entity
29+
from .html_inline import html_inline
30+
from . import strikethrough

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ warn_unused_ignores = True
8181
warn_redundant_casts = True
8282
no_implicit_optional = True
8383
strict_equality = True
84+
implicit_reexport = False
8485

8586
[mypy-tests.test_plugins.*]
8687
ignore_errors = True

0 commit comments

Comments
 (0)