Configuration
Most configuration for hexdoc can be done in the hexdoc.toml (or doc/hexdoc.toml) file.
File paths
Most file paths in the hexdoc.toml file are resolved relative to the location of the config file, not the working directory of the hexdoc command or the root of the Git repository.
For example, in the below file structure, the following hexdoc.toml file would correctly reference the src/main/resources directory, regardless of where the hexdoc command is executed from:
.
├── doc/
│ └── hexdoc.toml
└── src/
└── main/
└── resources/
resource_dirs = [
"../src/main/resources",
]
TOML placeholders
The hexdoc.toml parser includes a custom placeholder interpolation system, similar to JSONPath, that allows referencing other values in the config file (eg. for reusing common values).
Placeholders are added to strings in the format {key}, similar to Python's f-strings. The string may also contain other text outside of the placeholder. By default, placeholder keys are resolved relative to the table containing the placeholder.
- Before parsing
- After parsing
key = "foo {var} baz"
var = "bar"
key = "foo bar baz"
var = "bar"
Placeholders must reference keys containing string values; the following example is invalid and would raise an error.
- Before parsing
- After parsing
key = "{var}"
var = 0
key = <INVALID>
var = 0
Parent references
The key ^ may be used to reference the table containing the current table (ie. the parent table). It can be used multiple times to reference grandparents, great-grandparents, and so on. Parent references may optionally be separated and/or followed by . characters.
- Before parsing
- After parsing
[foo]
key1 = "{^baz.var}"
[foo.bar]
key2 = "{^^baz.var}"
key3 = "{^.^.baz.var}"
[baz]
var = "value"
[foo]
key1 = "value"
[foo.bar]
key2 = "value"
key3 = "value"
[baz]
var = "value"
Root references
The key $ may be used at the start of a placeholder key to reference the root table of the TOML file. It may optionally be followed by a . character.
- Before parsing
- After parsing
[foo]
key1 = "{$baz.var}"
[foo.bar]
key2 = "$.baz.var"
[baz]
var = "value"
[foo]
key1 = "value"
[foo.bar]
key2 = "value"
[baz]
var = "value"
Arrays
Placeholders in arrays are resolved relative to the table containing the array. However, placeholders in tables within arrays are resolved relative to the table in the array.
- Before parsing
- After parsing
key1 = [
"{var}",
{ key2="{^var}" }
]
var = "value"
key1 = [
"value",
{ key2="value" }
]
var = "value"
For this reason, it is usually more readable to use root references within arrays.
- Before parsing
- After parsing
key1 = [
"{$var}",
{ key2="{$var}" }
]
var = "value"
key1 = [
"value",
{ key2="value" }
]
var = "value"