Skip to content

Commit 1a95f48

Browse files
committed
fix: autopackage works with no module docstring
1 parent 81ce4c5 commit 1a95f48

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

quartodoc/builder/blueprint.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,37 @@ def _auto_package(mod: dc.Module) -> list[Section]:
4343

4444
import griffe.docstrings.dataclasses as ds
4545

46+
has_all = "__all__" in mod.members
47+
48+
if not has_all:
49+
print(
50+
f"\nWARNING: the module {mod.name} does not define an __all__ attribute."
51+
" Generating documentation from all members of the module."
52+
" Define __all__ in your package's __init__.py to specify exactly which"
53+
" functions it exports (and should be documented).\n"
54+
)
55+
4656
# get module members for content ----
4757
contents = []
4858
for name, member in mod.members.items():
4959
external_alias = _is_external_alias(member, mod)
50-
if external_alias or member.is_module or name.startswith("__"):
60+
if (
61+
external_alias
62+
or member.is_module
63+
or name.startswith("__")
64+
or (has_all and not mod.member_is_exported(member))
65+
):
5166
continue
5267

5368
contents.append(Auto(name=name))
5469

5570
# try to fetch a description of the module ----
56-
mod_summary = mod.docstring.parsed[0]
57-
if isinstance(mod_summary, ds.DocstringSectionText):
58-
desc = mod_summary.value
71+
if mod.docstring and mod.docstring.parsed:
72+
mod_summary = mod.docstring.parsed[0]
73+
if isinstance(mod_summary, ds.DocstringSectionText):
74+
desc = mod_summary.value
75+
else:
76+
desc = ""
5977
else:
6078
desc = ""
6179

0 commit comments

Comments
 (0)