Skip to content

76 Documenting declarations for agents ​

@Document stores a description on the greet declaration. A semantic query reads that same description from the compiler's model, so an agent can discover intent beside the checked signature.

norm
import std.annotation.Document

@Document(description: "Returns a greeting for the named person.")
String greet(String name) {
  return "Hello, " + name
}

main() {
  printLine(greet(name: "Norm"))
}

Expected output:

text
Hello, Norm

Query the declaration from the repository root:

sh
norm query norm/tests/docs/tour/document_annotation.norm greet

The result's query.context.declaration.documentation is Returns a greeting for the named person.

Try it: Change the description, run norm query again, and observe the documentation field.

Precise rules: Reference.

Norm 0.25