Skip to content

Commit

Permalink
Merge pull request #234 from machow/fix-auto-package
Browse files Browse the repository at this point in the history
fix: autopackage works with no module docstring
  • Loading branch information
machow authored Aug 7, 2023
2 parents 81ce4c5 + 1a95f48 commit 772feed
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions quartodoc/builder/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,37 @@ def _auto_package(mod: dc.Module) -> list[Section]:

import griffe.docstrings.dataclasses as ds

has_all = "__all__" in mod.members

if not has_all:
print(
f"\nWARNING: the module {mod.name} does not define an __all__ attribute."
" Generating documentation from all members of the module."
" Define __all__ in your package's __init__.py to specify exactly which"
" functions it exports (and should be documented).\n"
)

# get module members for content ----
contents = []
for name, member in mod.members.items():
external_alias = _is_external_alias(member, mod)
if external_alias or member.is_module or name.startswith("__"):
if (
external_alias
or member.is_module
or name.startswith("__")
or (has_all and not mod.member_is_exported(member))
):
continue

contents.append(Auto(name=name))

# try to fetch a description of the module ----
mod_summary = mod.docstring.parsed[0]
if isinstance(mod_summary, ds.DocstringSectionText):
desc = mod_summary.value
if mod.docstring and mod.docstring.parsed:
mod_summary = mod.docstring.parsed[0]
if isinstance(mod_summary, ds.DocstringSectionText):
desc = mod_summary.value
else:
desc = ""
else:
desc = ""

Expand Down

0 comments on commit 772feed

Please sign in to comment.