Elfie

Documentation / Context API

Context API

Every member of the context layer, for every kind of entity, and the records criteria, tests, knowledge, and commands are made of.

Name@member reads a member. Inside a declaration's body, @member reads the current entity's. @ alone is the entity itself.

Every entity

MemberTypeHolds
identifierstring | undefinedThe declared name. Undefined when anonymous.
definitionstring | undefinedThe description.
typeEntity | undefinedThe declared or inferred type. For a data, trait, type, or enum, the entity itself.
typeParametersEntity[]The type parameters it declares, in order.
typeArgumentsEntity[]The arguments a generic type was written with.
itemTypeEntity | undefinedWhat a list-typed entity holds.
acceptanceCriteriaCriterion[]Its own criteria, then each trait's, in application order.
testsTest[]Every test added, in order.
traitsEntity[]Every trait applied, directly or inherited, in application order.
referencesEntity[]Every entity referred to with [[...]] in its description, documentation, or value.
knowledgeKnowledge[]Its own items, then each trait's.
commandsCommand[]Shell commands for its operations.
targetsEntity[]The target consts added to it.
CallDoes
@acceptanceCriteria.add(criterion)Appends a criterion. Returns the list, so calls chain.
@test(...tests)Appends test cases. Returns the entity.
@knowledge.add(item)Appends a knowledge item.
@commands.add(command)Appends a command.
@targets.add(target)Appends a target const. Adding one twice, or adding to a member, a parameter, or an enum member, is a problem.
Type@like(prompt)A value of the type that the prompt describes, chosen by the compiler.

Functions

Applies to fn and function.

MemberTypeHolds
parametersParameter[]Its parameters, in order.
outputEntityThe type after the arrow, or the inferred type of what it returns.
agenticbooleantrue for a fn, whose body is generated, and false for a function.

Traits

MemberTypeHolds
entitiesEntity[]Everything the trait was applied to, directly or by inheritance.
extendersTrait[]Every trait that names it in extends.
apply(target, ...arguments)TraitApplies the trait to an entity or a list of entities, and returns the trait.
layer(...arguments)LayerThe trait with arguments, for a target's slot. Applies it to nothing.

Other kinds

KindMemberTypeHolds
EnummembersEntity[]Its named values, in order.
MemberownerEntityThe entity that declares it.
ParameteroptionalbooleanWhether a call may leave it out.
ParameterdefaultValueEntity | undefinedWhat it takes when left out.
ParameterspreadbooleanWhether it takes the rest of the arguments.
ModuleentitiesEntity[]Every entity its file declares.

Data (d), types, and variables have only the members every entity has.

Criterion

FieldTypeHolds
situationstring | string[] | undefinedWhen it applies. A list must all hold. Undefined means always.
behaviorstring | string[] | undefinedWhat must happen.
sideEffectsstring[] | undefinedWhat is written outside the value.
contributorobjectThe entity whose body holds it: the entity itself, or one of its traits.

A where statement adds a criterion too. Its conditions are the situation, and the text after -> is the behavior.

Test

FieldHolds
inputFor a function, the argument list. Otherwise, a value.
expectFor a function, what the call returns. Otherwise, a value.

Knowledge

FieldTypeHolds
topicstringWhat it teaches, in a few words.
kindKnowledgeKindreference, example, definition, or tool.
sourcestringA path relative to the declaring package or project, a use path, or a tool's name.
quoteboolean | undefinedWhether requests quote it in full.

Command

FieldTypeHolds
operationOperationinstall, add, build, test, lint, format, or run.
linestring | undefinedWhat sh -c runs in the target's output directory. Undefined turns the operation off.

Was this guide clear?

Share a suggestion