From d3f5079d8dcb488c964aad4d0e92b71aa9d8fc51 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 27 Sep 2021 13:28:27 +0200 Subject: [PATCH] Generate config docs from lemmy code --- .drone.yml | 4 +--- .gitignore | 1 + .gitmodules | 3 +++ README.md | 3 +-- build.sh | 19 +++++++++++++++++++ lemmy | 1 + src/en/administration/configuration.md | 10 +++++++--- 7 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 .gitmodules create mode 100755 build.sh create mode 160000 lemmy diff --git a/.drone.yml b/.drone.yml index be72a27..448d750 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/.gitignore b/.gitignore index 7585238..edc8779 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ book +generated \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8009f1c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lemmy"] + path = lemmy + url = https://github.com/LemmyNet/lemmy.git diff --git a/README.md b/README.md index 3279b13..a6b5418 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..82514de --- /dev/null +++ b/build.sh @@ -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 . diff --git a/lemmy b/lemmy new file mode 160000 index 0000000..c66a792 --- /dev/null +++ b/lemmy @@ -0,0 +1 @@ +Subproject commit c66a7920839baa82319d32fc8360a590393cdd18 diff --git a/src/en/administration/configuration.md b/src/en/administration/configuration.md index 9d4398f..9e8f226 100644 --- a/src/en/administration/configuration.md +++ b/src/en/administration/configuration.md @@ -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}} +``` \ No newline at end of file