docs: Add basic documentation system based on nmd

You can now run `nix build '.#docs'` to build HTML documentation
documenting every single option on nixvim! Fortunately, thanks to
the 'description' field, most options are already documented, but
there are still a fair few that need documenting.

I will be taking care of those in the next few days. When those are
done, I will find a way to automatically rebuild documentation on every
repo push, and also add a PR hook requiring documentation.

Additionally, I will try to find a way to have per-page plugin docs.
This commit is contained in:
Pedro Alves 2022-01-10 19:50:13 +00:00
parent 69cf1b6204
commit eef84178ab
42 changed files with 184 additions and 51 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.tmp .tmp
result

51
docs/default.nix Normal file
View file

@ -0,0 +1,51 @@
{ pkgs, lib, ... }:
let
nmdSrc = pkgs.fetchFromGitLab {
name = "nmd";
owner = "rycee";
repo = "nmd";
rev = "527245ff605bde88c2dd2ddae21c6479bb7cf8aa";
sha256 = "1zi0f9y3wq4bpslx1py3sfgrgd9av41ahpandvs6rvkpisfsqqlp";
};
nmd = import nmdSrc { inherit pkgs lib; };
scrubbedPkgsModule = {
imports = [{
_module.args = {
pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs);
pkgs_i686 = lib.mkForce { };
};
}];
};
buildModulesDocs = args:
nmd.buildModulesDocs ({
moduleRootPaths = [ ./.. ];
mkModuleUrl = path:
"https://github.com/pta2002/nixvim/blob/master/${path}#blob-path";
channelName = "nixvim";
} // args);
nixvimDocs = buildModulesDocs {
modules = [
(import ../nixvim.nix {})
scrubbedPkgsModule
];
docBook.id = "nixvim-options";
};
docs = nmd.buildDocBookDocs {
pathName = "";
modulesDocs = [ nixvimDocs ];
documentsDirectory = ./.;
documentType = "book";
chunkToc = ''
<toc>
<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-home-manager-manual"><?dbhtml filename="index.html"?>
<d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry>
<d:tocentry linkend="ch-nixos-options"><?dbhtml filename="nixos-options.html"?></d:tocentry>
<d:tocentry linkend="ch-nix-darwin-options"><?dbhtml filename="nix-darwin-options.html"?></d:tocentry>
<d:tocentry linkend="ch-tools"><?dbhtml filename="tools.html"?></d:tocentry>
<d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry>
</d:tocentry>
</toc>
'';
};
in docs.html

27
docs/man-nixvim.xml Normal file
View file

@ -0,0 +1,27 @@
<refentry xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refmeta>
<refentrytitle><filename>nixvim.nix</filename></refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo class="source">NixVim</refmiscinfo>
<!-- <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo> -->
</refmeta>
<refnamediv>
<refname><filename>nixvim.nix</filename></refname>
<refpurpose>NixVim configuration specification</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>
TODO
</para>
</refsection>
<refsection>
<title>Options</title>
<para>
You can use the following options in your nixvim config
</para>
<xi:include href="./nmd-result/nixvim-options.xml" />
</refsection>
</refentry>

11
docs/man-pages.xml Normal file
View file

@ -0,0 +1,11 @@
<reference xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>NixVim Reference Pages</title>
<info>
<author><personname>NixVim contributors</personname></author>
<copyright><year>2021-2022</year><holder>NixVim contributors</holder>
</copyright>
</info>
<xi:include href="man-nixvim.xml" />
</reference>

23
docs/manual.xml Normal file
View file

@ -0,0 +1,23 @@
<book xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="book-home-manager-manual">
<info>
<title>NixVim Manual</title>
</info>
<preface>
<title>Preface</title>
<para>
This manual is meant to serve as the ultimate reference for how to use and install NixVim.
</para>
<para>
If you have any issues, questions, or plugin suggestions please open an issue on the
<link xlink:href="https://github.com/pta2002/nixvim">NixVim GitHub</link>
</para>
</preface>
<appendix xml:id="ch-options">
<title>Configuration Options</title>
<xi:include href="./nmd-result/nixvim-options.xml" />
</appendix>
</book>

25
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1638986258, "lastModified": 1641710811,
"narHash": "sha256-OceRdctKZRSgqQxVRvvNB0MaEnFMzQqjUffecoDE9eI=", "narHash": "sha256-yVJ+CtwWZY8BnkNIJ/ue5a28yrRM6CkDF1LvmGmqqwM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "581d2d6c9cd5c289002203581d8aa0861963a933", "rev": "0ecf7d414811f831060cf55707c374d54fbb1dec",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -16,9 +16,26 @@
"type": "github" "type": "github"
} }
}, },
"nmdSrc": {
"flake": false,
"locked": {
"lastModified": 1637239786,
"narHash": "sha256-l2KsnY537mz0blZdqALZKrWXn9PD39CpvotgPnxyIP4=",
"owner": "rycee",
"repo": "nmd",
"rev": "527245ff605bde88c2dd2ddae21c6479bb7cf8aa",
"type": "gitlab"
},
"original": {
"owner": "rycee",
"repo": "nmd",
"type": "gitlab"
}
},
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"nmdSrc": "nmdSrc"
} }
} }
}, },

