File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -43,19 +43,37 @@ def _auto_package(mod: dc.Module) -> list[Section]:
43
43
44
44
import griffe .docstrings .dataclasses as ds
45
45
46
+ has_all = "__all__" in mod .members
47
+
48
+ if not has_all :
49
+ print (
50
+ f"\n WARNING: 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
+
46
56
# get module members for content ----
47
57
contents = []
48
58
for name , member in mod .members .items ():
49
59
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
+ ):
51
66
continue
52
67
53
68
contents .append (Auto (name = name ))
54
69
55
70
# 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 = ""
59
77
else :
60
78
desc = ""
61
79
You can’t perform that action at this time.
0 commit comments