Skip to content

Commit

Permalink
Generate config docs from lemmy code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Sep 27, 2021
1 parent 9ca86ab commit 7bfa0fa
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
4 changes: 1 addition & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
book
generated
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lemmy"]
path = lemmy
url = https://github.com/LemmyNet/lemmy.git
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions lemmy
Submodule lemmy added at c66a79
10 changes: 7 additions & 3 deletions src/en/administration/configuration.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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}}
```

0 comments on commit 7bfa0fa

Please sign in to comment.