Skip to content

Commit

Permalink
docs: Add basic documentation system based on nmd
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pta2002 committed Jan 12, 2022
1 parent 69cf1b6 commit eef8417
Show file tree
Hide file tree
Showing 42 changed files with 184 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.tmp
result
51 changes: 51 additions & 0 deletions docs/default.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions docs/man-nixvim.xml
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions docs/man-pages.xml
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions docs/manual.xml
Original file line number Diff line number Diff line change
@@ -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>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 21 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

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; };
homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; };

Expand Down
19 changes: 6 additions & 13 deletions nixvim.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ nixos ? false, nixOnDroid ? false, homeManager ? false }:
{ pkgs, lib, config, ... }:
{ pkgs , lib, config, ... }:
with lib;
let
cfg = config.programs.nixvim;
Expand Down Expand Up @@ -100,8 +100,9 @@ in
};

colorscheme = mkOption {
type = types.str;
type = types.nullOr types.str;
description = "The name of the colorscheme";
default = null;
};

extraConfigLua = mkOption {
Expand All @@ -126,6 +127,7 @@ in
configure = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "Internal option";
};

options = mkOption {
Expand Down Expand Up @@ -257,7 +259,7 @@ in

in mkIf cfg.enable (if nixos then {
environment.systemPackages = [ wrappedNeovim ];
programs.nixvim = {
programs.neovim = {
configure = configure;

extraConfigLua = extraConfigLua;
Expand All @@ -273,14 +275,5 @@ in
extraConfig = configure.customRC;
plugins = cfg.extraPlugins;
};
} else {
environment.packages = [ wrappedNeovim ];
programs.nixvim = {
configure = configure;

extraConfigLua = extraConfigLua;
};

environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
}));
} else {}));
}
4 changes: 2 additions & 2 deletions plugins/git/gitgutter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ in {
};

grep = mkOption {
type = types.nullOr (types.oneOf [ types.submodule {
type = types.nullOr (types.oneOf [ (types.submodule {
options = {
command = mkOption {
type = types.str;
Expand All @@ -103,7 +103,7 @@ in {
description = "The package of the grep alternative to use";
};
};
} types.str]);
}) types.str]);
default = null;
description = "A non-standard grep to use instead of the default";
};
Expand Down
14 changes: 8 additions & 6 deletions plugins/statuslines/airline.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ in {
sections = mkOption {
default = null;
type = with types; nullOr (submodule {
a = sectionOption;
b = sectionOption;
c = sectionOption;
x = sectionOption;
y = sectionOption;
z = sectionOption;
options = {
a = sectionOption;
b = sectionOption;
c = sectionOption;
x = sectionOption;
y = sectionOption;
z = sectionOption;
};
});
};

Expand Down
2 changes: 1 addition & 1 deletion plugins/statuslines/lightline.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in {
description = ''
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 = ''
programs.nixvim.plugins.lightline = {
Expand Down
6 changes: 2 additions & 4 deletions plugins/utils/comment-nvim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ in
options = {
basic = mkOption {
type = types.bool;
description = "operator-pending mapping. Includes 'gcc', 'gcb', 'gc[count]{motion}'
and 'gb[count]{motion}'";
description = "operator-pending mapping. Includes 'gcc', 'gcb', 'gc[count]{motion}' and 'gb[count]{motion}'";
default = true;
};
extra = mkOption {
Expand All @@ -75,8 +74,7 @@ in
};
extended = mkOption {
type = types.bool;
description = "extended mapping. Includes 'g>', 'g<', 'g>[count]{motion}' and
'g<[count]{motion}'";
description = "extended mapping. Includes 'g&gt;', 'g&lt;', 'g&gt;[count]{motion}' and 'g&lt;[count]{motion}'";
default = false;
};
};
Expand Down
6 changes: 3 additions & 3 deletions plugins/utils/floaterm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ in
};
winWidth = mkOption {
type = types.nullOr types.float;
description = "number of columns relative to &columns.";
description = "number of columns relative to &amp;columns.";
default = null;
};
winHeight = mkOption {
type = types.nullOr types.float;
description = "number of lines relative to &lines.";
description = "number of lines relative to &amp;lines.";
default = null;
};
borderChars = mkOption {
Expand All @@ -38,7 +38,7 @@ in
};
rootMarkers = mkOption {
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;
};
opener = mkOption {
Expand Down
36 changes: 19 additions & 17 deletions plugins/utils/startify.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ mkPlugin args {
lists = mkDefaultOpt {
description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code";
global = "startify_lists";
type = types.listOf (types.oneOf [types.submodule {
type = mkOption {
type = types.str;
description = "The type of the list";
type = types.listOf (types.oneOf [(types.submodule {
options = {
type = mkOption {
type = types.str;
description = "The type of the list";
};
# TODO the header should be a literal lua string!
header = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional header. It's a list of strings";
default = null;
};
indices = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional indices for the current list";
default = null;
};
};
# TODO the header should be a literal lua string!
header = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional header. It's a list of strings";
default = null;
};
indices = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional indices for the current list";
default = null;
};
} types.str]);
}) types.str]);

value = val: let
list = map (v: if builtins.isAttrs v then toLuaObject v else v) val;
Expand Down Expand Up @@ -131,7 +133,7 @@ mkPlugin args {
};

enableSpecial = mkDefaultOpt {
description = "Show <empty buffer> and <quit>";
description = "Show &lt;empty buffer&gt; and &lt;quit&gt;";
global = "startify_enable_special";
type = types.bool;
};
Expand Down

0 comments on commit eef8417

Please sign in to comment.