Object
docforge.models.object
This module defines the DocObject class, the fundamental recursive unit of the doc-forge documentation models. A DocObject represents a single Python entity (class, function, method, or attribute) and its nested members.
DocObject
DocObject(name: str, kind: str, path: str, signature: Optional[str] = None, docstring: Optional[str] = None)
Represents a documented Python object (class, function, method, etc.).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Local name of the object. |
kind |
str
|
Type of object (e.g., 'class', 'function', 'attribute'). |
path |
str
|
Full dotted import path to the object. |
signature |
Optional[str]
|
Callable signature, if applicable. |
docstring |
Optional[str]
|
Raw docstring content extracted from the source. |
members |
Dict[str, DocObject]
|
Dictionary mapping member names to their DocObject representations. |
Initialize a new DocObject.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The local name of the object. |
required |
kind |
str
|
The kind of object (e.g., 'class', 'function'). |
required |
path |
str
|
The full dotted path to the object. |
required |
signature |
Optional[str]
|
The object's signature (for callable objects). |
None
|
docstring |
Optional[str]
|
The object's docstring, if any. |
None
|
add_member
add_member(obj: DocObject) -> None
Add a child member to this object (e.g., a method to a class).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj |
DocObject
|
The child DocObject to add. |
required |
get_all_members
get_all_members() -> Iterable[DocObject]
Get all members of this object.
Returns:
| Type | Description |
|---|---|
Iterable[DocObject]
|
An iterable of child DocObject instances. |
get_member
get_member(name: str) -> DocObject
Retrieve a child member by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the member. |
required |
Returns:
| Type | Description |
|---|---|
DocObject
|
The requested DocObject. |