aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-29 21:31:37 +0100
committereldritch horrors <pennae@lix.systems>2024-03-30 14:26:47 +0000
commitbfbcc3352bd91aa2636386ff0c10d8d0318b1ebc (patch)
treef66a900a25436512366a46e51fbb5f98959accee
parent65d544b1a631a139c369387618adbb2fe2fe9e1f (diff)
meson: add manpages for old cli and config files
Change-Id: I93384ec774d1945a649f6aaf7cd967c3fb7197f9
-rw-r--r--doc/manual/meson.build165
-rwxr-xr-xdoc/manual/process-includes.sh32
-rw-r--r--meson.build1
3 files changed, 192 insertions, 6 deletions
diff --git a/doc/manual/meson.build b/doc/manual/meson.build
new file mode 100644
index 000000000..d898aa0a9
--- /dev/null
+++ b/doc/manual/meson.build
@@ -0,0 +1,165 @@
+nix_env_for_docs = {
+ 'HOME': '/dummy',
+ 'NIX_CONF_DIR': '/dummy',
+ 'NIX_SSL_CERT_FILE': '/dummy/no-ca-bundle.crt',
+ 'NIX_STATE_DIR': '/dummy',
+ 'NIX_CONFIG': 'cores = 0',
+}
+
+nix_for_docs = [ nix, '--experimental-features', 'nix-command' ]
+nix_eval_for_docs = nix_for_docs + [
+ 'eval',
+ '-I', 'nix/corepkgs=corepkgs',
+ '--store', 'dummy://',
+ '--impure',
+ '--raw',
+]
+
+nix_conf_file_json = custom_target(
+ command : nix_for_docs + [ 'show-config', '--json' ],
+ capture : true,
+ output : 'conf-file.json',
+ env : nix_env_for_docs,
+)
+
+nix_conf_file_md_body = custom_target(
+ command : nix_eval_for_docs + [
+ '--expr',
+ '(import @INPUT0@).showSettings { inlineHTML = true; } (builtins.fromJSON (builtins.readFile @INPUT1@))',
+ ],
+ capture : true,
+ input : [
+ 'utils.nix',
+ nix_conf_file_json,
+ ],
+ output : 'conf-file.md.body',
+ env : nix_env_for_docs,
+)
+
+nix_conf_file_md = custom_target(
+ command : [ 'cat', '@INPUT@' ],
+ capture : true,
+ input : [
+ 'src/command-ref/conf-file-prefix.md',
+ nix_conf_file_md_body,
+ ],
+ output : 'conf-file.md',
+)
+
+nix_exp_features_json = custom_target(
+ command : [ nix, '__dump-xp-features' ],
+ capture : true,
+ output : 'xp-features.json',
+)
+nix_exp_feature_shortlist = custom_target(
+ command : nix_eval_for_docs + [
+ '--expr',
+ 'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
+ ],
+ input : [
+ 'generate-xp-features-shortlist.nix',
+ nix_exp_features_json,
+ ],
+ output : 'experimental-features-shortlist.md',
+ capture : true,
+ env : nix_env_for_docs,
+)
+
+nix_nested_manpages = [
+ [ 'nix-env',
+ [
+ 'delete-generations',
+ 'install',
+ 'list-generations',
+ 'query',
+ 'rollback',
+ 'set-flag',
+ 'set',
+ 'switch-generation',
+ 'switch-profile',
+ 'uninstall',
+ 'upgrade',
+ ],
+ ],
+ [ 'nix-store',
+ [
+ 'add-fixed',
+ 'add',
+ 'delete',
+ 'dump-db',
+ 'dump',
+ 'export',
+ 'gc',
+ 'generate-binary-cache-key',
+ 'import',
+ 'load-db',
+ 'optimise',
+ 'print-env',
+ 'query',
+ 'read-log',
+ 'realise',
+ 'repair-path',
+ 'restore',
+ 'serve',
+ 'verify',
+ 'verify-path',
+ ],
+ ],
+]
+
+foreach command : nix_nested_manpages
+ foreach page : command[1]
+ custom_target(
+ command : [
+ './render-manpage.sh',
+ '--unescape-dashes',
+ command[0] + ' --' + page,
+ '1',
+ '@INPUT@',
+ '@OUTPUT@.tmp',
+ '@OUTPUT@',
+ ],
+ input : 'src/command-ref' / command[0] / (page + '.md'),
+ output : command[0] + '-' + page + '.1',
+ install : true,
+ install_dir : mandir / 'man1',
+ )
+ endforeach
+endforeach
+
+nix_manpages = [
+ [ 'nix-env', 1 ],
+ [ 'nix-store', 1 ],
+ [ 'nix-build', 1 ],
+ [ 'nix-shell', 1 ],
+ [ 'nix-instantiate', 1 ],
+ [ 'nix-collect-garbage', 1 ],
+ [ 'nix-prefetch-url', 1 ],
+ [ 'nix-channel', 1 ],
+ [ 'nix-hash', 1 ],
+ [ 'nix-copy-closure', 1 ],
+ [ 'nix.conf', 5, nix_conf_file_md, nix_exp_feature_shortlist ],
+ [ 'nix-daemon', 8 ],
+ [ 'nix-profiles', 5, 'src/command-ref/files/profiles.md', nix_exp_feature_shortlist ],
+]
+
+foreach entry : nix_manpages
+ custom_target(
+ command : [
+ './render-manpage.sh',
+ entry[0],
+ entry[1].to_string(),
+ '@INPUT0@',
+ '@OUTPUT@.tmp',
+ '@OUTPUT@',
+ meson.current_build_dir(),
+ ],
+ input : [
+ entry.get(2, 'src/command-ref' / (entry[0] + '.md')),
+ entry.get(3, []),
+ ],
+ output : '@0@.@1@'.format(entry[0], entry[1]),
+ install : true,
+ install_dir : mandir / 'man@0@'.format(entry[1]),
+ )
+endforeach
diff --git a/doc/manual/process-includes.sh b/doc/manual/process-includes.sh
index 6d75710ad..51ac67acb 100755
--- a/doc/manual/process-includes.sh
+++ b/doc/manual/process-includes.sh
@@ -2,11 +2,31 @@
set -euo pipefail
+infile="$1"
+outfile="$2"
+shift 2
+
+# set a search path for includes. the old makefile-based system splorked
+# everything into the source tree and was thus able to not have a search
+# path, but the meson system generates intermediate files into dedicated
+# directories separate from the source. we still retain the implicit old
+# behavior for now as the base search path, once meson is the default we
+# can revisit this and remove the implicit search path entry. it's fine.
+set -- "$(dirname "$infile")" "$@"
+
# re-implement mdBook's include directive to make it usable for terminal output and for proper @docroot@ substitution
-(grep '{{#include' "$1" || true) | while read -r line; do
- filename="$(dirname "$1")/$(printf "$line" | sed 's/{{#include \(.*\)}}/\1/')"
- test -f "$filename" || ( echo "#include-d file '$filename' does not exist." >&2; exit 1; )
- matchline="$(printf "$line" | sed 's|/|\\/|g')"
- sed -i "/$matchline/r $filename" "$2"
- sed -i "s/$matchline//" "$2"
+(grep '{{#include' "$infile" || true) | while read -r line; do
+ found=false
+ include="$(printf "$line" | sed 's/{{#include \(.*\)}}/\1/')"
+ for path in "$@"; do
+ filename="$path/$include"
+ if [ -e "$filename" ]; then
+ found=true
+ matchline="$(printf "$line" | sed 's|/|\\/|g')"
+ sed -i "/$matchline/r $filename" "$outfile"
+ sed -i "s/$matchline//" "$outfile"
+ break
+ fi
+ done
+ $found || ( echo "#include-d file '$filename' does not exist." >&2; exit 1; )
done
diff --git a/meson.build b/meson.build
index eaa5aa348..8f2a2f88d 100644
--- a/meson.build
+++ b/meson.build
@@ -356,6 +356,7 @@ endif
subdir('src')
subdir('scripts')
subdir('misc')
+subdir('doc/manual')
if enable_tests
subdir('tests/unit')