Add API reference

This commit is contained in:
2026-04-27 22:43:26 +02:00
parent 55c4c74ee8
commit 81b2be7efc
7 changed files with 3111 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,205 @@
# Module `jcloud_docsgen.core.python.arguments`
## Class `PythonArgumentKind`
### Base classes
- `Enum`
## Class `PythonFunctionArgument`
Represents an argument of a Python function.
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str, kind: PythonArgumentKind, default: Union[str, None], annotation: Union[str, None]) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
| `kind` | `PythonArgumentKind` | normal | -- | -- |
| `default` | `Union[str, None]` | normal | -- | -- |
| `annotation` | `Union[str, None]` | normal | -- | -- |
#### Method `__eq__`
##### Method signature
```python
__eq__(self, value: PythonFunctionArgument) -> bool
```
##### Returns
Return type: `bool`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `value` | `PythonFunctionArgument` | normal | -- | -- |
#### Method `__repr__`
##### Method signature
```python
__repr__(self) -> str
```
##### Returns
Return type: `str`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `signature_repr`
Returns the function signature representation of the argument.
##### Method signature
```python
signature_repr(self) -> str
```
##### Returns
The string representation of the argument.
Return type: `str`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
##### Docstring
Returns the function signature representation of the argument.
:return: The string representation of the argument.
:rtype: str
### Docstring
Represents an argument of a Python function.
:param name: The name of the argument.
:type name: str
:param kind: The kind of the argument.
:type kind: ArgumentKind
:param default: The default value of the argument.
:type default: Union[str, None]
:param annotation: The type annotation of the argument.
:type annotation: Union[str, None]
## Class `PythonASTArgumentsListParser`
A parser for making ``PythonFunctionArgument`` objects from an
``ast.arguments`` arguments list.
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, ast_arguments_list: ast.arguments) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `ast_arguments_list` | `ast.arguments` | normal | -- | -- |
#### Method `to_argument_list`
Converts the AST arguments list to a list of Python function
argument objects.
##### Method signature
```python
to_argument_list(self) -> list[PythonFunctionArgument]
```
##### Returns
The list of Python function argument objects.
Return type: `list[PythonFunctionArgument]`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
##### Docstring
Converts the AST arguments list to a list of Python function
argument objects.
:return: The list of Python function argument objects.
:rtype: list[PythonFunctionArgument]
### Docstring
A parser for making ``PythonFunctionArgument`` objects from an
``ast.arguments`` arguments list.
:param ast_arguments_list: The ``ast.arguments`` arguments list.
:type ast_arguments_list: ast.arguments
@@ -0,0 +1,445 @@
# Module `jcloud_docsgen.core.python.definitions`
## Function `_python_docstring`
Returns the PythonDocstring object if the docstring is a string and
not ``None``.
### Function signature
```python
_python_docstring(doc: Union[str, None]) -> Union[PythonDocstring, None]
```
### Returns
The PythonDocstring object or ``None``.
Return type: `Union[PythonDocstring, None]`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `doc` | `Union[str, None]` | normal | -- | The docstring. |
### Docstring
Returns the PythonDocstring object if the docstring is a string and
not ``None``.
:param doc: The docstring.
:type doc: Union[str, None]
:return: The PythonDocstring object or ``None``.
:rtype: Union[PythonDocstring, None]
## Class `PythonDefinition`
A base class for Python definition (a class, function or asynchronous
function definition) classes.
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str, doc: Union[PythonDocstring, None], decorators: list[str]) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
| `doc` | `Union[PythonDocstring, None]` | normal | -- | -- |
| `decorators` | `list[str]` | normal | -- | -- |
#### Method `_arg_list`
##### Method signature
```python
_arg_list(self) -> tuple
```
##### Returns
Return type: `tuple`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `__repr__`
##### Method signature
```python
__repr__(self) -> str
```
##### Returns
Return type: `str`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `from_node`
From an AST node.
##### Method signature
```python
from_node(cls, node: ast.stmt) -> PythonDefinition
```
##### Returns
Return type: `PythonDefinition`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `cls` | -- | normal | -- | -- |
| `node` | `ast.stmt` | normal | -- | The AST node. |
##### Decorators
```python
classmethod
```
##### Docstring
From an AST node.
:param node: The AST node.
:type node: ast.stmt
#### Method `__eq__`
##### Method signature
```python
__eq__(self, value: object) -> bool
```
##### Returns
Return type: `bool`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `value` | `object` | normal | -- | -- |
### Docstring
A base class for Python definition (a class, function or asynchronous
function definition) classes.
:param name: The name of the definition.
:type name: str
:param doc: The docstring.
:type doc: Union[PythonDocstring, None]
:param decorators: The definition decorators.
:type decorators: list[str]
:raises InvalidPythonIdentifierError: If the name is not a valid
Python identifier.
## Class `PythonFunctionDefinition`
A PythonDefinition subclass representing a Python function
definition.
### Base classes
- `PythonDefinition`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str, args: list[PythonFunctionArgument], returns: Union[str, None], doc: Union[PythonDocstring, None], decorators: list[str]) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
| `args` | `list[PythonFunctionArgument]` | normal | -- | -- |
| `returns` | `Union[str, None]` | normal | -- | -- |
| `doc` | `Union[PythonDocstring, None]` | normal | -- | -- |
| `decorators` | `list[str]` | normal | -- | -- |
#### Method `_arg_list`
##### Method signature
```python
_arg_list(self) -> tuple
```
##### Returns
Return type: `tuple`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `from_node`
From an AST node.
##### Method signature
```python
from_node(cls, node: ast.stmt) -> PythonFunctionDefinition
```
##### Returns
Return type: `PythonFunctionDefinition`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `cls` | -- | normal | -- | -- |
| `node` | `ast.stmt` | normal | -- | The AST node. |
##### Decorators
```python
classmethod
```
##### Docstring
From an AST node.
:param node: The AST node.
:type node: ast.stmt
### Docstring
A PythonDefinition subclass representing a Python function
definition.
:param name: The name of the definition.
:type name: str
:param args: The arguments.
:type args: list[PythonFunctionArgument]
:param returns: The return type of the function or class.
:type returns: Union[str, None]
:param doc: The docstring.
:type doc: Union[PythonDocstring, None]
:param decorators: The definition decorators.
:type decorators: list[str]
:raises InvalidPythonIdentifierError: If the name is not a valid
Python identifier.
## Class `PythonAsyncFunctionDefinition`
A PythonDefinition subclass representing an asynchronous Python function
definition.
### Base classes
- `PythonFunctionDefinition`
### Docstring
A PythonDefinition subclass representing an asynchronous Python function
definition.
:param name: The name of the definition.
:type name: str
:param args: The arguments.
:type args: list[PythonFunctionArgument]
:param returns: The return type of the function or class.
:type returns: Union[str, None]
:param doc: The docstring.
:type doc: Union[PythonDocstring, None]
:param decorators: The definition decorators.
:type decorators: list[str]
:raises InvalidPythonIdentifierError: If the name is not a valid
Python identifier.
## Class `PythonClassDefinition`
A PythonDefinition subclass representing a Python class definition.
### Base classes
- `PythonDefinition`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str, bases: list[str], doc: Union[PythonDocstring, None], decorators: list[str], body: list[PythonDefinition]) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
| `bases` | `list[str]` | normal | -- | -- |
| `doc` | `Union[PythonDocstring, None]` | normal | -- | -- |
| `decorators` | `list[str]` | normal | -- | -- |
| `body` | `list[PythonDefinition]` | normal | -- | -- |
#### Method `_arg_list`
##### Method signature
```python
_arg_list(self) -> tuple
```
##### Returns
Return type: `tuple`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `from_node`
From an AST node.
##### Method signature
```python
from_node(cls, node: ast.stmt) -> PythonClassDefinition
```
##### Returns
Return type: `PythonClassDefinition`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `cls` | -- | normal | -- | -- |
| `node` | `ast.stmt` | normal | -- | The AST node. |
##### Decorators
```python
classmethod
```
##### Docstring
From an AST node.
:param node: The AST node.
:type node: ast.stmt
### Docstring
A PythonDefinition subclass representing a Python class definition.
:param name: The name of the definition.
:type name: str
:param bases: The base classes.
:type bases: list[str]
:param doc: The docstring.
:type doc: Union[PythonDocstring, None]
:param decorators: The definition decorators.
:type decorators: list[str]
:param body:
:type body: list[PythonDefinition]
:raises InvalidPythonIdentifierError: If the name is not a valid
Python identifier.
@@ -0,0 +1,113 @@
# Module `jcloud_docsgen.core.python.docstrings`
## Class `PythonDocstring`
Represents a Python docstring.
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, docstring: str) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `docstring` | `str` | normal | -- | -- |
#### Method `__repr__`
##### Method signature
```python
__repr__(self) -> str
```
##### Returns
Return type: `str`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `__eq__`
##### Method signature
```python
__eq__(self, value) -> bool
```
##### Returns
Return type: `bool`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `value` | -- | normal | -- | -- |
#### Method `parse`
Parses the docstring.
##### Method signature
```python
parse(self) -> docstring_parser.Docstring
```
##### Returns
The parsed docstring.
Return type: `docstring_parser.Docstring`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
##### Docstring
Parses the docstring.
:return: The parsed docstring.
:rtype: docstring_parser.Docstring
### Docstring
Represents a Python docstring.
:param docstring: The docstring as a string.
:type docstring: str
@@ -0,0 +1,442 @@
# Module `jcloud_docsgen.core.python.namespaces`
## Class `PythonNamespace`
The base class for all Python namespaces such as modules or packages.
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
#### Method `__repr__`
##### Method signature
```python
__repr__(self) -> str
```
##### Returns
Return type: `str`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
### Docstring
The base class for all Python namespaces such as modules or packages.
:param name: The name of the namespace.
:type name: str
## Class `PythonPackageNamespace`
A subclass of ``PythonNamespace`` for Python package namespaces.
### Base classes
- `PythonNamespace`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str, sub_namespaces: List[PythonNamespace]) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
| `sub_namespaces` | `List[PythonNamespace]` | normal | -- | -- |
#### Method `namespace`
Returns the namespace object with a specific identifier, such as
``['package', 'subpackage', 'module']``.
##### Method signature
```python
namespace(self, sub_namespaces: List[str]) -> PythonNamespace
```
##### Returns
The namespace.
Return type: `PythonNamespace`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `sub_namespaces` | `List[str]` | normal | -- | The identifier of the namespace. |
##### Exceptions
| Exception | Description |
| --- | --- |
| `InvalidNamespaceError` | If the namespace identifier is invalid. |
| `NamespaceNotFoundError` | If the namespace does not exist. |
##### Docstring
Returns the namespace object with a specific identifier, such as
``['package', 'subpackage', 'module']``.
:param sub_namespaces: The identifier of the namespace.
:type sub_namespaces: list[str]
:raises InvalidNamespaceError: If the namespace identifier is
invalid.
:raises NamespaceNotFoundError: If the namespace does not exist.
:return: The namespace.
:rtype: PythonNamespace
#### Method `_sub_namespaces_names`
Returns the names of all sub-namespaces of the specified package
namespace and keeps the package structure.
##### Method signature
```python
_sub_namespaces_names(self, package: PythonPackageNamespace) -> PythonPackageNamespaceDictType
```
##### Returns
The names if all sub-namespaces.
Return type: `PythonPackageNamespaceDictType`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `package` | `PythonPackageNamespace` | normal | -- | The package. |
##### Docstring
Returns the names of all sub-namespaces of the specified package
namespace and keeps the package structure.
:param package: The package.
:type package: PythonPackageNamespace
:return: The names if all sub-namespaces.
:rtype: PythonPackageNamespaceDictType
#### Method `sub_namespace_names`
Returns the names of all sub-namespaces and keeps the package
structure.
##### Method signature
```python
sub_namespace_names(self) -> PythonPackageNamespaceDictType
```
##### Returns
The names if all sub-namespaces.
Return type: `PythonPackageNamespaceDictType`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
##### Docstring
Returns the names of all sub-namespaces and keeps the package
structure.
:return: The names if all sub-namespaces.
:rtype: PythonPackageNamespaceDictType
#### Method `__eq__`
##### Method signature
```python
__eq__(self, value: PythonPackageNamespace) -> bool
```
##### Returns
Return type: `bool`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `value` | `PythonPackageNamespace` | normal | -- | -- |
#### Method `__repr__`
##### Method signature
```python
__repr__(self) -> str
```
##### Returns
Return type: `str`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
#### Method `__getitem__`
Returns a namespace with the specified name.
##### Method signature
```python
__getitem__(self, name: str) -> PythonNamespace
```
##### Returns
The namespace
Return type: `PythonNamespace`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | The name of the namespace |
##### Exceptions
| Exception | Description |
| --- | --- |
| `NamespaceNotFoundError` | If the namespace does not exist. |
##### Docstring
Returns a namespace with the specified name.
:param name: The name of the namespace
:type name: str
:raises NamespaceNotFoundError: If the namespace does not exist.
:return: The namespace
:rtype: PythonNamespace
#### Method `add`
Adds a namespace.
##### Method signature
```python
add(self, namespace: PythonNamespace) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `namespace` | `PythonNamespace` | normal | -- | The namespace to add. |
##### Exceptions
| Exception | Description |
| --- | --- |
| `NamespaceExistsError` | If a namespace with the name of the namespace that is attempted to add already exists. |
##### Docstring
Adds a namespace.
:param namespace: The namespace to add.
:type namespace: PythonNamespace
:raises NamespaceExistsError: If a namespace with the name of the
namespace that is attempted to add
already exists.
#### Method `sub_namespaces`
##### Method signature
```python
sub_namespaces(self) -> List[PythonNamespace]
```
##### Returns
Return type: `List[PythonNamespace]`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
##### Decorators
```python
property
```
### Docstring
A subclass of ``PythonNamespace`` for Python package namespaces.
:param name: The name of the namespace.
:type name: str
:param sub_namespaces: The sub-namespaces.
:type sub_namespaces: list[PythonNamespace]
## Class `PythonModuleNamespace`
A subclass of ``PythonNamespace`` for Python module namespaces.
### Base classes
- `PythonNamespace`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, name: str) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `name` | `str` | normal | -- | -- |
#### Method `__eq__`
##### Method signature
```python
__eq__(self, value: PythonModuleNamespace) -> bool
```
##### Returns
Return type: `bool`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `value` | `PythonModuleNamespace` | normal | -- | -- |
### Docstring
A subclass of ``PythonNamespace`` for Python module namespaces.
:param name: The name of the namespace.
:type name: str