Skip to content

Commit

Permalink
Merge pull request #318102 from TheCodedProf/private/thecodedprof/doc…
Browse files Browse the repository at this point in the history
…umentation-examples

lib.trivial: add examples for importJSON and importTOML
  • Loading branch information
infinisil committed Jun 13, 2024
2 parents 15ef0de + cfc6c9b commit a1bae89
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions lib/trivial.nix
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,37 @@ in {
/**
Reads a JSON file.
# Examples
:::{.example}
## `lib.trivial.importJSON` usage example
example.json
```json
{
"title": "Example JSON",
"hello": {
"world": "foo",
"bar": {
"foobar": true
}
}
}
```
```nix
importJSON ./example.json
=> {
title = "Example JSON";
hello = {
world = "foo";
bar = {
foobar = true;
};
};
}
```
:::
# Inputs
Expand All @@ -642,6 +673,35 @@ in {
/**
Reads a TOML file.
# Examples
:::{.example}
## `lib.trivial.importTOML` usage example
example.toml
```toml
title = "TOML Example"
[hello]
world = "foo"
[hello.bar]
foobar = true
```
```nix
importTOML ./example.toml
=> {
title = "TOML Example";
hello = {
world = "foo";
bar = {
foobar = true;
};
};
}
```
:::
# Inputs
Expand Down

0 comments on commit a1bae89

Please sign in to comment.