zaphyra's git: haumea

fork of https://github.com/nix-community/haumea

commit da64893a722be4cf19eb2f43d5e3020911335455
parent e6f3a41fe8f3b36424dd259d2438ad31caf132da
Author: figsoda <figsoda@pm.me>
Date: Wed, 10 May 2023 11:41:20 -0400

docs: add dev shell and contribution instructions
3 files changed, 22 insertions(+), 0 deletions(-)
M
CONTRIBUTING.md
|
6
++++++
M
docs/book.toml
|
3
+++
M
docs/flake.nix
|
13
+++++++++++++
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
@@ -13,6 +13,12 @@ This doesn't apply to bug fixes.
 - Add [tests](https://github.com/nix-community/haumea/tree/main/tests) when necessary.
   Test your changes with `nix flake check`. Make sure new files are added to git.
 
+## Documentation
+
+Documentation sits in the [docs](https://github.com/nix-community/haumea/tree/main/docs)
+directory. You can get started with `nix develop ./docs`, which will start up
+[mdbook](https://github.com/rust-lang/mdbook) and serve the documentation on localhost.
+
 ## Scope
 
 Haumea only depends on [nixpkgs.lib](https://github.com/nix-community/nixpkgs.lib).
diff --git a/docs/book.toml b/docs/book.toml
@@ -3,6 +3,9 @@ authors = ["figsoda"]
 description = "Filesystem-based module system for Nix"
 title = "haumea"
 
+[build]
+extra-watch-dirs = ["."]
+
 [output.html]
 edit-url-template = "https://github.com/nix-community/haumea/edit/main/docs/{path}"
 git-repository-url = "https://github.com/nix-community/haumea"
diff --git a/docs/flake.nix b/docs/flake.nix
@@ -19,6 +19,19 @@
         (system: f nixpkgs.legacyPackages.${system});
     in
     {
+      devShells = eachSystem (pkgs: {
+        default = pkgs.mkShell {
+          packages = [ pkgs.mdbook ];
+          shellHook = ''
+            toplevel=$(git rev-parse --show-toplevel) || exit
+            cd "$toplevel" || exit
+            mkdir -p docs/theme
+            ln -sf ${pkgs.documentation-highlighter}/highlight.pack.js docs/theme/highlight.js
+            mdbook serve docs
+          '';
+        };
+      });
+
       packages = eachSystem (pkgs: {
         default = pkgs.stdenv.mkDerivation {
           pname = "haumea-docs";