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
+253
View File
@@ -0,0 +1,253 @@
# Module `jcloud_docsgen.exceptions`
## Class `NamespaceError`
Base class for namespace errors.
### Base classes
- `ValueError`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, *args: object, namespace_identifier: str = '') -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `args` | `object` | vararg | -- | -- |
| `namespace_identifier` | `str` | keyword-only | `''` | -- |
#### Method `__str__`
##### Method signature
```python
__str__(self)
```
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
### Docstring
Base class for namespace errors.
## Class `InvalidNamespaceError`
### Base classes
- `NamespaceError`
## Class `NamespaceNotFoundError`
### Base classes
- `NamespaceError`
## Class `NamespaceExistsError`
### Base classes
- `NamespaceError`
## Class `PythonIdentifierError`
Base class for Python identifier errors.
### Base classes
- `ValueError`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, *args: object, identifier: str = '') -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `args` | `object` | vararg | -- | -- |
| `identifier` | `str` | keyword-only | `''` | -- |
#### Method `__str__`
##### Method signature
```python
__str__(self)
```
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
### Docstring
Base class for Python identifier errors.
## Class `InvalidPythonIdentifierError`
### Base classes
- `PythonIdentifierError`
## Class `PythonAnnotationError`
Base class for Python annotation errors.
### Base classes
- `ValueError`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, *args: object, annotation: str = '') -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `args` | `object` | vararg | -- | -- |
| `annotation` | `str` | keyword-only | `''` | -- |
#### Method `__str__`
##### Method signature
```python
__str__(self)
```
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
### Docstring
Base class for Python annotation errors.
## Class `InvalidPythonAnnotationError`
### Base classes
- `PythonAnnotationError`
## Class `PythonDefinitionError`
Base class for Python definition errors.
### Base classes
- `ValueError`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, *args: object, definition: str = '') -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `args` | `object` | vararg | -- | -- |
| `definition` | `str` | keyword-only | `''` | -- |
#### Method `__str__`
##### Method signature
```python
__str__(self)
```
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
### Docstring
Base class for Python definition errors.
## Class `PythonArgumentStructureError`
### Base classes
- `PythonDefinitionError`
+335
View File
@@ -0,0 +1,335 @@
# Module `jcloud_docsgen.utils`
The utilities for jcloud_docsgen
## Class `ExistingDirectory`
pathlib.Path subclass that is a directory.
ExistingDirectory represents a filesystem path but it also checks
whether the path exists and is not a file but a directory. It
inherits from pathlib.Path.
### Base classes
- `pathlib.Path`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, path, *args, **kwargs) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `path` | -- | normal | -- | -- |
| `args` | -- | vararg | -- | -- |
| `kwargs` | -- | kwargs | -- | -- |
### Docstring
pathlib.Path subclass that is a directory.
ExistingDirectory represents a filesystem path but it also checks
whether the path exists and is not a file but a directory. It
inherits from pathlib.Path.
## Class `ExistingFile`
pathlib.Path subclass that is a file.
ExistingFile represents a filesystem path but it also checks whether
the path exists and is not a directory but a file. It inherits from
pathlib.Path.
### Base classes
- `pathlib.Path`
### Body
#### Constructor (method `__init__`)
##### Method signature
```python
__init__(self, path, *args, **kwargs) -> None
```
##### Returns
Return type: `None`
##### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `self` | -- | normal | -- | -- |
| `path` | -- | normal | -- | -- |
| `args` | -- | vararg | -- | -- |
| `kwargs` | -- | kwargs | -- | -- |
### Docstring
pathlib.Path subclass that is a file.
ExistingFile represents a filesystem path but it also checks whether
the path exists and is not a directory but a file. It inherits from
pathlib.Path.
## Function `_quote`
Quotes a string.
### Function signature
```python
_quote(string: str, quotation_mark: str) -> str
```
### Returns
The quoted string
Return type: `str`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `string` | `str` | normal | -- | The string to quote |
| `quotation_mark` | `str` | normal | -- | The quotation mark |
### Docstring
Quotes a string.
:param string: The string to quote
:type string: str
:param quotation_mark: The quotation mark
:type quotation_mark: str
:return: The quoted string
:rtype: str
## Function `human_readable_list`
Generates a human-readable list from a list.
### Function signature
```python
human_readable_list(ls: list, final_separator: str = 'and', quotation_mark: str = '') -> str
```
### Returns
The human-readable list.
Return type: `str`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `ls` | `list` | normal | -- | The list. |
| `final_separator` | `str` | normal | `'and'` | The seperator between the last and the second-to-last element of the list. Default is 'and'. |
| `quotation_mark` | `str` | normal | `''` | The characters that are inserted before and after an element. Default is ''. |
### Docstring
Generates a human-readable list from a list.
:param ls: The list.
:type ls: list
:param final_separator: The seperator between the last and the
second-to-last element of the list. Default
is 'and'.
:type final_separator: str
:param quotation_mark: The characters that are inserted before and
after an element. Default is ''.
:return: The human-readable list.
:rtype: str
## Function `_list_type_names`
Converts a list of types into a list of their names (``__name__``
attribute)
### Function signature
```python
_list_type_names(types: list[type]) -> list[str]
```
### Returns
The list of the names of the types
Return type: `list[str]`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `types` | `list[type]` | normal | -- | The list of types |
### Docstring
Converts a list of types into a list of their names (``__name__``
attribute)
:param types: The list of types
:type types: list[type]
:return: The list of the names of the types
:rtype: list[str]
## Function `assert_that_is_instance`
### Function signature
```python
assert_that_is_instance(obj: object, class_or_tuple: Union[type, types.UnionType, tuple[type, ...]]) -> None
```
### Returns
Return type: `None`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `obj` | `object` | normal | -- | -- |
| `class_or_tuple` | `Union[type, types.UnionType, tuple[type, ...]]` | normal | -- | -- |
## Function `non_empty_str`
Returns the value or ``None``.
Returns the value if it is not empty and not `Ǹone``; otherwise,
returns ``None``.
Please note: values are stripped, i. e. if the value consists only
of spaces, it is also considered empty.
### Function signature
```python
non_empty_str(value: Union[str, None]) -> Union[str, None]
```
### Returns
The value or ``None``.
Return type: `Union[str, None]`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `value` | `Union[str, None]` | normal | -- | The value. |
### Docstring
Returns the value or ``None``.
Returns the value if it is not empty and not `Ǹone``; otherwise,
returns ``None``.
Please note: values are stripped, i. e. if the value consists only
of spaces, it is also considered empty.
:param value: The value.
:type value: Union[str, None]
:return: The value or ``None``.
:rtype: Union[str, None]
## Function `get_relative_path_segments`
Returns the path segments relative to ``root``.
### Function signature
```python
get_relative_path_segments(path: pathlib.Path, root: pathlib.Path) -> list[str]
```
### Returns
The path segments relative to ``root``.
Return type: `list[str]`
### Parameters
| Parameter | Type | Kind | Default value | Description |
| --- | --- | --- | --- | --- |
| `path` | `pathlib.Path` | normal | -- | The path. |
| `root` | `pathlib.Path` | normal | -- | The root path. |
### Docstring
Returns the path segments relative to ``root``.
:param path: The path.
:type path: pathlib.Path
:param root: The root path.
:type root: pathlib.Path
:return: The path segments relative to ``root``.
:rtype: list[str]