pynydus.standards._loader

Spec file loader and shared validation helper.

Each spec file lives in specs/<name>.md and optionally contains a JSON Schema block delimited by <!-- nydus:schema ... --> markers.

Module Contents

Functions

load_spec

Load a spec markdown file and extract its embedded JSON Schema.

validate_against_schema

Validate instance against a spec’s embedded JSON Schema.

_extract_schema_block

Extract the first <!-- nydus:schema ... --> JSON Schema block.

Data

API

pynydus.standards._loader._SPECS_DIR

None

pynydus.standards._loader._SCHEMA_BLOCK_RE

‘compile(…)’

pynydus.standards._loader.load_spec(name: str) tuple[str, dict[str, Any] | None]

Load a spec markdown file and extract its embedded JSON Schema.

Args: name: Standard name (e.g. "mcp", "agentskills", "a2a"). Maps to specs/<name>.md.

Returns: (full_markdown_text, json_schema_dict_or_None). The schema is None when the spec has no embedded schema block (e.g. apm.md).

Raises: FileNotFoundError: If the spec file does not exist. json.JSONDecodeError: If the schema block is not valid JSON.

pynydus.standards._loader.validate_against_schema(instance: Any, spec_name: str, *, schema: dict[str, Any] | None = None, level: str = 'warning', label: str = '', location: str = '') list[pynydus.api.schemas.ValidationIssue]

Validate instance against a spec’s embedded JSON Schema.

Args: instance: JSON-compatible object to validate. spec_name: Standard name to load schema from (e.g. "mcp"). schema: Override schema. If None, loads from the spec file. level: Issue level for findings ("warning" or "error"). label: Prefix for the issue message (e.g. "MCP schema"). location: Base location string for the issue.

Returns: List of :class:ValidationIssue (empty when valid).

pynydus.standards._loader._extract_schema_block(md: str) dict[str, Any] | None

Extract the first <!-- nydus:schema ... --> JSON Schema block.

Returns: Parsed JSON Schema dict, or None if no block is found.