mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
update-script/rust-analyzer: Filter out headers from option descriptions
Headers are not allowed in nixpkgs option descriptions.
This commit is contained in:
parent
ad704ddba7
commit
dbf6f7bc99
4 changed files with 44 additions and 24 deletions
|
@ -25,5 +25,5 @@ lib.fix (self: {
|
|||
# Derivations that build the generated files
|
||||
efmls-configs-sources = pkgs.callPackage ./efmls-configs.nix { };
|
||||
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
|
||||
rust-analyzer-options = pkgs.callPackage ./rust-analyzer.nix { };
|
||||
rust-analyzer-options = pkgs.callPackage ./rust-analyzer { };
|
||||
})
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
lib,
|
||||
rust-analyzer,
|
||||
writeText,
|
||||
pandoc,
|
||||
runCommand,
|
||||
}:
|
||||
let
|
||||
packageJSON = "${rust-analyzer.src}/editors/code/package.json";
|
||||
|
@ -132,6 +134,18 @@ let
|
|||
type ? null,
|
||||
}:
|
||||
let
|
||||
filteredMarkdownDesc =
|
||||
# If there is a risk that the string contains an heading filter it out
|
||||
if lib.hasInfix "# " markdownDescription then
|
||||
builtins.readFile (
|
||||
runCommand "filtered-documentation" { inherit markdownDescription; } ''
|
||||
${lib.getExe pandoc} -o $out -t markdown \
|
||||
--lua-filter=${./heading_filter.lua} <<<"$markdownDescription"
|
||||
''
|
||||
)
|
||||
else
|
||||
markdownDescription;
|
||||
|
||||
enumDesc =
|
||||
values: descriptions:
|
||||
let
|
||||
|
@ -140,7 +154,7 @@ let
|
|||
);
|
||||
in
|
||||
''
|
||||
${markdownDescription}
|
||||
${filteredMarkdownDesc}
|
||||
|
||||
Values:
|
||||
${builtins.concatStringsSep "\n" valueDesc}
|
||||
|
@ -164,7 +178,7 @@ let
|
|||
enum == null && (anyOf == null || builtins.all (subProp: !(lib.hasAttr "enum" subProp)) anyOf)
|
||||
then
|
||||
''
|
||||
${markdownDescription}
|
||||
${filteredMarkdownDesc}
|
||||
''
|
||||
else if enum != null then
|
||||
assert lib.assertMsg (anyOf == null) "enum + anyOf types are not yet handled";
|
3
update-scripts/rust-analyzer/heading_filter.lua
Normal file
3
update-scripts/rust-analyzer/heading_filter.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
function Header(elem)
|
||||
return pandoc.Strong(elem.content)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue