@@ -360,7 +360,7 @@ def _render_signature(obj) -> str:
360360def _render_function_detailed (func ) -> str :
361361 """Render a function with full docstring details."""
362362 parts = []
363- parts .append (f"### `{ func .__name__ } `\n " )
363+ parts .append (f"## `{ func .__name__ } `\n " )
364364
365365 # Get signature without backticks for code block
366366 try :
@@ -485,10 +485,33 @@ def generate_module_markdown(name: str, mod, add_frontmatter: bool = False) -> s
485485 lines .append ("weight: 10\n " )
486486 lines .append ("---\n \n " )
487487
488+ # Check if this is a stub (failed import)
489+ is_stub = hasattr (mod , "__doc__" ) and mod .__doc__ and "Failed to import" in mod .__doc__
490+ if is_stub :
491+ # Skip generating docs for failed imports - they're not useful
492+ return None
493+
488494 lines .append (f"# `{ name } ` module\n " )
489495 if getattr (mod , "__doc__" , None ):
490496 mod_doc = inspect .cleandoc (mod .__doc__ )
491- lines .append (_md_escape (mod_doc ) + "\n " )
497+ # Preserve markdown lists - ensure proper formatting
498+ # Convert indented lists to proper markdown lists
499+ lines_doc = mod_doc .split ('\n ' )
500+ formatted_lines = []
501+ for i , line in enumerate (lines_doc ):
502+ # If line starts with spaces followed by "- " or "* ", it's a list item
503+ # Remove leading spaces but keep the list marker
504+ stripped = line .lstrip ()
505+ if stripped .startswith (('- ' , '* ' )):
506+ # It's a list item - ensure it's at the start (or after proper context)
507+ formatted_lines .append (stripped )
508+ elif line .strip () and not line .startswith (' ' ):
509+ # Regular line - escape HTML but preserve markdown
510+ formatted_lines .append (line .replace ("<" , "<" ).replace (">" , ">" ))
511+ else :
512+ # Preserve indentation for code blocks and other formatted content
513+ formatted_lines .append (line .replace ("<" , "<" ).replace (">" , ">" ))
514+ lines .append ('\n ' .join (formatted_lines ) + "\n " )
492515
493516 # Functions
494517 funcs = sorted (list (_iter_public_functions (mod )), key = lambda o : o .__name__ )
@@ -533,6 +556,9 @@ def write_all(out_dir: Path | str = "docs/auto", add_frontmatter: bool = False)
533556 written : List [Path ] = []
534557 for name , mod in TARGET_MODULES :
535558 content = generate_module_markdown (name , mod , add_frontmatter = add_frontmatter )
559+ if content is None :
560+ # Skip failed imports
561+ continue
536562 p = out_root / f"{ name } .md"
537563 p .write_text (content , encoding = "utf-8" )
538564 written .append (p )
0 commit comments