Bundle link-manpages.nix (#669)

It's being removed from nixpkgs as part of the dedocbookification
process. Eventually we'll want to use nixos-render-docs to render
options.
This commit is contained in:
Naïm Favier 2023-07-03 20:29:32 +02:00 committed by GitHub
parent f11e857671
commit 67bac7fe6d
Failed to generate hash of commit
2 changed files with 29 additions and 1 deletions

View file

@ -24,7 +24,7 @@ pkgs.rustPlatform.buildRustPackage rec {
ROOTDIR = builtins.placeholder "out";
NIXPKGS_PANDOC_FILTERS_PATH = pkgs.path + "/doc/build-aux/pandoc-filters";
LINK_MANPAGES_PANDOC_FILTER = import (pkgs.path + "/doc/build-aux/pandoc-filters/link-manpages.nix") { inherit pkgs; };
LINK_MANPAGES_PANDOC_FILTER = import src/data/link-manpages.nix { inherit pkgs; };
checkFlags = [
"--skip elastic::tests"

View file

@ -0,0 +1,28 @@
{ pkgs }:
let
inherit (pkgs) lib;
manpageURLs = lib.importJSON (pkgs.path + "/doc/manpage-urls.json");
in pkgs.writeText "link-manpages.lua" ''
--[[
Adds links to known man pages that aren't already in a link.
]]
local manpage_urls = {
${lib.concatStringsSep "\n" (lib.mapAttrsToList (man: url:
" [${builtins.toJSON man}] = ${builtins.toJSON url},") manpageURLs)}
}
traverse = 'topdown'
-- Returning false as the second value aborts processing of child elements.
function Link(elem)
return elem, false
end
function Code(elem)
local is_man_role = elem.classes:includes('interpreted-text') and elem.attributes['role'] == 'manpage'
if is_man_role and manpage_urls[elem.text] ~= nil then
return pandoc.Link(elem, manpage_urls[elem.text]), false
end
end
''