View file

@ -3,7 +3,15 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs, ... }@inputs: rec { inputs.nmdSrc.url = "gitlab:rycee/nmd";
inputs.nmdSrc.flake = false;
outputs = { self, nixpkgs, nmdSrc, ... }@inputs: rec {
packages."x86_64-linux".docs = import ./docs {
pkgs = import nixpkgs { system = "x86_64-linux"; };
lib = nixpkgs.lib;
};
nixosModules.nixvim = import ./nixvim.nix { nixos = true; }; nixosModules.nixvim = import ./nixvim.nix { nixos = true; };
homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; }; homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; };

View file

@ -1,5 +1,5 @@
{ nixos ? false, nixOnDroid ? false, homeManager ? false }: { nixos ? false, nixOnDroid ? false, homeManager ? false }:
{ pkgs, lib, config, ... }: { pkgs , lib, config, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim; cfg = config.programs.nixvim;
@ -100,8 +100,9 @@ in
}; };
colorscheme = mkOption { colorscheme = mkOption {
type = types.str; type = types.nullOr types.str;
description = "The name of the colorscheme"; description = "The name of the colorscheme";
default = null;
}; };
extraConfigLua = mkOption { extraConfigLua = mkOption {
@ -126,6 +127,7 @@ in
configure = mkOption { configure = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
default = { }; default = { };
description = "Internal option";
}; };
options = mkOption { options = mkOption {
@ -257,7 +259,7 @@ in
in mkIf cfg.enable (if nixos then { in mkIf cfg.enable (if nixos then {
environment.systemPackages = [ wrappedNeovim ]; environment.systemPackages = [ wrappedNeovim ];
programs.nixvim = { programs.neovim = {
configure = configure; configure = configure;
extraConfigLua = extraConfigLua; extraConfigLua = extraConfigLua;
@ -273,14 +275,5 @@ in
extraConfig = configure.customRC; extraConfig = configure.customRC;
plugins = cfg.extraPlugins; plugins = cfg.extraPlugins;
}; };
} else { } else {}));
environment.packages = [ wrappedNeovim ];
programs.nixvim = {
configure = configure;
extraConfigLua = extraConfigLua;
};
environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
}));
} }

View file

