Skip to content

Commit 87285b1

Browse files
committed
Revert "fix: Fixes Issue 89 with missing find_module (ml-tooling#91)"
This reverts commit fc1b6fe.
1 parent fc1b6fe commit 87285b1

File tree

4 files changed

+7
-42
lines changed

4 files changed

+7
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Lazydocs makes it easy to generate beautiful markdown documentation for your Pyt
3838

3939
### Installation
4040

41-
> _Requirements: Python 3.9+._
41+
> _Requirements: Python 3.6+._
4242
4343
```bash
4444
pip install lazydocs

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
EMAIL = "team@mltooling.org"
1616
AUTHOR = "ML Tooling Team"
1717
LICENSE = "MIT"
18-
REQUIRES_PYTHON = ">=3.9"
18+
REQUIRES_PYTHON = ">=3.6"
1919
VERSION = None # Only set version if you like to overwrite the version in _about.py
2020

2121
PWD = os.path.abspath(os.path.dirname(__file__))

src/lazydocs/generation.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,6 @@ def _lines_isvalid(lines: list, start_index: int, blockindent: int,
624624
prev_blank_line_count += 1
625625
return "".join(out)
626626

627-
628-
def get_module(loader, module_name: str) -> Optional[Any]:
629-
spec = loader.find_spec(module_name)
630-
if spec is None:
631-
raise ImportError(f"Cannot find module {module_name}")
632-
return spec.loader.load_module(spec.name)
633-
634-
635627
class MarkdownGenerator(object):
636628
"""Markdown generator class."""
637629

@@ -1258,7 +1250,8 @@ def generate_docs(
12581250
mod = importlib.util.module_from_spec(mod_spec)
12591251
mod_spec.loader.exec_module(mod)
12601252
except AttributeError:
1261-
mod = get_module(loader, module_name)
1253+
# For older python version compatibility
1254+
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
12621255
module_md = generator.module2md(mod, is_mdx=is_mdx, include_toc=include_toc)
12631256
if not module_md:
12641257
# Module md is empty -> ignore module and all submodules
@@ -1341,7 +1334,8 @@ def generate_docs(
13411334
mod = importlib.util.module_from_spec(mod_spec)
13421335
mod_spec.loader.exec_module(mod)
13431336
except AttributeError:
1344-
mod = get_module(loader, module_name)
1337+
# For older python version compatibility
1338+
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
13451339
module_md = generator.module2md(mod, is_mdx=is_mdx, include_toc=include_toc)
13461340

13471341
if not module_md:

tests/test_generation.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import hashlib
22

3-
from lazydocs import MarkdownGenerator, generate_docs
4-
from tempfile import TemporaryDirectory
3+
from lazydocs import MarkdownGenerator
54

65

76
def test_import2md() -> None:
@@ -36,31 +35,3 @@ def test_func2md() -> None:
3635
# Remove whitespaces: fix changes between py version 3.6 3.7 in signature method
3736
md_hash = hashlib.md5(markdown.replace(" ", "").encode("utf-8")).hexdigest()
3837
assert md_hash == "797bad8c00ee6f189cb6f578eaec02c4"
39-
40-
41-
def test_integration_generate_docs(capsys) -> None:
42-
test_class = """
43-
class TestClass:
44-
\"\"\"just a test class\"\"\"
45-
"""
46-
with TemporaryDirectory() as d:
47-
test_module_name = "test_module"
48-
with open(f"{d}/{test_module_name}.py", "w") as f:
49-
f.write(test_class)
50-
51-
overview_file_name = "DOCS.md"
52-
overview_file = f"{d}/output/{overview_file_name}"
53-
generate_docs(
54-
paths=[d],
55-
output_path=f"{d}/output/",
56-
overview_file=overview_file_name
57-
)
58-
59-
captured = capsys.readouterr()
60-
61-
with open(overview_file) as f:
62-
result = f.read()
63-
64-
assert test_module_name in result
65-
assert f"{test_module_name}.TestClass" in result
66-
assert "Failed to generate docs for module" not in captured.out

0 commit comments

Comments
 (0)