Module
PuduLangDocgen.Configuration.Fields
Typed reads of configuration values with exact failures
Types
| Name | Description |
|---|---|
Reader |
The configuration file and the object being read |
Functions
| Name | Description |
|---|---|
failure |
A configuration failure naming the dotted location of the value. |
only |
Every key of an object is one of the allowed names. |
nested |
A reader for the object stored under a key; a missing key reads as empty. |
text |
Text under a key, or the fallback when it is missing. |
flag |
A flag under a key, or the fallback when it is missing. |
texts |
A list of text under a key; a single text counts as a list of one. |
objects |
Readers for each object of a list under a key; a single object counts as a list of one. |
directory |
A relative directory under a key: empty for the configuration folder, never leaving it. |
sourceFolder |
A relative folder under a key that may start above the configuration folder with `../` segments; the rest must be a portable relative path. |
failure
fn failure(reader: &Reader, key: Str, message: Str) -> Docgen.Diagnostic
A configuration failure naming the dotted location of the value.
Parameters
reader&ReaderkeyStrmessageStr
Returns
only
fn only(reader: &Reader, allowed: &Array[Str]) -> Result[(), Docgen.Diagnostic]
Every key of an object is one of the allowed names.
Parameters
reader&Readerallowed&Array[Str]
Returns
Result[(), Docgen.Diagnostic]
nested
fn nested(reader: &Reader, key: Str) -> Result[Reader, Docgen.Diagnostic]
A reader for the object stored under a key; a missing key reads as empty.
Parameters
reader&ReaderkeyStr
Returns
Result[Reader, Docgen.Diagnostic]
text
fn text(reader: &Reader, key: Str, fallback: Str) -> Result[Str, Docgen.Diagnostic]
Text under a key, or the fallback when it is missing.
Parameters
reader&ReaderkeyStrfallbackStr
Returns
Result[Str, Docgen.Diagnostic]
flag
fn flag(reader: &Reader, key: Str, fallback: Bool) -> Result[Bool, Docgen.Diagnostic]
A flag under a key, or the fallback when it is missing.
Parameters
reader&ReaderkeyStrfallbackBool
Returns
Result[Bool, Docgen.Diagnostic]
texts
fn texts(reader: &Reader, key: Str) -> Result[Array[Str], Docgen.Diagnostic]
A list of text under a key; a single text counts as a list of one.
Parameters
reader&ReaderkeyStr
Returns
Result[Array[Str], Docgen.Diagnostic]
objects
fn objects(reader: &Reader, key: Str) -> Result[Array[Reader], Docgen.Diagnostic]
Readers for each object of a list under a key; a single object counts as a list of one.
Parameters
reader&ReaderkeyStr
Returns
Result[Array[Reader], Docgen.Diagnostic]
directory
fn directory(reader: &Reader, key: Str, fallback: Str) -> Result[Str, Docgen.Diagnostic]
A relative directory under a key: empty for the configuration folder, never leaving it.
Parameters
reader&ReaderkeyStrfallbackStr
Returns
Result[Str, Docgen.Diagnostic]
sourceFolder
fn sourceFolder(reader: &Reader, key: Str, fallback: Str) -> Result[Str, Docgen.Diagnostic]
A relative folder under a key that may start above the configuration folder with ../
segments; the rest must be a portable relative path.
Parameters
reader&ReaderkeyStrfallbackStr
Returns
Result[Str, Docgen.Diagnostic]