@ -91,7 +91,7 @@ in {
}; };
grep = mkOption { grep = mkOption {
type = types.nullOr (types.oneOf [ types.submodule { type = types.nullOr (types.oneOf [ (types.submodule {
options = { options = {
command = mkOption { command = mkOption {
type = types.str; type = types.str;
@ -103,7 +103,7 @@ in {
description = "The package of the grep alternative to use"; description = "The package of the grep alternative to use";
}; };
}; };
} types.str]); }) types.str]);
default = null; default = null;
description = "A non-standard grep to use instead of the default"; description = "A non-standard grep to use instead of the default";
}; };

View file

@ -30,12 +30,14 @@ in {
sections = mkOption { sections = mkOption {
default = null; default = null;
type = with types; nullOr (submodule { type = with types; nullOr (submodule {
options = {
a = sectionOption; a = sectionOption;
b = sectionOption; b = sectionOption;
c = sectionOption; c = sectionOption;
x = sectionOption; x = sectionOption;
y = sectionOption; y = sectionOption;
z = sectionOption; z = sectionOption;
};
}); });
}; };

View file

@ -21,7 +21,7 @@ in {
description = '' description = ''
A list of function component definitions. A list of function component definitions.
You should define the functions themselves in <para>extraConfig</para> You should define the functions themselves in extraConfig
''; '';
example = '' example = ''
programs.nixvim.plugins.lightline = { programs.nixvim.plugins.lightline = {

View file

@ -64,8 +64,7 @@ in
options = { options = {
basic = mkOption { basic = mkOption {
type = types.bool; type = types.bool;
description = "operator-pending mapping. Includes 'gcc', 'gcb', 'gc[count]{motion}' description = "operator-pending mapping. Includes 'gcc', 'gcb', 'gc[count]{motion}' and 'gb[count]{motion}'";
and 'gb[count]{motion}'";
default = true; default = true;
}; };
extra = mkOption { extra = mkOption {
@ -75,8 +74,7 @@ in
}; };
extended = mkOption { extended = mkOption {
type = types.bool; type = types.bool;
description = "extended mapping. Includes 'g>', 'g<', 'g>[count]{motion}' and description = "extended mapping. Includes 'g&gt;', 'g&lt;', 'g&gt;[count]{motion}' and 'g&lt;[count]{motion}'";
'g<[count]{motion}'";
default = false; default = false;
}; };
}; };

View file

@ -23,12 +23,12 @@ in
}; };
winWidth = mkOption { winWidth = mkOption {
type = types.nullOr types.float; type = types.nullOr types.float;
description = "number of columns relative to &columns."; description = "number of columns relative to &amp;columns.";
default = null; default = null;
}; };
winHeight = mkOption { winHeight = mkOption {
type = types.nullOr types.float; type = types.nullOr types.float;
description = "number of lines relative to &lines."; description = "number of lines relative to &amp;lines.";
default = null; default = null;
}; };
borderChars = mkOption { borderChars = mkOption {
@ -38,7 +38,7 @@ in
}; };
rootMarkers = mkOption { rootMarkers = mkOption {
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
description = "Markers used to detect the project root directory for --cwd=<root>"; description = "Markers used to detect the project root directory for --cwd=&lt;root&gt;";
default = null; default = null;
}; };
opener = mkOption { opener = mkOption {

View file

@ -17,7 +17,8 @@ mkPlugin args {
lists = mkDefaultOpt { lists = mkDefaultOpt {
description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code"; description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code";
global = "startify_lists"; global = "startify_lists";
type = types.listOf (types.oneOf [types.submodule { type = types.listOf (types.oneOf [(types.submodule {
options = {
type = mkOption { type = mkOption {
type = types.str; type = types.str;
description = "The type of the list"; description = "The type of the list";
@ -33,7 +34,8 @@ mkPlugin args {
description = "Optional indices for the current list"; description = "Optional indices for the current list";
default = null; default = null;
}; };
} types.str]); };
}) types.str]);
value = val: let value = val: let
list = map (v: if builtins.isAttrs v then toLuaObject v else v) val; list = map (v: if builtins.isAttrs v then toLuaObject v else v) val;
@ -131,7 +133,7 @@ mkPlugin args {
}; };
enableSpecial = mkDefaultOpt { enableSpecial = mkDefaultOpt {
description = "Show <empty buffer> and <quit>"; description = "Show &lt;empty buffer&gt; and &lt;quit&gt;";
global = "startify_enable_special"; global = "startify_enable_special";
type = types.bool; type = types.bool;
}; };