YAML Import/Export#

Batch import and export of documents and items in YAML format.

jamb.yaml_io.export_to_yaml(output_path, prefixes=None, root=None)[source]#

Export document tree to YAML file.

Parameters:
  • output_path (Path) – Path to write YAML file.

  • prefixes (list[str] | None) – Optional list of document prefixes to export.

  • root (Path | None) – Optional project root directory.

Return type:

None

jamb.yaml_io.export_items_to_yaml(output_path, item_uids, include_neighbors=False, prefixes=None, root=None)[source]#

Export specific items (and optionally their neighbors) to YAML file.

Parameters:
  • output_path (Path) – Path to write YAML file.

  • item_uids (list[str]) – List of item UIDs to export.

  • include_neighbors (bool) – If True, include ancestors and descendants.

  • prefixes (list[str] | None) – Optional list of document prefixes to filter by.

  • root (Path | None) – Optional project root directory.

Return type:

None

jamb.yaml_io.import_from_yaml(path, dry_run=False, update=False, verbose=False, echo=None)[source]#

Import documents and items from YAML file.

Parameters:
  • path (Path) – Path to YAML file.

  • dry_run (bool) – If True, don’t make changes, just report what would happen.

  • update (bool) – If True, update existing items instead of skipping them.

  • verbose (bool) – If True, print verbose output.

  • echo (Callable[[str], object] | None) – Optional function for output (defaults to print).

Returns:

{‘documents_created’, ‘items_created’,

’items_updated’, ‘skipped’}

Return type:

Dict with counts

jamb.yaml_io.load_import_file(path, echo=None)[source]#

Load and validate YAML import file.

Parameters:
  • path (Path) – Path to YAML file.

  • echo (Callable[[str], object] | None) – Optional callable for warning output (e.g., print or click.echo).

Returns:

dict[str, Any] – Dict with ‘documents’ and ‘items’ keys.

Raises:

ValueError – If file is invalid.

Return type:

dict[str, Any]