Skip to content

Commit

Permalink
feat: Discover package submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 6, 2020
1 parent 2f0bfaa commit 231062a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mkdocstrings/documenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def my_function(param1: int, param2: Optional[str] = None) -> typing.Dict[int, s
import importlib
import inspect
import os
import pkgutil
import re
import textwrap
from functools import lru_cache
Expand Down Expand Up @@ -322,6 +323,16 @@ def get_module_documentation(self, module: ModuleType) -> Module:
root_object.add_child(self.get_class_documentation(member, module))
elif inspect.isfunction(member) and inspect.getmodule(member) == module:
root_object.add_child(self.get_function_documentation(member, module))

try:
package_path = module.__path__
except AttributeError:
pass
else:
for _, modname, _ in pkgutil.iter_modules(package_path):
parent, submodule = import_object(f"{name}.{modname}")
root_object.add_child(self.get_module_documentation(submodule))

return root_object

def get_class_documentation(self, class_: Type[Any], module: Optional[ModuleType] = None) -> Class:
Expand Down

0 comments on commit 231062a

Please sign in to comment.