unitelabs.jsondocs.extract
Attributes
- Name
GriffeObjType
- Type
- Value
= typing.Union[griffe.Object, griffe.Class, griffe.Function, griffe.Module, griffe.Attribute]
- Description
- Name
DOCUMENTATION_TYPE_MAP
- Type
- Value
= {'package': DocumentedPackage, 'class': DocumentedClass, 'function': DocumentedFunction, 'attribute': DocumentedAttribute}
- Description
Functions
get_semver(version_str : str) -> str
For a distribution or build version string build the semver version string.
Parameters
- Name
version_str
- Type
- str
- Default
- Description
Response
- Type
- str
- Description
get_docstring(obj : GriffeObjType, kind : str) -> typing.Optional[str]
Extract a `griffe.DocstringSection` of a given `kind`s parsed value.
Parameters
- Name
obj
- Type
- GriffeObjType
- Default
- Description
The `griffe.Object` to extract the `griffe.DocstringSection` from.
- Name
kind
- Type
- str
- Default
- Description
The kind of `griffe.DocstringSection` to extract. Valid values are `text`, `parameters`, `returns`, `raises`, and `examples`.
Response
- Type
- typing.Optional[str]
- Description
load_package(package_name : str, package : typing.Optional[str]) -> dict[str, typing.Any]
For a given an importable `package_name`, (as specified by `importlib.import_module`) parse the google-style documentation as a JSON string.
Parameters
- Name
package_name
- Type
- str
- Default
- Description
The name of the package/module to extract documentation from, or a relative path to a package/module, which requires `package` to also be set.
- Name
package
- Type
- typing.Optional[str]
- Default
- = None
- Description
The import name of the package in the form of `package_name`, for use with relative paths.
Response
- Type
- dict[str, typing.Any]
- Description
A JSON string of the documentation.
write_package_json(
- package_name : str,
- outpath : typing.Optional[pathlib.Path],
- package : typing.Optional[str]
Write a JSON file of the documentation for the given `package_name`. Requires the package to be available on `sys.path`, i.e. installed in local environment.
Parameters
- Name
package_name
- Type
- str
- Default
- Description
The name of the package or the dot-separated import path (also the case for namespaced packages), to the module to extract documentation from, or a relative path to a package/module, which requires `package` to also be set.
- Name
outpath
- Type
- typing.Optional[pathlib.Path]
- Default
- = None
- Description
The desired path of the JSON output file, defaults to directory in which this is run, using the distribution name.
- Name
package
- Type
- typing.Optional[str]
- Default
- = None
- Description
The name of the package in the form of `package_name`, for use with relative paths.
Classes
DataExtractor
Holds parameter information for mapping between a class and its `__init__` function.
Methods
__init__(self) -> None
flatten(
- self,
- obj,
- flattened_data : dict[str, typing.Any]
Parameters
- Name
self
- Type
- Default
- Description
- Name
obj
- Type
- Default
- Description
- Name
flattened_data
- Type
- dict[str, typing.Any]
- Default
- Description
Response
- Type
- dict[str, typing.Any]
- Description
extract_data(self, obj : GriffeObjType) -> typing.Optional[DocumentedItem]
Parameters
- Name
self
- Type
- Default
- Description
- Name
obj
- Type
- GriffeObjType
- Default
- Description
Response
- Type
- typing.Optional[DocumentedItem]
- Description
get_modules(self, obj : typing.Union[griffe.Object, griffe.Alias]) -> dict[str, typing.Any]
Parameters
- Name
self
- Type
- Default
- Description
- Name
obj
- Type
- typing.Union[griffe.Object, griffe.Alias]
- Default
- Description
Response
- Type
- dict[str, typing.Any]
- Description
Attributes
- Name
parameter_map
- Type
- Value
= {}
- Description