Skip to content

Commit

Permalink
doc/meson: Dedup conf-file.md targets
Browse files Browse the repository at this point in the history
This also fixes the inclusion of conf-file-prefix.md, as that
would otherwise not appear in the confused meson build.
  • Loading branch information
roberth committed Oct 2, 2024
1 parent 9b4a950 commit feceb8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
32 changes: 3 additions & 29 deletions doc/manual/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,6 @@ subdir('src/development')
subdir('src/release-notes')
subdir('src')

nix_conf_file_md_body = custom_target(
command : nix_eval_for_docs + [
'--expr',
'import @INPUT1@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT0@))',
],
capture : true,
input : [
conf_file_json,
'utils.nix',
'generate-settings.nix',
'src' / 'command-ref' / 'conf-file-prefix.md',
experimental_features_shortlist_md,
],
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',
)

# Hacky way to figure out if `nix` is an `ExternalProgram` or
# `Exectuable`. Only the latter can occur in custom target input lists.
if nix.full_path().startswith(meson.build_root())
Expand Down Expand Up @@ -351,7 +324,7 @@ nix_manpages = [
[ 'nix-channel', 1 ],
[ 'nix-hash', 1 ],
[ 'nix-copy-closure', 1 ],
[ 'nix.conf', 5, 'conf-file.md' ],
[ 'nix.conf', 5, conf_file_md.full_path() ],
[ 'nix-daemon', 8 ],
[ 'nix-profiles', 5, 'files/profiles.md' ],
]
Expand All @@ -363,13 +336,14 @@ foreach entry : nix_manpages
# Therefore we use an optional third element of this array to override the name pattern
md_file = entry.get(2, title + '.md')
section = entry[1].to_string()
md_file_resolved = join_paths('@INPUT1@/command-ref/', md_file)
custom_target(
command : [
bash,
'@INPUT0@',
title,
section,
'@INPUT1@/command-ref/@0@'.format(md_file),
md_file_resolved,
'@OUTPUT@',
],
input : [
Expand Down
14 changes: 12 additions & 2 deletions doc/manual/src/command-ref/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ nix3_cli_files = custom_target(
env : nix_env_for_docs,
)

conf_file_md = custom_target(
conf_file_md_body = custom_target(
command : [
nix_eval_for_docs,
'--expr',
Expand All @@ -43,6 +43,16 @@ conf_file_md = custom_target(
'../../generate-settings.nix',
conf_file_json,
],
output : 'conf-file.md',
output : 'conf-file.body.md',
env : nix_env_for_docs,
)

conf_file_md = custom_target(
command : [ 'cat', '@INPUT0@', '@INPUT1@' ],
capture : true,
input : [
'conf-file-prefix.md',
conf_file_md_body,
],
output : 'conf-file.md',
)

0 comments on commit feceb8e

Please sign in to comment.