Generate config docs from lemmy code

This commit is contained in:
Felix Ableitner 2021-09-27 13:28:27 +02:00
parent 16155e31d6
commit d3f5079d8d
7 changed files with 33 additions and 8 deletions

View file

@ -5,6 +5,4 @@ steps:
- name: check documentation build
image: rust:1.49-slim-buster
commands:
- cargo install mdbook --git https://github.com/Nutomic/mdBook.git --branch localization
--rev 0982a82 --force --debug
- mdbook build .
- build.sh

1
.gitignore vendored
View file

@ -1 +1,2 @@
book
generated

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "lemmy"]
path = lemmy
url = https://github.com/LemmyNet/lemmy.git

View file

@ -9,8 +9,7 @@ You need to have [Cargo](https://doc.rust-lang.org/cargo/) installed.
Our documentation tool [mdbook](https://github.com/rust-lang/mdBook) doesn't support localisation yet, so we are using code that is still work on progress to create our documentation with localisation. Note that this code still has some rough edges. See [github.com/rust-lang/mdBook/pull/1306](https://github.com/rust-lang/mdBook/pull/1306) for more details.
```bash
cargo install mdbook --git https://github.com/Ruin0x11/mdBook.git \
--branch localization --rev d06249b
./build.sh
# generate static page in `book` subfolder
mdbook build
# serve the book at `http://localhost:3000`, and rebuilds on changes

19
build.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
set -e
# generate config docs
pushd lemmy
mkdir ../generated
cargo run -- --print-config-docs >> ../generated/config.hjson
# replace // comments with #
sed -i "s/\/\//#/" ../generated/config.hjson
# remove trailing commas
sed -i "s/,\$//" ../generated/config.hjson
# remove quotes around json keys
sed -i "s/\"//" ../generated/config.hjson
sed -i "s/\"//" ../generated/config.hjson
popd
cargo install mdbook --git https://github.com/Nutomic/mdBook.git --branch localization \
--rev 0982a82
mdbook build .

1
lemmy Submodule

@ -0,0 +1 @@
Subproject commit c66a7920839baa82319d32fc8360a590393cdd18

View file

@ -1,8 +1,6 @@
# Configuration
The configuration is based on the file [config.hjson](https://github.com/lemmynet/lemmy/blob/main/config/config.hjson). This file also contains documentation for all the available options. The install instructions tell you how to override the defaults.
The `config.hjson` file is located at `config/config.hjson`. To change the default location, you can set the environment variable `LEMMY_CONFIG_LOCATION`.
The configuration is based on the file config.hjson, which is located by default at `config/config.hjson`. To change the default location, you can set the environment variable `LEMMY_CONFIG_LOCATION`.
An additional environment variable `LEMMY_DATABASE_URL` is available, which can be used with a PostgreSQL connection string like `postgres://lemmy:password@lemmy_db:5432/lemmy`, passing all connection details at once.
@ -14,3 +12,9 @@ cd server
```
**Federation is not set up by default.** You can add this [this federation block](https://github.com/lemmynet/lemmy/blob/main/config/config.hjson#L64) to your `lemmy.hjson`, and ask other servers to add you to their allowlist.
## Full config with default values
```hjson
{{#include ../../../generated/config.hjson}}
```