Skip to content

Commit 7391e8a

Browse files
authored
make pdoc . work (#813)
fix #812
1 parent 57ee1d6 commit 7391e8a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Include included HTML headers in the ToC by default by enabling markdown2's `mixed=True` option of the `header-ids` extra
88
(#806, @mrossinek)
9+
- Make `pdoc .` work to document the module in the current directory.
10+
([#813](https://github.com/mitmproxy/pdoc/pull/813), @mhils)
911

1012
## 2025-04-21: pdoc 15.0.3
1113

pdoc/extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def parse_spec(spec: Path | str) -> str:
112112
raise ModuleNotFoundError
113113
except pdoc.docstrings.AnyException:
114114
# Module does not exist, use local file.
115-
spec = pspec
115+
spec = pspec.resolve()
116116
else:
117117
# Module does exist. We now check if the local file/directory is the same (e.g. after pip install -e),
118118
# and emit a warning if that's not the case.

test/test_extract.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def test_parse_spec(monkeypatch):
100100
assert str(here / "testdata") in sys.path
101101
sys.path = p
102102

103+
monkeypatch.chdir(here / "testdata" / "demopackage" / "subpackage")
104+
assert parse_spec(".") == "demopackage.subpackage"
105+
assert parse_spec("..") == "demopackage"
106+
103107

104108
def test_parse_spec_mod_and_dir(tmp_path, monkeypatch):
105109
"""Test that we display a warning when both a module and a local directory exist with the provided name."""

0 commit comments

Comments
 (0)