Loader
Loader for python source code.
Handsdown API Index / Handsdown / Loader
Auto-generated documentation for handsdown.loader module.
Loader
Loader for python source code.
Examples
loader = Loader(Path('path/to/my_module/'))
my_module_utils = loader.import_module('my_module.utils')
Arguments
root_path- Root path of the project.output_path- Docs output path.encoding- File encoding.
Signature
class Loader:
def __init__(
self, root_path: Path, output_path: Path, encoding: str = ENCODING
) -> None:
...
See also
Loader()._get_output_path
Get output MD document path based on source_path.
Arguments
source_path- Path to source code file.
Returns
A path to the output .md file even if it does not exist yet.
Signature
Loader().get_import_string
Get Python import string for a source source_path relative to root_path.
Examples
loader = Loader(root_path=Path("/root"), ...)
loader.get_import_string('/root/my_module/test.py')
'my_module.test'
loader.get_import_string('/root/my_module/__init__.py')
'my_module'
Arguments
source_path- Path to a source file.
Returns
A Python import string.
Signature
Loader().get_module_record
Build ModuleRecord for given source_path.
Arguments
source_path- Absolute path to source file.
Returns
A new ModuleRecord instance or None if there is ntohing to import.
Raises
LoaderError- If python source cannot be loaded.
Signature
See also
Loader.parse_module_record
Parse ModuleRecord children and fully load a tree for it.
Raises
LoaderError- If python source cannot be parsed.