nix: Move docs tools into core infrastructure
This commit is contained in:
committed by
Wolfgang Walther
parent
e110fdbd2c
commit
a1f2ecadda
@@ -5,5 +5,4 @@ Pipfile.lock
|
||||
_diagrams/db.pdf
|
||||
misspellings
|
||||
unuseddict
|
||||
.history
|
||||
*.mo
|
||||
|
||||
+1
-11
@@ -2,17 +2,7 @@
|
||||
|
||||
PostgREST docs use the reStructuredText format, check this [cheatsheet](https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst) to get acquainted with it.
|
||||
|
||||
To build the docs locally, use [nix](https://nixos.org/nix/):
|
||||
|
||||
```bash
|
||||
nix-shell
|
||||
```
|
||||
|
||||
Once in the nix-shell you have the following commands available:
|
||||
|
||||
- `postgrest-docs-build`: Build the docs.
|
||||
- `postgrest-docs-serve`: Build the docs and start a livereload server on `http://localhost:5500`.
|
||||
- `postgrest-docs-spellcheck`: Run aspell.
|
||||
To build the docs locally, see [the Nix development readme](/nix/README.md#documentation).
|
||||
|
||||
## Documentation structure
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ function build() {
|
||||
sphinx-build --color -W -a -n . -b "$@"
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
if [ "${1:-}" == "" ]; then
|
||||
# clean previous build, otherwise some errors might be supressed
|
||||
rm -rf "_build/html/default"
|
||||
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
let
|
||||
# Commit of the Nixpkgs repository that we want to use.
|
||||
nixpkgsVersion = {
|
||||
date = "2024-01-06";
|
||||
rev = "4bbf5a2eb6046c54f7a29a0964c642ebfe912cbc";
|
||||
tarballHash = "03p45qdcxqxc41mmzmmyzbkff29vv95vv643z0kd3mf1s2nnsy5b";
|
||||
};
|
||||
|
||||
# Nix files that describe the Nixpkgs repository. We evaluate the expression
|
||||
# using `import` below.
|
||||
pkgs = import
|
||||
(fetchTarball {
|
||||
url = "https://github.com/nixos/nixpkgs/archive/${nixpkgsVersion.rev}.tar.gz";
|
||||
sha256 = nixpkgsVersion.tarballHash;
|
||||
})
|
||||
{ };
|
||||
|
||||
python = pkgs.python3.withPackages (ps: [
|
||||
ps.sphinx
|
||||
ps.sphinx_rtd_theme
|
||||
ps.livereload
|
||||
ps.sphinx-tabs
|
||||
ps.sphinx-copybutton
|
||||
ps.sphinxext-opengraph
|
||||
# TODO: Remove override once new sphinx-intl version (> 2.1.0) is released and available in nixpkgs
|
||||
(ps.sphinx-intl.overrideAttrs (drv: { nativeBuildInputs = drv.nativeBuildInputs ++ [ ps.six ]; }))
|
||||
]);
|
||||
in
|
||||
rec {
|
||||
inherit pkgs;
|
||||
|
||||
build =
|
||||
pkgs.writeShellScriptBin "postgrest-docs-build"
|
||||
''
|
||||
set -euo pipefail
|
||||
cd "$(${pkgs.git}/bin/git rev-parse --show-toplevel)/docs"
|
||||
|
||||
# build.sh needs to find "sphinx-build"
|
||||
PATH=${python}/bin:$PATH
|
||||
|
||||
./build.sh "$@"
|
||||
'';
|
||||
|
||||
serve =
|
||||
pkgs.writeShellScriptBin "postgrest-docs-serve"
|
||||
''
|
||||
set -euo pipefail
|
||||
cd "$(${pkgs.git}/bin/git rev-parse --show-toplevel)/docs"
|
||||
|
||||
# livereload_docs.py needs to find "sphinx-build"
|
||||
PATH=${python}/bin:$PATH
|
||||
|
||||
./livereload_docs.py "$@"
|
||||
'';
|
||||
|
||||
spellcheck =
|
||||
pkgs.writeShellScriptBin "postgrest-docs-spellcheck"
|
||||
''
|
||||
set -euo pipefail
|
||||
cd "$(${pkgs.git}/bin/git rev-parse --show-toplevel)/docs"
|
||||
|
||||
FILES=$(find . -type f -iname '*.rst' | tr '\n' ' ')
|
||||
|
||||
cat $FILES \
|
||||
| grep -v '^\(\.\.\| \)' \
|
||||
| sed 's/`.*`//g' \
|
||||
| ${pkgs.aspell}/bin/aspell -d ${pkgs.aspellDicts.en}/lib/aspell/en_US -p ./postgrest.dict list \
|
||||
| sort -f \
|
||||
| tee misspellings
|
||||
test ! -s misspellings
|
||||
'';
|
||||
|
||||
# dictcheck detects obsolete entries in postgrest.dict, that are not used anymore
|
||||
dictcheck =
|
||||
pkgs.writeShellScriptBin "postgrest-docs-dictcheck"
|
||||
''
|
||||
set -euo pipefail
|
||||
cd "$(${pkgs.git}/bin/git rev-parse --show-toplevel)/docs"
|
||||
|
||||
FILES=$(find . -type f -iname '*.rst' | tr '\n' ' ')
|
||||
|
||||
cat postgrest.dict \
|
||||
| tail -n+2 \
|
||||
| tr '\n' '\0' \
|
||||
| xargs -0 -n 1 -i \
|
||||
sh -c "grep \"{}\" $FILES > /dev/null || echo \"{}\"" \
|
||||
| tee unuseddict
|
||||
test ! -s unuseddict
|
||||
'';
|
||||
|
||||
linkcheck =
|
||||
pkgs.writeShellScriptBin "postgrest-docs-linkcheck"
|
||||
''
|
||||
set -euo pipefail
|
||||
cd "$(${pkgs.git}/bin/git rev-parse --show-toplevel)/docs"
|
||||
|
||||
${python}/bin/sphinx-build --color -b linkcheck . _build
|
||||
'';
|
||||
|
||||
check =
|
||||
pkgs.writeShellScriptBin "postgrest-docs-check"
|
||||
''
|
||||
set -euo pipefail
|
||||
${build}/bin/postgrest-docs-build
|
||||
${dictcheck}/bin/postgrest-docs-dictcheck
|
||||
${linkcheck}/bin/postgrest-docs-linkcheck
|
||||
${spellcheck}/bin/postgrest-docs-spellcheck
|
||||
'';
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import sys
|
||||
from livereload import Server, shell
|
||||
from subprocess import call
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
if len(sys.argv) == 1 or sys.argv[1] == "":
|
||||
locale = "default"
|
||||
build = "./build.sh"
|
||||
else:
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
let
|
||||
docs =
|
||||
import ./default.nix;
|
||||
|
||||
inherit (docs) pkgs;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "postgrest-docs";
|
||||
|
||||
buildInputs = [
|
||||
docs.build
|
||||
docs.serve
|
||||
docs.spellcheck
|
||||
docs.dictcheck
|
||||
docs.linkcheck
|
||||
docs.check
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export HISTFILE=.history
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user