Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrcjkb/vimcats
A CLI to generate vim/nvim help doc from LuaCATS. Forked from lemmy-help.
https://github.com/mrcjkb/vimcats
doc help lua luacats vimdoc
Last synced: about 1 month ago
JSON representation
A CLI to generate vim/nvim help doc from LuaCATS. Forked from lemmy-help.
- Host: GitHub
- URL: https://github.com/mrcjkb/vimcats
- Owner: mrcjkb
- License: gpl-2.0
- Created: 2023-10-18T19:25:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-11T09:00:11.000Z (2 months ago)
- Last Synced: 2024-09-28T06:20:20.793Z (about 2 months ago)
- Topics: doc, help, lua, luacats, vimdoc
- Language: Rust
- Homepage:
- Size: 330 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
:cat2: vimCATS :book:
A CLI to generate vimdoc from LuaCATS. Forked from lemmy-help.
![vimcats](https://user-images.githubusercontent.com/24727447/164423469-b26fea39-2ef7-497c-8156-5a4c01bc30f8.gif "Generating help docs")
### What?
`vimcats` is a LuaCATS parser as well as a CLI
which takes that parsed tree and converts it into vim help docs.### Installation
[![Packaging status](https://repology.org/badge/vertical-allrepos/vimcats.svg)](https://repology.org/project/vimcats/versions)
- Using `cargo`
```bash
cargo install vimcats --features=cli
```### LuaCATS
To properly generate docs you should follow the luaCATS spec.
The parser is capable of parsing most (not all) of the LuaCATS syntax.
You can read the following doc which can give you an idea on how to
properly write LuaCATS annotations.- [Writing LuaCATS annotations](./luaCATS.md)
### Usage
Using the CLI is simple just give it the path to the lua files;
it will parse them and prints help doc to `stdout`.```bash
vimcats /path/to/{first,second,third}.lua > doc/PLUGIN_NAME.txt
```### CLI
```text
vimcatsUSAGE:
vimcats [FLAGS] [OPTIONS] ...ARGS:
... Path to lua filesFLAGS:
-h, --help Print help information
-v, --version Print version information
-M, --no-modeline Don't print modeline at the end
-f, --prefix-func Prefix function name with ---@mod name
-a, --prefix-alias Prefix ---@alias tag with return/---@mod name
-c, --prefix-class Prefix ---@class tag with return/---@mod name
-t, --prefix-type Prefix ---@type tag with ---@mod name
--expand-opt Expand '?' (optional) to 'nil' typeOPTIONS:
-i, --indent Controls the indent width [default: 4]
-l, --layout Vimdoc text layout [default: 'default']
- "default" : Default layout
- "compact[:n=0]" : Aligns [desc] with
and uses {n}, if provided, to indent the
following new lines. This option only
affects ---@field and ---@param tags
- "mini[:n=0]" : Aligns [desc] from the start
and uses {n}, if provided, to indent the
following new lines. This option affects
---@field, ---@param and ---@return tagsUSAGE:
vimcats /path/to/first.lua /path/to/second.lua > doc/PLUGIN_NAME.txt
vimcats -c -a /path/to/{first,second,third}.lua > doc/PLUGIN_NAME.txt
vimcats --layout compact:2 /path/to/plugin.lua > doc/PLUGIN_NAME.txtNOTES:
- The order of parsing + rendering is relative to the given files
```### CI
```yaml
name: vimcatson: [push]
env:
PLUGIN_NAME: plugin-namejobs:
docs:
runs-on: ubuntu-latest
name: luaCATS to vimdoc
steps:
- uses: actions/checkout@v4- name: Install Rust
uses: dtolnay/rust-toolchain@master- name: Install vimcats
run: cargo install vimcats --features=cli- name: Generate docs
run: vimcats [args] > doc/${{env.PLUGIN_NAME}}.txt- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.head_ref }}
commit_message: "chore(docs): auto-generate vimdoc"
file_pattern: doc/*.txt
```### Nix flake
This project provides a flake so you can use it with frameworks
like [git-hooks.nix](https://github.com/cachix/git-hooks.nix).Here is basic example:
> [!NOTE]
>
> You will likely want to ajust the flake to be used
> with multiple systems.```nix
{
inputs = {
git-hooks.url = "github:cachix/git-hooks.nix";
vimcats.url = "github:mrcjkb/vimcats";
};
outputs = {
self,
nixpkgs,
git-hooks,
vimcats,
...
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
docgen = final.writeShellApplication {
name = "docgen";
runtimeInputs = [
inputs.vimcats.packages.${final.system}.default
];
text = ''
mkdir -p doc
vimcats [args] > doc/.txt
'';
};
git-hooks-check = git-hooks.lib.${system}.run {
src = self;
hooks = {
docgen = {
enable = true;
name = "docgen";
entry = "${pkgs.docgen}/bin/docgen";
files = "\\.(lua)$";
pass_filenames = false;
};
};
};
in {
devShells.${system}.default = {
pkgs.mkShell {
buildInputs = [
docgen
];
shellHook = ''
# Installs a docgen pre-commit hook
${git-hooks-check.shellHook}
'';
};
};
checks.${system} = {
inherit git-hooks-check;
};
};
}
```### Credits
- [lemmy-help](https://github.com/numToStr/lemmy-help)
- TJ's [docgen](https://github.com/tjdevries/tree-sitter-lua#docgen) module
- [mini.doc](https://github.com/echasnovski/mini.nvim#minidoc) from `mini.nvim` plugin### License
This project is [licensed](./LICENSE) according to GPL version 2
or (at your option) any later version.lemmy-help (from which this project is forked)
is [licensed](./lemmy-help-LICENSE) according to MIT.