This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A GitHub Action and standalone Python tool that postprocesses OGC Building Blocks — reusable data models combining JSON Schema, JSON-LD, SHACL, test cases, examples, and profile declarations. It generates documentation, validates outputs, performs semantic uplifting to RDF, and optionally deploys results.
# Directly via Python module
python -m ogc.bblocks.bootstrap [options]
# Key options:
# --register-file PATH Path to register.json output
# --items-dir DIR Directory to scan for building blocks
# --base-url URL Base URL for generated output
# --clean Delete old build directories first
# --steps STEPS Comma-separated list: annotate,jsonld,tests,transforms,doc,register
# --filter FILTER Process only matching building block or file
# --fail-on-errors Exit non-zero if validation errors found
# Via Docker
docker build -t bblocks-postprocess .
docker run -v /path/to/repo:/workspace bblocks-postprocess [options]Create bblocks-config-local.yml to map remote URLs to local files:
url-mappings:
https://example.com/path: /local/pathThe HTTP interceptor (http_interceptor.py) monkey-patches urllib/requests to redirect these.
bootstrap.py Loads plugins from transform-plugins.yml, then delegates
→ entrypoint.py Parses CLI args, loads bblocks-config.yaml, calls postprocess()
→ postprocess.py Core orchestration: discover → annotate → validate → generate docs → register
-
models.py—BuildingBlock(single block),BuildingBlockRegister(collection),ImportedBuildingBlocks(external registers). Building blocks lazy-load their properties; remote resources are cached underannotated_path/_cache/. -
schema.py+extension.py— JSON Schema annotation (via ogc-na-tools) and reference resolution.extension.pymerges extension points from child building blocks into parent schemas. -
validate.py— Test validation and HTML/JSON/text report generation. Validators (JSON Schema, RDF/SHACL, semantic uplift) live invalidation/. -
transform.py+transformers/— Applies pluggable transformers to examples. Built-in transformers: RDF (SHACL-AF, SPARQL), jq, XSLT, JSON-LD Frame, semantic uplift. External transformers load viatransform-plugins.yml. -
generate_docs.py— Mako-based documentation generation from templates intemplates/*/. -
oas30.py— Converts JSON Schema to OpenAPI 3.0. -
http_interceptor.py— URL mapping for local testing.
For each bblock.json found:
- Validate metadata against
schemas/bblock.schema.yaml - Annotate schema with semantic annotations (ogc-na-tools)
- Resolve all
$refpointers - Convert to OAS 3.0
- Apply transforms to examples
- Validate (JSON Schema, JSON-LD context, RDF, SHACL)
- Generate docs from Mako templates
- Write annotated schema, context, etc. to
build/
After all blocks: generate register.json, perform semantic uplift to JSON-LD + Turtle, optionally push to SPARQL triplestore.
transform-plugins.yml allows loading external transformer modules:
plugins:
- modules: [my.custom.Transformer]
install:
pip: my-custom-packagebootstrap.py loads these before delegating to entrypoint.py.
| File | Purpose |
|---|---|
bblocks-config.yaml |
Per-repo config: identifier prefix, imports, SPARQL endpoints |
bblock.json |
Per-block metadata: identifier, name, schema path, examples, SHACL, extension points |
examples.yaml |
Example snippets with test cases |
transforms.yaml |
Transform definitions (type, inputs, outputs, code) |
transform-plugins.yml |
External transformer plugin loading |
- Python: ogc-na-tools (semantic annotation + RDF), pyshacl, rdflib (custom fork
avillar/rdflib@6.x), jsonschema, mako, requests - Node.js:
jsonldpackage (for JSON-LD processing) - Install:
pip install -r requirements.txt && npm install
build-docker.yml— builds and pushes Docker image toghcr.io/opengeospatial/bblocks-postprocesson push to mastertest-postprocess.yml— regression tests against live bblocks repos (triggered after Docker build)validate-and-process.yml— reusable workflow called by downstream repos to postprocess, commit, and deploy their building blocks