Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lazydocs/_about.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Information about this library. This file will automatically changed."""

__version__ = "0.5.1"
__version__ = "0.5.2"
# __author__
# __email__
39 changes: 26 additions & 13 deletions src/lazydocs/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def to_md_file(
return

md_file = filename

if is_mdx:
if not filename.endswith(".mdx"):
md_file = filename + ".mdx"
Expand Down Expand Up @@ -429,13 +429,16 @@ def _doc2md(obj: Any) -> str:
argindent = indent
elif arg_list and not literal_block and _RE_ARGSTART.match(line):
# start of an exception-type block
out.append(
"\n"
+ " " * blockindent
+ " - "
+ _RE_ARGSTART.sub(r"<b>`\1`</b>: \2", line)
)
argindent = indent
if indent > argindent:
out.append(" " + line)
else:
out.append(
"\n"
+ " " * blockindent
+ " - "
+ _RE_ARGSTART.sub(r"<b>`\1`</b>: \2", line)
)
argindent = indent
elif indent > argindent:
# attach docs text of argument
# * (blockindent + 2)
Expand Down Expand Up @@ -614,7 +617,7 @@ def func2md(self, func: Callable, clsname: str = "", depth: int = 3, is_mdx: boo
if path:
if is_mdx:
markdown = _MDX_SOURCE_BADGE_TEMPLATE.format(path=path) + markdown
else:
else:
markdown = _SOURCE_BADGE_TEMPLATE.format(path=path) + markdown

return markdown
Expand Down Expand Up @@ -998,8 +1001,13 @@ def generate_docs(
continue

try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
mod_spec.loader.exec_module(mod)
except AttributeError:
# For older python version compatibility
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
module_md = generator.module2md(mod, is_mdx=is_mdx)
if not module_md:
# Module md is empty -> ignore module and all submodules
Expand Down Expand Up @@ -1077,8 +1085,13 @@ def generate_docs(
continue

try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
mod_spec.loader.exec_module(mod)
except AttributeError:
# For older python version compatibility
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
module_md = generator.module2md(mod, is_mdx=is_mdx)

if not module_md:
Expand Down
Loading