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