selfdoc v0.15.1 /selfdoc.resolver
On this page

Resolver factory module that creates a three-level dispatch chain: content directives, custom script directives, then language-specific extractors.

#selfdoc.resolver

#selfdoc.resolver

Resolver factory -- dispatches directives to language-specific extractors.

#_load_custom_directive

python
def _load_custom_directive(script_path, name)

Dynamically import a custom directive script and return its module.

Args:

  • script_path: Absolute path to the Python script.
  • name: Directive name (used as the module name for importlib).

Returns:

  • The loaded module, or None if loading fails.

Raises:

  • FileNotFoundError: If the script file does not exist.
  • AttributeError: If the module has no 'resolve' callable.
  • Exception: Any other import/load error.

#Resolver

Multi-language directive resolver.

Groups source entries by (language, extractor) and dispatches each directive to the correct language extractor based on path resolution. Tracks the last matched source entry for downstream consumers.

#__call__

python
def __call__(self, name, attrs, body) -> str

Resolve a directive by name, attributes, and body.

Tries content directives first (language-agnostic), then custom directives, then dispatches to language extractors. For multi- language projects, resolves which language group matches the directive's path argument and errors on ambiguity.

#make_resolver

python
def make_resolver(config, base_dir='.')

Create a resolver callable for the project.

Returns a Resolver instance (callable) that dispatches directives to language-specific extractors. The returned object also exposes last_source_entry for tracking which source entry matched.

Args:

  • config: Validated config dict from selfdoc.json.
  • base_dir: Project root directory (for resolving relative paths).

Returns:

  • A Resolver instance (callable(name, attrs, body) -> str).