✓
Passing This code compiles and runs correctly.
Code
// Pins: declaration prose in a vertical annotation block on a collected
// tor renders through the surface — scope-vocabulary shows each verb's
// first doc line after ` — `, and scope-manifest ships the whole doc in
// its JSON `doc` field. An undocumented verb renders with no suffix.
import std/io
import std/runtime
import doclib/res
std/runtime:register(scope: "docs") {
doclib.res:mint -> mint(1)
doclib.res:grab -> grab(1)
doclib.res:release -> release(1)
}
std/runtime:scope-vocabulary(name: "docs")
| ok v |> std/io:print.ln("{{ v:s }}")
| not-found |> std/io:print.ln("FAIL: scope docs not found")
std/runtime:scope-manifest(name: "docs")
| ok m |> std/io:print.ln("{{ m:s }}")
| not-found |> std/io:print.ln("FAIL: manifest not found")
Supporting Files
// Doc'd tors for the vocabulary-render pin: prose in a vertical annotation
// block becomes the decl's .prose, which scope-vocabulary renders after
// ` — ` (first line) and scope-manifest ships whole in the JSON `doc` field.
pub const Res = struct { v: u32 };
~[
Mint a Res — hands back a live handle token.
The token is opaque: pass it to verbs that borrow or discharge it.
]pub tor mint {} -> *Res<opened!>
~proc mint|zig {
const r = @import("std").heap.page_allocator.create(Res) catch unreachable;
r.* = .{ .v = 7 };
return r;
}
~[
Read the resource — borrows the token.
]pub tor grab { r: *Res<opened> }
~proc grab|zig {
_ = r;
}
~[
Release the resource — spends the token for good.
]pub tor release { r: *Res<!opened> }
~proc release|zig {
@import("std").heap.page_allocator.destroy(r);
}
Actual
pub tor mint {} -> *Res<opened!> — Mint a Res — hands back a live handle token.
pub tor grab { r: *Res<opened> } — Read the resource — borrows the token.
pub tor release { r: *Res<!opened> } — Release the resource — spends the token for good.
{"kind":"koru/scope-manifest","version":1,"scope":"docs","events":[{"name":"mint","cost":1,"home":"doclib.res","args":[],"creates":[{"obligation":"opened","module":"doclib.res","field":"__type_ref","resource_type":"Res"}],"discharges":[],"branches":[{"name":"ok","optional":false,"fields":[{"name":"__type_ref","type":"*Res<opened!>","optional":false}]}],"doc":"Mint a Res — hands back a live handle token.\u000aThe token is opaque: pass it to verbs that borrow or discharge it."},{"name":"grab","cost":1,"home":"doclib.res","args":[{"name":"r","type":"*Res","optional":false,"phantom":"opened"}],"creates":[],"discharges":[],"branches":[],"doc":"Read the resource — borrows the token."},{"name":"release","cost":1,"home":"doclib.res","args":[{"name":"r","type":"*Res","optional":false,"phantom":"!opened"}],"creates":[],"discharges":[{"obligation":"opened","module":"doclib.res","arg":"r"}],"branches":[],"doc":"Release the resource — spends the token for good."}],"includes":[],"doc":""}
Expected output
pub tor mint {} -> *Res<opened!> — Mint a Res — hands back a live handle token.
pub tor grab { r: *Res<opened> } — Read the resource — borrows the token.
pub tor release { r: *Res<!opened> } — Release the resource — spends the token for good.
{"kind":"koru/scope-manifest","version":1,"scope":"docs","events":[{"name":"mint","cost":1,"home":"doclib.res","args":[],"creates":[{"obligation":"opened","module":"doclib.res","field":"__type_ref","resource_type":"Res"}],"discharges":[],"branches":[{"name":"ok","optional":false,"fields":[{"name":"__type_ref","type":"*Res<opened!>","optional":false}]}],"doc":"Mint a Res — hands back a live handle token.\u000aThe token is opaque: pass it to verbs that borrow or discharge it."},{"name":"grab","cost":1,"home":"doclib.res","args":[{"name":"r","type":"*Res","optional":false,"phantom":"opened"}],"creates":[],"discharges":[],"branches":[],"doc":"Read the resource — borrows the token."},{"name":"release","cost":1,"home":"doclib.res","args":[{"name":"r","type":"*Res","optional":false,"phantom":"!opened"}],"creates":[],"discharges":[{"obligation":"opened","module":"doclib.res","arg":"r"}],"branches":[],"doc":"Release the resource — spends the token for good."}],"includes":[],"doc":""}
Flows
flow ~register click a branch to expand · @labels scroll to their anchor
register (scope: "docs", source: doclib.res:mint -> mint(1)
doclib.res:grab -> grab(1)
doclib.res:release -> release(1))
flow ~scope-vocabulary click a branch to expand · @labels scroll to their anchor
scope-vocabulary (name: "docs")
flow ~scope-manifest click a branch to expand · @labels scroll to their anchor
scope-manifest (name: "docs")
Test Configuration
MUST_RUN
koru.json:
{
"paths": {
"std": "../../../../../koru_std",
"app": "{{ ENTRY }}",
"doclib": "{{ ENTRY }}/doclib"
}
}