forked from lix-project/lix
meson: add manpages for old cli and config files
Change-Id: I93384ec774d1945a649f6aaf7cd967c3fb7197f9
This commit is contained in:
parent
6804dec882
commit
4a34ec598b
165
doc/manual/meson.build
Normal file
165
doc/manual/meson.build
Normal file
|
@ -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
|
|
@ -2,11 +2,31 @@
|
||||||
|
|
||||||
set -euo pipefail
|
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
|
# 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
|
(grep '{{#include' "$infile" || true) | while read -r line; do
|
||||||
filename="$(dirname "$1")/$(printf "$line" | sed 's/{{#include \(.*\)}}/\1/')"
|
found=false
|
||||||
test -f "$filename" || ( echo "#include-d file '$filename' does not exist." >&2; exit 1; )
|
include="$(printf "$line" | sed 's/{{#include \(.*\)}}/\1/')"
|
||||||
matchline="$(printf "$line" | sed 's|/|\\/|g')"
|
for path in "$@"; do
|
||||||
sed -i "/$matchline/r $filename" "$2"
|
filename="$path/$include"
|
||||||
sed -i "s/$matchline//" "$2"
|
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
|
done
|
||||||
|
|
|
@ -356,6 +356,7 @@ endif
|
||||||
subdir('src')
|
subdir('src')
|
||||||
subdir('scripts')
|
subdir('scripts')
|
||||||
subdir('misc')
|
subdir('misc')
|
||||||
|
subdir('doc/manual')
|
||||||
|
|
||||||
if enable_tests
|
if enable_tests
|
||||||
subdir('tests/unit')
|
subdir('tests/unit')
|
||||||
|
|
Loading…
Reference in a new issue