DocumentableCollection

struct DocumentableCollection

A flat, source-ordered graph of declarations and signature components.

DocumentableID payloads index items and carry the expected entry kind. Nested types, parameters, effects, and payload types are separate entries so signatures can reference them without copying source spellings. One collection is reused for only one source string at a time.

Properties

let module_documentation: [String]

The detached comment group at the beginning of the source file.

let module_wip: String?

The description from a leading // WIP: marker, when present.

Leading whitespace and the // no-core pragma may precede the marker. The marker is metadata and is removed from module and declaration prose.

let items: [DocumentableEntry]

Declaration and signature-component entries in insertion order.

Methods

mut func add_builtin(name: String, documentation: [String]) -> Void

Adds a synthetic compiler-provided type and its Markdown documentation.

Builtins have no declaration source and therefore do not receive a View Source disclosure. The caller must use the compiler-recognized type spelling.

View Source
pub mut func add_builtin(name: String, documentation: [String]) -> Void {
	self.insert(.builtin(Builtin(name: name)), documentation: documentation)
	()
}

func get(id: DocumentableID) -> DocumentableEntry?

Resolves a typed entry ID, returning none for an out-of-range index.

View Source
pub func get(id: DocumentableID) -> DocumentableEntry? {
	let index = match id {
		.builtin(value) -> value,
		.function(value) -> value,
		.global(value) -> value,
		.method(value) -> value,
		.nominal(value) -> value,
		.property(value) -> value,
		.type(value) -> value,
		.variant(value) -> value,
		.effect_declaration(value) -> value,
		.#"effect"(value) -> value,
		.parameter(value) -> value
	}
	if index < 0 || index >= self.items.count { return .none }
	.some(self.items[index])
}

mut func collect(source: String) -> Void

Appends all supported declarations from source, including private ones.

Type spellings, documentation, and function source are copied into owned entries before the source context changes, so existing IDs remain valid across later collection passes. Use collect_public for the generated API surface.

View Source
pub mut func collect(source: String) -> Void {
	self.collect_in(source: source, public_only: false)
}

mut func collect_public(source: String) -> Void

Indexes declarations visible in the module's public interface.

Private top-level declarations and private members are skipped. Enum variants remain visible with their public enum even though cases have no pub modifier.

View Source
pub mut func collect_public(source: String) -> Void {
	self.collect_in(source: source, public_only: true)
}