From 3de5f1ba395fa39d6813506a41ce3d5c44082f9f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 4 Nov 2023 14:30:04 +0300 Subject: [PATCH 1/7] docs: use nixosOptionDocs NixOS 23.11 is deprecating DocBook option documentation. Following home-manager in this change is probably a good idea --- docs/default.nix | 80 ++++++++++++++++--- .../nvim-autopairs/nvim-autopairs.nix | 2 +- modules/completion/nvim-cmp/nvim-cmp.nix | 13 ++- modules/core/default.nix | 10 +-- modules/filetree/nvimtree/nvimtree.nix | 1 + modules/statusline/lualine/lualine.nix | 2 +- modules/treesitter/context.nix | 4 +- modules/treesitter/treesitter.nix | 2 +- modules/ui/breadcrumbs/breadcrumbs.nix | 1 + modules/visuals/visuals.nix | 6 +- 10 files changed, 91 insertions(+), 30 deletions(-) diff --git a/docs/default.nix b/docs/default.nix index 211bf3890..2a5142cb5 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -29,25 +29,68 @@ ]; }; + githubDeclaration = user: repo: subpath: let + urlRef = "main"; + in { + url = "https://github.com/${user}/${repo}/blob/${urlRef}/${subpath}"; + name = "<${repo}/${subpath}>"; + }; + dontCheckDefinitions = {_module.check = false;}; - nvimModuleDocs = nmd.buildModulesDocs { + nvimPath = toString ./..; + + buildOptionsDocs = args @ { + modules, + includeModuleSystemsOptions ? true, + ... + }: let + options = (lib.evalModules {inherit modules;}).options; + in + pkgs.buildPackages.nixosOptionsDoc + ({ + options = + if includeModuleSystemsOptions + then options + else builtins.removeAttrs (options ["_module"]); + transformOptions = opt: + opt + // { + # Clean up declaration sites to not refer to local source tree + declarations = + map + (decl: + if lib.hasPrefix nvimPath (toString decl) + then + githubDeclaration "notashelf" "neovim-flake" + (lib.removePrefix "/" (lib.removePrefix nvimPath (toString decl))) + else decl) + opt.declarations; + }; + } + // builtins.removeAttrs args ["modules" "includeModuleSystemsOptions"]); + + nvimModuleDocs = buildOptionsDocs { modules = - import ../modules/modules.nix { + import ../modules/modules.nix + { inherit pkgs lib; check = false; } - ++ [scrubbedPkgsModule dontCheckDefinitions]; - moduleRootPaths = [./..]; - mkModuleUrl = path: "https://github.com/notashelf/neovim-flake/blob/main/${path}#blob-path"; - channelName = "neovim-flake"; - docBook.id = "neovim-flake-options"; + ++ [scrubbedPkgsModule]; + variablelistId = "neovim-flake-options"; }; docs = nmd.buildDocBookDocs { pathName = "neovim-flake"; projectName = "neovim-flake"; - modulesDocs = [nvimModuleDocs]; + modulesDocs = [ + { + docBook = pkgs.linkFarm "nvim-module-docs-for-nmd" { + "nmd-result/neovim-flake-options.xml" = nvimModuleDocs.optionsDocBook; + }; + } + ]; documentsDirectory = ./.; documentType = "book"; chunkToc = '' @@ -65,7 +108,24 @@ ''; }; in { - options.json = nvimModuleDocs.json.override {path = "share/doc/neovim-flake/options.json";}; - manPages = docs.manPages; + options.json = + pkgs.runCommand "options.json" + # TODO: Use `nvimOptionsDoc.optionsJSON` directly once upstream + # `nixosOptionsDoc` is more customizable + { + meta.description = "List of neovim-flake options in JSON format"; + } '' + mkdir -p $out/{share/doc,nix-support} + cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/neovim-flake + substitute \ + ${nvimModuleDocs.optionsJSON}/nix-support/hydra-build-products \ + $out/nix-support/hydra-build-products \ + --replace \ + '${nvimModuleDocs.optionsJSON}/share/doc/nixos' \ + "$out/share/doc/neovim-flake" + ''; + + inherit (docs) manPages; + manual = {inherit (docs) html htmlOpenTool;}; } diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index 9dc8c64ac..d64b5cbd3 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -15,7 +15,7 @@ with builtins; { map_cr = mkOption { type = types.bool; default = true; - description = nvim.nmd.asciiDoc ''map on insert mode''; + description = ''map on insert mode''; }; map_complete = mkOption { diff --git a/modules/completion/nvim-cmp/nvim-cmp.nix b/modules/completion/nvim-cmp/nvim-cmp.nix index fa7041b7e..6871600c7 100644 --- a/modules/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/completion/nvim-cmp/nvim-cmp.nix @@ -22,7 +22,7 @@ with builtins; { }; sources = mkOption { - description = nvim.nmd.asciiDoc '' + description = '' Attribute set of source names for nvim-cmp. If an attribute set is provided, then the menu value of @@ -40,23 +40,22 @@ with builtins; { formatting = { format = mkOption { - description = nvim.nmd.asciiDoc '' + description = '' The function used to customize the appearance of the completion menu. - If <> is true, then the function + If {option}`vim.lsp.lspkind.enable` is true, then the function will be called before modifications from lspkind. Default is to call the menu mapping function. ''; type = types.str; default = "nvim_cmp_menu_map"; - example = nvim.nmd.literalAsciiDoc '' - [source,lua] - --- + example = '' + ```lua function(entry, vim_item) return vim_item end - --- + ``` ''; }; }; diff --git a/modules/core/default.nix b/modules/core/default.nix index fd097ef8b..2a352629e 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -27,23 +27,23 @@ with builtins; let mapConfigOptions = { silent = mkBool false - (nvim.nmd.asciiDoc "Whether this mapping should be silent. Equivalent to adding to a map."); + "Whether this mapping should be silent. Equivalent to adding to a map."; nowait = mkBool false - (nvim.nmd.asciiDoc "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."); + "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; script = mkBool false - (nvim.nmd.asciiDoc "Equivalent to adding