You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/panvimdoc.md
+115Lines changed: 115 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,121 @@ toc: true
9
9
Write documentation in [pandoc markdown](https://pandoc.org/MANUAL.html).
10
10
Generate documentation in vimdoc.
11
11
12
+
# Motivation
13
+
14
+
Writing documentation is hard.
15
+
Writing documentation for vim plugins is an additional hassle.
16
+
Making writing vim plugin documentation frictionless can be useful.
17
+
18
+
Writing documentation in markdown and converting it to vimdoc can help toward that goal.
19
+
This way, plugin authors will have to write documentation just once as part of the README of the project, and have the vim documentation autogenerated.
20
+
21
+
Writing vim documentation requires conforming to a few simple rules.
22
+
Although `vimdoc` is not a well defined spec, it does have some nice syntax highlighting and features like tags and links when a text file is in `vimdoc` compatible format and when the `filetype=help` in vim.
23
+
Also, typically, while vim documentation is just plain text files, they are usually formatted well using whitespace.
24
+
Preserving these features and characteristics is important.
25
+
26
+
See [References](#references) for more information.
27
+
28
+
It would be nice to write documentation in Markdown and convert to vimdoc.
29
+
[@mjlbach](https://github.com/mjlbach) has already implemented a neovim treesitter markdown to vimdoc converter that works fairly well.
30
+
This approach is close to ideal. There are no dependencies ( except for the Markdown treesitter parser ). While it appears that the markdown parser may cause crashes, I have not experienced any in my use. It is neovim only but you can use this on github actions even for a vim plugin documentation.
31
+
32
+
I found two other projects that do something similar, again linked in the references.
33
+
As far as I can tell, these projects are all in use and actively maintained and these projects may suit your need.
34
+
35
+
However, none of these projects use Pandoc.
36
+
Pandoc Markdown supports a wide number of features.
37
+
Most importantly, it supports a range of Markdown formats and flavors.
38
+
And, Pandoc has lua filters and a custom output writer that can be configured in lua.
39
+
Pandoc filters are easy to write and maintain too.
40
+
41
+
This project aims to write a specification in Pandoc Markdown, and take advantage of Pandoc filters, to convert a Markdown file to a vim documentation help file.
42
+
43
+
# Goals:
44
+
45
+
- Markdown file must be readable when the file is presented as the README on GitHub / GitLab.
46
+
- Markdown file converted to HTML using Pandoc must be web friendly and render appropriately (if the user chooses to do so).
47
+
- Vim documentation generated must support links and tags.
48
+
- Vim documentation generated should be aesthetically pleasing to view, in vim and as a plain text file.
49
+
- This means using column and spacing appropriately.
50
+
- Use built in Vim documentation as guidelines but not rules.
51
+
52
+
# Features
53
+
54
+
- Autogenerate title for vim documentation
55
+
- Generate links and tags
56
+
- Support markdown syntax for tables
57
+
- Support raw vimdoc syntax where ever needed for manual control.
58
+
59
+
# Specification
60
+
61
+
The specification is described in [panvimdoc.md](./doc/panvimdoc.md) along with examples.
62
+
The generated output is in [panvimdoc.txt](./doc/panvimdoc.txt).
63
+
The reference implementation of the Pandoc lua filter is in [panvimdoc.lua](./scripts/panvimdoc.lua).
64
+
65
+
If you would like to contribute to the specification please feel free to comment on this issue: <https://github.com/kdheepak/panvimdoc/issues/1>.
66
+
67
+
# Usage
68
+
69
+
```bash
70
+
pandoc -t scripts/panvimdoc.lua ${INPUT}${OUTPUT}
71
+
```
72
+
73
+
The following are the metadata fields that the custom writer uses:
74
+
75
+
-`project` (String) _required_: This is typically the plugin name. This is prefixed to all generated tags
76
+
-`vimdoctitle` (String) _required_: This is the name of the documentation file that you want to generate
77
+
-`vimversion` (String) _optional_: The version vim / neovim that the plugin is targeting. If not present, the version of vim in the available environment is used.
78
+
-`toc` (Boolean) _optional_: Whether to generate table of contents or not
79
+
80
+
Example:
81
+
82
+
```markdown
83
+
---
84
+
project: panvimdoc
85
+
vimdoctitle: panvimdoc.txt
86
+
vimversion: Neovim v0.5.0
87
+
toc: true
88
+
---
89
+
```
90
+
91
+
## Using Github Actions
92
+
93
+
Add the following to `./.github/workflows/pandocvim.yml`:
94
+
95
+
```yaml
96
+
name: panvimdoc
97
+
98
+
on: [push]
99
+
100
+
jobs:
101
+
custom_test:
102
+
runs-on: ubuntu-latest
103
+
name: pandoc to vimdoc
104
+
steps:
105
+
- uses: actions/checkout@v2
106
+
- name: PanVimDoc
107
+
uses: kdheepak/panvimdoc@v1
108
+
with:
109
+
pandoc: INPUT_FILENAME.md
110
+
vimdoc: doc/OUTPUT_FILENAME.txt
111
+
- uses: stefanzweifel/git-auto-commit-action@v4
112
+
with:
113
+
commit_message: "Auto generate docs"
114
+
branch: ${{ github.head_ref }}
115
+
```
116
+
117
+
Choose `INPUT_FILENAME` and `OUTPUT_FILENAME` appropriately.
0 commit comments