doc changes

This commit is contained in:
2026-01-21 17:36:08 +05:30
parent e33133cb0e
commit 15c59ab274
13 changed files with 110 additions and 36 deletions

View File

@@ -134,6 +134,15 @@ class GriffeLoader:
# -------------------------
def _convert_module(self, obj: Object) -> Module:
"""
Convert a Griffe Object (module) into a docforge Module.
Args:
obj: The Griffe Object representing the module.
Returns:
A populated Module instance.
"""
module = Module(
path=obj.path,
docstring=self._safe_docstring(obj),
@@ -148,6 +157,15 @@ class GriffeLoader:
return module
def _convert_object(self, obj: Object) -> DocObject:
"""
Recursively convert a Griffe Object into a DocObject hierarchy.
Args:
obj: The Griffe Object to convert.
Returns:
A DocObject instance.
"""
kind = obj.kind.value
signature = self._safe_signature(obj)
@@ -174,12 +192,30 @@ class GriffeLoader:
# -------------------------
def _safe_docstring(self, obj: Object) -> Optional[str]:
"""
Safely retrieve the docstring value from a Griffe object.
Args:
obj: The Griffe Object to inspect.
Returns:
The raw docstring string, or None if missing or unresolvable.
"""
try:
return obj.docstring.value if obj.docstring else None
except AliasResolutionError:
return None
def _safe_signature(self, obj: Object) -> Optional[str]:
"""
Safely retrieve the signature string from a Griffe object.
Args:
obj: The Griffe Object to inspect.
Returns:
The string representation of the signature, or None.
"""
try:
if hasattr(obj, "signature") and obj.signature:
return str(obj.signature)