Skip to content

Latest commit

 

History

History
142 lines (86 loc) · 2.87 KB

File metadata and controls

142 lines (86 loc) · 2.87 KB

Loader

Loader for python source code.

Handsdown API Index / Handsdown / Loader

Auto-generated documentation for handsdown.loader module.

Loader

Show source in loader.py:18

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

Show source in loader.py:41

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

def _get_output_path(self, source_path: Path) -> Path: ...

Loader().get_import_string

Show source in loader.py:131

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

def get_import_string(self, source_path: Path) -> str: ...

Loader().get_module_record

Show source in loader.py:62

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

def get_module_record(self, source_path: Path) -> ModuleRecord | None: ...

Loader.parse_module_record

Show source in loader.py:114

Parse ModuleRecord children and fully load a tree for it.

Raises

  • LoaderError - If python source cannot be parsed.

Signature

@staticmethod
def parse_module_record(module_record: ModuleRecord) -> None: ...

See also