Module

PuduLangDocgen.Configuration.Fields

View source

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
&Reader
key
Str
message
Str

Returns

Docgen.Diagnostic

View source

only

fn only(reader: &Reader, allowed: &Array[Str]) -> Result[(), Docgen.Diagnostic]

Every key of an object is one of the allowed names.

Parameters

reader
&Reader
allowed
&Array[Str]

Returns

Result[(), Docgen.Diagnostic]

View source

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
&Reader
key
Str

Returns

Result[Reader, Docgen.Diagnostic]

View source

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
&Reader
key
Str
fallback
Str

Returns

Result[Str, Docgen.Diagnostic]

View source

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
&Reader
key
Str
fallback
Bool

Returns

Result[Bool, Docgen.Diagnostic]

View source

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
&Reader
key
Str

Returns

Result[Array[Str], Docgen.Diagnostic]

View source

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
&Reader
key
Str

Returns

Result[Array[Reader], Docgen.Diagnostic]

View source

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
&Reader
key
Str
fallback
Str

Returns

Result[Str, Docgen.Diagnostic]

View source

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
&Reader
key
Str
fallback
Str

Returns

Result[Str, Docgen.Diagnostic]

View source