Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman committed Jan 16, 2024
1 parent f1f284c commit 6ffd38a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions sphinx_automodapi/automodapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
objects warnings.
* ``:sort:``
Sort the objects in the module alphabetically. The default is to
sort by the order they appear in the module (as specified by `__all__`
or `dir`).
If the module contains ``__all__``, sort the module's objects
alphabetically (if ``__all__`` is not present, the objects are found
using `dir`, which always gives a sorted list).
This extension also adds four sphinx configuration options:
Expand Down
9 changes: 5 additions & 4 deletions sphinx_automodapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ def find_mod_objs(modname, onlylocals=False, sort=False):
# define their own __getattr__ and __dir__.
if hasattr(mod, '__all__'):
pkgitems = [(k, getattr(mod, k)) for k in mod.__all__]
else:
pkgitems = [(k, getattr(mod, k)) for k in dir(mod) if k[0] != '_']
# Optionally sort the items alphabetically
if sort:
pkgitems.sort()

if sort:
pkgitems.sort()
else:
pkgitems = [(k, getattr(mod, k)) for k in dir(mod) if k[0] != "_"]

# filter out modules and pull the names and objs out
ismodule = inspect.ismodule
Expand Down

0 comments on commit 6ffd38a

Please sign in to comment.