nix: Move docs tools into core infrastructure
This commit is contained in:
committed by
Wolfgang Walther
parent
e110fdbd2c
commit
a1f2ecadda
@@ -248,6 +248,27 @@ $ nix-shell --run postgrest-style
|
||||
There is also `postgrest-style-check` that exits with a non-zero exit code if
|
||||
the check resulted in any uncommitted changes. It's mostly useful for CI.
|
||||
|
||||
## Documentation
|
||||
|
||||
The following commands can help you when working on the PostgREST docs:
|
||||
|
||||
```bash
|
||||
# Build the docs
|
||||
[nix-shell]$ postgrest-docs-build
|
||||
|
||||
# Build the docs and start a livereload server on `http://localhost:5500`
|
||||
[nix-shell]$ postgrest-docs-serve
|
||||
|
||||
# Run aspell, to verify spelling mistakes
|
||||
[nix-shell]$ postgrest-docs-spellcheck
|
||||
|
||||
# Detect obsolete entries in postgrest.dict
|
||||
[nix-shell]$ postgrest-docs-dictcheck
|
||||
|
||||
# Build and run all the validation scripts
|
||||
[nix-shell]$ postgrest-docs-check
|
||||
```
|
||||
|
||||
## General development tools
|
||||
|
||||
Tools like `postgrest-build`, `postgrest-run`, `postgrest-repl` etc. are simple wrappers around
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
{ aspell
|
||||
, aspellDicts
|
||||
, buildToolbox
|
||||
, checkedShellScript
|
||||
, python3
|
||||
}:
|
||||
let
|
||||
python = 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 ]; }))
|
||||
]);
|
||||
|
||||
build =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-docs-build";
|
||||
docs = "Build the documentation.";
|
||||
args = [ "ARG_POSITIONAL_SINGLE([language], [Language to build docs for.], [\"\"])" ];
|
||||
workingDir = "/docs";
|
||||
}
|
||||
''
|
||||
# build.sh needs to find "sphinx-build"
|
||||
PATH=${python}/bin:$PATH
|
||||
|
||||
./build.sh "$_arg_language"
|
||||
'';
|
||||
|
||||
serve =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-docs-serve";
|
||||
docs = "Serve the documentation locally with live reload.";
|
||||
args = [ "ARG_POSITIONAL_SINGLE([language], [Language to serve docs for.], [\"\"])" ];
|
||||
workingDir = "/docs";
|
||||
}
|
||||
''
|
||||
# livereload_docs.py needs to find "sphinx-build"
|
||||
PATH=${python}/bin:$PATH
|
||||
|
||||
./livereload_docs.py "$_arg_language"
|
||||
'';
|
||||
|
||||
spellcheck =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-docs-spellcheck";
|
||||
docs = "Verify spelling mistakes. Bypass if the word is present in postgrest.dict.";
|
||||
workingDir = "/docs";
|
||||
}
|
||||
''
|
||||
FILES=$(find . -type f -iname '*.rst' | tr '\n' ' ')
|
||||
|
||||
# shellcheck disable=SC2086 disable=SC2016
|
||||
cat $FILES \
|
||||
| grep -v '^\(\.\.\| \)' \
|
||||
| sed 's/`.*`//g' \
|
||||
| ${aspell}/bin/aspell -d ${aspellDicts.en}/lib/aspell/en_US -p ./postgrest.dict list \
|
||||
| sort -f \
|
||||
| tee misspellings
|
||||
test ! -s misspellings
|
||||
'';
|
||||
|
||||
dictcheck =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-docs-dictcheck";
|
||||
docs = "Detect obsolete entries in postgrest.dict that are not used anymore.";
|
||||
workingDir = "/docs";
|
||||
}
|
||||
''
|
||||
FILES=$(find . -type f -iname '*.rst' | tr '\n' ' ')
|
||||
|
||||
tail -n+2 postgrest.dict \
|
||||
| tr '\n' '\0' \
|
||||
| xargs -0 -i \
|
||||
sh -c "grep \"{}\" $FILES > /dev/null || echo \"{}\"" \
|
||||
| tee unuseddict
|
||||
test ! -s unuseddict
|
||||
'';
|
||||
|
||||
linkcheck =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-docs-linkcheck";
|
||||
docs = "Verify that external links are working correctly.";
|
||||
workingDir = "/docs";
|
||||
}
|
||||
''
|
||||
${python}/bin/sphinx-build --color -b linkcheck . _build
|
||||
'';
|
||||
|
||||
check =
|
||||
checkedShellScript
|
||||
{
|
||||
name = "postgrest-docs-check";
|
||||
docs = "Build and run all the validation scripts.";
|
||||
workingDir = "/docs";
|
||||
}
|
||||
''
|
||||
${build}/bin/postgrest-docs-build
|
||||
${dictcheck}/bin/postgrest-docs-dictcheck
|
||||
${linkcheck}/bin/postgrest-docs-linkcheck
|
||||
${spellcheck}/bin/postgrest-docs-spellcheck
|
||||
'';
|
||||
|
||||
in
|
||||
buildToolbox
|
||||
{
|
||||
name = "postgrest-docs";
|
||||
tools =
|
||||
[
|
||||
build
|
||||
check
|
||||
dictcheck
|
||||
linkcheck
|
||||
serve
|
||||
spellcheck
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user