docs: fix moduleDoc being interpreted by bash

Including the `moduleDoc` text directly in the `copy_docs` script meant
special chars were interpreted by bash.

Write the text to the nix store so we can `cat` a file instead.
This commit is contained in:
Matt Sturgeon 2024-03-22 13:32:01 +00:00 committed by Gaétan Lepage
parent fd5ef72725
commit d45c30f160

View file

@ -202,11 +202,12 @@ with lib; let
+ ( + (
if opts.index.moduleDoc == null if opts.index.moduleDoc == null
then "cp ${mkMDDoc opts.index.options} ${path}" then "cp ${mkMDDoc opts.index.options} ${path}"
else '' else
# Including moduleDoc's text directly will result in bash interpreting special chars,
# write it to the nix store and `cat` the file instead.
''
{ {
cat <<EOF cat ${pkgs.writeText "module-doc" opts.index.moduleDoc}
${opts.index.moduleDoc}
EOF
cat ${mkMDDoc opts.index.options} cat ${mkMDDoc opts.index.options}
} > ${path} } > ${path}
'' ''