Code Example Collector
The Code Example Collector retains an explicitly selected code file as a documentation fragment. It preserves the source text without executing it or fetching its dependencies.
What it documents
Code examples accompany pages and guides and published specifications. Supported formats are JSON-LD, JSON, Turtle, SPARQL, and plain text. Retaining a JSON example does not interpret arbitrary JSON records as documentable things.
Configure a code example
Publication definitions configure explicit code jobs. A job identifies the file, its subject, its fragment, and its format:
@prefix ga: <https://ekgf.org/ontology/grapharch#> .
@prefix ex: <urn:example:> .
ex:project ga:collector ex:query-example-source .
ex:query-example-source a ga:CollectorUse ; ga:collectorType ga:CodeFileCollector ;
ga:source "examples/products.rq" ; ga:sourcePath "examples/products.rq" ;
ga:fragment ex:query-example ; ga:subject ex:product-query ;
ga:format "application/sparql-query" ; ga:includedIn ex:scope .
Use one of application/ld+json, application/json, text/turtle,
application/sparql-query, or text/plain. This is the configured publishing
workflow of an
exact-revision build,
not a standalone --kind code CLI command. ga:includedIn is required: it
names the scope that publishes the fragment. Publication definitions still
choose where the fragment appears.
For code fenced inside Markdown, use the Markdown File Collector. For a query file with documentation pragmas, use the SPARQL File Collector.