updated docs strings and added README.md
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
"""
|
||||
# Summary
|
||||
|
||||
Model layer for doc-forge.
|
||||
|
||||
The ``docforge.models`` package defines the core data structures used to
|
||||
The `docforge.models` package defines the core data structures used to
|
||||
represent Python source code as a structured documentation model.
|
||||
|
||||
---
|
||||
|
||||
Overview
|
||||
--------
|
||||
# Overview
|
||||
|
||||
The model layer forms the central intermediate representation used throughout
|
||||
doc-forge. Python modules and objects discovered during introspection are
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"""
|
||||
# Summary
|
||||
|
||||
Documentation model representing a Python module or package.
|
||||
|
||||
This module defines the ``Module`` class used in the doc-forge documentation
|
||||
model. A ``Module`` acts as a container for top-level documented objects
|
||||
This module defines the `Module` class used in the doc-forge documentation
|
||||
model. A `Module` acts as a container for top-level documented objects
|
||||
(classes, functions, variables, and other members) discovered during
|
||||
introspection.
|
||||
"""
|
||||
@@ -16,15 +18,19 @@ class Module:
|
||||
"""
|
||||
Representation of a documented Python module or package.
|
||||
|
||||
A ``Module`` stores metadata about the module itself and maintains a
|
||||
A `Module` stores metadata about the module itself and maintains a
|
||||
collection of top-level documentation objects discovered during
|
||||
introspection.
|
||||
|
||||
Attributes:
|
||||
path: Dotted import path of the module.
|
||||
docstring: Module-level documentation string, if present.
|
||||
members: Mapping of object names to their corresponding
|
||||
``DocObject`` representations.
|
||||
path (str):
|
||||
Dotted import path of the module.
|
||||
|
||||
docstring (Optional[str]):
|
||||
Module-level documentation string, if present.
|
||||
|
||||
members (Dict[str, DocObject]):
|
||||
Mapping of object names to their corresponding `DocObject` representations.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -36,8 +42,11 @@ class Module:
|
||||
Initialize a Module instance.
|
||||
|
||||
Args:
|
||||
path: Dotted import path identifying the module.
|
||||
docstring: Module-level documentation text, if available.
|
||||
path (str):
|
||||
Dotted import path identifying the module.
|
||||
|
||||
docstring (Optional[str]):
|
||||
Module-level documentation text, if available.
|
||||
"""
|
||||
self.path = path
|
||||
self.docstring = docstring
|
||||
@@ -48,8 +57,8 @@ class Module:
|
||||
Add a documented object to the module.
|
||||
|
||||
Args:
|
||||
obj: Documentation object to register as a top-level
|
||||
member of the module.
|
||||
obj (DocObject):
|
||||
Documentation object to register as a top-level member of the module.
|
||||
"""
|
||||
self.members[obj.name] = obj
|
||||
|
||||
@@ -58,13 +67,16 @@ class Module:
|
||||
Retrieve a documented object by name.
|
||||
|
||||
Args:
|
||||
name: Name of the object to retrieve.
|
||||
name (str):
|
||||
Name of the object to retrieve.
|
||||
|
||||
Returns:
|
||||
The corresponding ``DocObject`` instance.
|
||||
DocObject:
|
||||
The corresponding `DocObject` instance.
|
||||
|
||||
Raises:
|
||||
KeyError: If no object with the given name exists.
|
||||
KeyError:
|
||||
If no object with the given name exists.
|
||||
"""
|
||||
return self.members[name]
|
||||
|
||||
@@ -73,7 +85,7 @@ class Module:
|
||||
Return all top-level documentation objects in the module.
|
||||
|
||||
Returns:
|
||||
An iterable of ``DocObject`` instances representing the
|
||||
module's public members.
|
||||
Iterable[DocObject]:
|
||||
An iterable of `DocObject` instances representing the module's public members.
|
||||
"""
|
||||
return self.members.values()
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"""
|
||||
# Summary
|
||||
|
||||
Documentation model representing individual Python objects.
|
||||
|
||||
This module defines the ``DocObject`` class, the fundamental recursive unit of
|
||||
the doc-forge documentation model. Each ``DocObject`` represents a Python
|
||||
This module defines the `DocObject` class, the fundamental recursive unit of
|
||||
the doc-forge documentation model. Each `DocObject` represents a Python
|
||||
entity such as a class, function, method, or attribute, and may contain nested
|
||||
members that form a hierarchical documentation structure.
|
||||
"""
|
||||
@@ -14,18 +16,28 @@ class DocObject:
|
||||
"""
|
||||
Representation of a documented Python object.
|
||||
|
||||
A ``DocObject`` models a single Python entity discovered during
|
||||
A `DocObject` models a single Python entity discovered during
|
||||
introspection. Objects may contain nested members, allowing the structure
|
||||
of modules, classes, and other containers to be represented recursively.
|
||||
|
||||
Attributes:
|
||||
name: Local name of the object.
|
||||
kind: Type of object (for example ``class``, ``function``,
|
||||
``method``, or ``attribute``).
|
||||
path: Fully qualified dotted path to the object.
|
||||
signature: Callable signature if the object represents a callable.
|
||||
docstring: Raw docstring text extracted from the source code.
|
||||
members: Mapping of member names to child ``DocObject`` instances.
|
||||
name (str):
|
||||
Local name of the object.
|
||||
|
||||
kind (str):
|
||||
Type of object (for example `class`, `function`, `method`, or `attribute`).
|
||||
|
||||
path (str):
|
||||
Fully qualified dotted path to the object.
|
||||
|
||||
signature (Optional[str]):
|
||||
Callable signature if the object represents a callable.
|
||||
|
||||
docstring (Optional[str]):
|
||||
Raw docstring text extracted from the source code.
|
||||
|
||||
members (Dict[str, DocObject]):
|
||||
Mapping of member names to child `DocObject` instances.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -40,11 +52,20 @@ class DocObject:
|
||||
Initialize a DocObject instance.
|
||||
|
||||
Args:
|
||||
name: Local name of the object.
|
||||
kind: Object type identifier (for example ``class`` or ``function``).
|
||||
path: Fully qualified dotted path of the object.
|
||||
signature: Callable signature if applicable.
|
||||
docstring: Documentation string associated with the object.
|
||||
name (str):
|
||||
Local name of the object.
|
||||
|
||||
kind (str):
|
||||
Object type identifier (for example `class` or `function`).
|
||||
|
||||
path (str):
|
||||
Fully qualified dotted path of the object.
|
||||
|
||||
signature (Optional[str]):
|
||||
Callable signature if applicable.
|
||||
|
||||
docstring (Optional[str]):
|
||||
Documentation string associated with the object.
|
||||
"""
|
||||
self.name = name
|
||||
self.kind = kind
|
||||
@@ -70,13 +91,16 @@ class DocObject:
|
||||
Retrieve a member object by name.
|
||||
|
||||
Args:
|
||||
name: Name of the member to retrieve.
|
||||
name (str):
|
||||
Name of the member to retrieve.
|
||||
|
||||
Returns:
|
||||
The corresponding ``DocObject`` instance.
|
||||
DocObject:
|
||||
The corresponding `DocObject` instance.
|
||||
|
||||
Raises:
|
||||
KeyError: If the member does not exist.
|
||||
KeyError:
|
||||
If the member does not exist.
|
||||
"""
|
||||
return self.members[name]
|
||||
|
||||
@@ -85,6 +109,7 @@ class DocObject:
|
||||
Return all child members of the object.
|
||||
|
||||
Returns:
|
||||
An iterable of ``DocObject`` instances representing nested members.
|
||||
Iterable[DocObject]:
|
||||
An iterable of `DocObject` instances representing nested members.
|
||||
"""
|
||||
return self.members.values()
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
"""
|
||||
# Summary
|
||||
|
||||
Documentation model representing a project.
|
||||
|
||||
This module defines the ``Project`` class, the top-level container used by
|
||||
doc-forge to represent a documented codebase. A ``Project`` aggregates multiple
|
||||
This module defines the `Project` class, the top-level container used by
|
||||
doc-forge to represent a documented codebase. A `Project` aggregates multiple
|
||||
modules and provides access to them through a unified interface.
|
||||
"""
|
||||
|
||||
@@ -15,12 +17,15 @@ class Project:
|
||||
"""
|
||||
Representation of a documentation project.
|
||||
|
||||
A ``Project`` serves as the root container for all modules discovered during
|
||||
A `Project` serves as the root container for all modules discovered during
|
||||
introspection. Each module is stored by its dotted import path.
|
||||
|
||||
Attributes:
|
||||
name: Name of the project.
|
||||
modules: Mapping of module paths to ``Module`` instances.
|
||||
name (str):
|
||||
Name of the project.
|
||||
|
||||
modules (Dict[str, Module]):
|
||||
Mapping of module paths to `Module` instances.
|
||||
"""
|
||||
|
||||
def __init__(self, name: str) -> None:
|
||||
@@ -28,7 +33,8 @@ class Project:
|
||||
Initialize a Project instance.
|
||||
|
||||
Args:
|
||||
name: Name used to identify the documentation project.
|
||||
name (str):
|
||||
Name used to identify the documentation project.
|
||||
"""
|
||||
self.name = name
|
||||
self.modules: Dict[str, Module] = {}
|
||||
@@ -38,7 +44,8 @@ class Project:
|
||||
Register a module in the project.
|
||||
|
||||
Args:
|
||||
module: Module instance to add to the project.
|
||||
module (Module):
|
||||
Module instance to add to the project.
|
||||
"""
|
||||
self.modules[module.path] = module
|
||||
|
||||
@@ -47,13 +54,16 @@ class Project:
|
||||
Retrieve a module by its dotted path.
|
||||
|
||||
Args:
|
||||
path: Fully qualified dotted module path (for example ``pkg.module``).
|
||||
path (str):
|
||||
Fully qualified dotted module path (for example `pkg.module`).
|
||||
|
||||
Returns:
|
||||
The corresponding ``Module`` instance.
|
||||
Module:
|
||||
The corresponding `Module` instance.
|
||||
|
||||
Raises:
|
||||
KeyError: If the module does not exist in the project.
|
||||
KeyError:
|
||||
If the module does not exist in the project.
|
||||
"""
|
||||
return self.modules[path]
|
||||
|
||||
@@ -62,7 +72,8 @@ class Project:
|
||||
Return all modules contained in the project.
|
||||
|
||||
Returns:
|
||||
An iterable of ``Module`` instances.
|
||||
Iterable[Module]:
|
||||
An iterable of `Module` instances.
|
||||
"""
|
||||
return self.modules.values()
|
||||
|
||||
@@ -71,6 +82,7 @@ class Project:
|
||||
Return the list of module import paths.
|
||||
|
||||
Returns:
|
||||
A list containing the dotted paths of all modules in the project.
|
||||
list[str]:
|
||||
A list containing the dotted paths of all modules in the project.
|
||||
"""
|
||||
return list(self.modules.keys())
|
||||
Reference in New Issue
Block a user