diff --git a/properdocs/__main__.py b/properdocs/__main__.py index 8d395af3..310fd119 100644 --- a/properdocs/__main__.py +++ b/properdocs/__main__.py @@ -12,12 +12,7 @@ import click -from properdocs import ( - __version__, - config, - replacement, # noqa: F401 - utils, -) +from properdocs import __version__, config, replacement, utils if sys.platform.startswith("win"): try: @@ -27,6 +22,9 @@ else: colorama.init() +replacement.setup() + + log = logging.getLogger(__name__) diff --git a/properdocs/replacement.py b/properdocs/replacement.py index ef68c6b3..e0edff05 100644 --- a/properdocs/replacement.py +++ b/properdocs/replacement.py @@ -1,7 +1,8 @@ -"""After this file is imported, all mkdocs.* imports get redirected to properdocs.* imports.""" +"""After calling setup(), all mkdocs.* imports get redirected to properdocs.* imports.""" import importlib.abc import importlib.util +import os import sys @@ -37,6 +38,11 @@ def find_spec(self, fullname, path, target=None): return None -sys.meta_path.insert(0, _AliasFinder()) -# Plus, handle the topmost module directly and without waiting for it to be requested. -sys.modules['mkdocs'] = sys.modules['properdocs'] +def setup(): + sys.meta_path.insert(0, _AliasFinder()) + # Plus, handle the topmost module directly and without waiting for it to be requested. + sys.modules['mkdocs'] = sys.modules['properdocs'] + + # Prevent warnings from the theme that already uses this environment variable. + # That warning does not apply to ProperDocs. + os.environ['NO_MKDOCS_2_WARNING'] = 'true'