• Stars
    star
    242
  • Rank 167,090 (Top 4 %)
  • Language
    CSS
  • License
    MIT License
  • Created about 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Write documentation in pandoc markdown. Generate documentation in vimdoc.

panvimdoc

Docs Build

Write documentation in pandoc markdown. Generate documentation in vimdoc.

image

::: center This software is released under a MIT License. :::

TLDR

  1. Choose a name for your project, i.e. ${VIMDOC_PROJECT_NAME}. See .github/workflows/panvimdoc.yml as an example.

  2. Add the following to ./.github/workflows/panvimdoc.yml:

    name: panvimdoc
    
    on: [push]
    
    jobs:
      docs:
        runs-on: ubuntu-latest
        name: pandoc to vimdoc
        steps:
          - uses: actions/checkout@v2
          - uses: kdheepak/panvimdoc@main
            with:
              vimdoc: ${VIMDOC_PROJECT_NAME}
          - uses: stefanzweifel/git-auto-commit-action@v4
            with:
              commit_message: "Auto generate docs"
              branch: ${{ github.head_ref }}
  3. README.md gets converted to ./doc/${VIMDOC_PROJECT_NAME}.txt and committed to the repo.

Usage

Using Github Actions

Create an empty doc file:

touch doc/${VIMDOC_PROJECT_NAME}.txt
git commit -am "Add empty doc"
git push

You don't actually need the file, only the doc folder but it is probably easiest to create a file.

Then add the following to ./.github/workflows/panvimdoc.yml:

name: panvimdoc

on: [push]

jobs:
  docs:
    runs-on: ubuntu-latest
    name: pandoc to vimdoc
    steps:
      - uses: actions/checkout@v2
      - name: panvimdoc
        uses: kdheepak/panvimdoc@main
        with:
          vimdoc: ${VIMDOC_PROJECT_NAME} # Output vimdoc project name (required)
          # The following are all optional
          pandoc: "README.md" # Input pandoc file
          version: "NVIM v0.8.0" # Vim version number
          toc: true # Table of contents
          description: "" # Project Description
          demojify: false # Strip emojis from the vimdoc
          dedupsubheadings: true # Add heading to subheading anchor links to ensure that subheadings are unique
          treesitter: true # Use treesitter for highlighting codeblocks
          ignorerawblocks: true # Ignore raw html blocks in markdown when converting to vimdoc
          docmapping: false # Use h4 headers as mapping docs
          docmappingprojectname: true # Use project name in tag when writing mapping docs
          shiftheadinglevelby: 0 # Shift heading levels by specified number
          incrementheadinglevelby: 0 # Increment heading levels by specified number

The only required thing for you to do is to choose a VIMDOC_PROJECT_NAME appropriately. This is usually the name of the plugin or the documentation file without the .txt extension. For example, the following:

- name: panvimdoc
  uses: kdheepak/panvimdoc@main
  with:
    vimdoc: panvimdoc

will output a file doc/panvimdoc.txt and the vim help tag for it will be panvimdoc using the main branch of the repository.

All the other options are optional.

It is recommended to pin to an exact version so you can be confident that no surprises occur for you or your users. See https://github.com/kdheepak/panvimdoc/releases/latest for which version to use. Once you pick a version, you can pin it like so:

- name: panvimdoc
  uses: kdheepak/[email protected]

For an example of how this is used, see one of the following workflows:

Or see any of the packages here that depend on this action: https://github.com/kdheepak/panvimdoc/network/dependents

If you are interested in making your vim plugin documentation available as a HTML page, check out .github/workflows/docs.yml file.

name: docs

on:
  push:
    branches: main

permissions:
  contents: write

jobs:
  publish-gh-page:
    runs-on: ubuntu-latest
    steps:
      - name: checkout code
        uses: actions/checkout@v3
      - name: pandoc markdown to html
        uses: docker://pandoc/latex:3.1
        with:
          args: >-
            --katex
            --from markdown+tex_math_single_backslash
            --to html5+smart
            --template="./scripts/template.html5"
            --css="/panvimdoc/css/theme.css"
            --css="/panvimdoc/css/skylighting-solarized-theme.css"
            --toc
            --wrap=none
            --metadata title="panvimdoc"
            doc/panvimdoc.md
            --lua-filter=scripts/include-files.lua
            --lua-filter=scripts/skip-blocks.lua
            -t html
            -o public/index.html
      - name: deploy to GitHub pages
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          branch: gh-pages
          folder: public

Using it manually

The ./panvimdoc.sh script runs pandoc along with all the filters and custom output writer.

$ ./panvimdoc.sh
Usage: ./panvimdoc.sh --project-name PROJECT_NAME --input-file INPUT_FILE --vim-version VIM_VERSION --toc TOC --description DESCRIPTION --dedup-subheadings DEDUP_SUBHEADINGS --treesitter TREESITTER

Arguments:
  --project-name: the name of the project
  --input-file: the input markdown file
  --vim-version: the version of Vim that the project is compatible with
  --toc: 'true' if the output should include a table of contents, 'false' otherwise
  --description: a description of the project
  --dedup-subheadings: 'true' if duplicate subheadings should be removed, 'false' otherwise
  --demojify: 'false' if emojis should not be removed, 'true' otherwise
  --treesitter: 'true' if the project uses Tree-sitter syntax highlighting, 'false' otherwise
  --ignore-rawblocks: 'true' if the project should ignore HTML raw blocks, 'false' otherwise
  --doc-mapping: 'true' if the project should use h4 headers as mapping docs, 'false' otherwise
  --doc-mapping-project-name: 'true' if tags generated for mapping docs contain project name, 'false' otherwise
  --shift-heading-level-by: 0 if you don't want to shift heading levels , n otherwise
  --increment-heading-level-by: 0 if don't want to increment the starting heading number, n otherwise

You will need pandoc v3.0.0 or greater for this script to work.

Motivation

Writing user-friendly documentation is important for every successful software project. This is particularly true when writing documentation for users in the world of vim plugins.

The process of writing and maintaining this documentation can often be a cumbersome, time-consuming task. This project is aims to make that process a little bit easier by allowing anyone to write documentation in markdown (or any format Pandoc supports) and converting it to vimdoc automatically. This way, plugin authors will have to write documentation just once (for example, as part of the README of the project), and the vim documentation can be autogenerated.

Rationale

  1. Simplicity: Writing in Markdown is often more intuitive for developers. By converting from Markdown to vimdoc, authors can maintain the simplicity of Markdown while adhering to the vimdoc standards.
  2. Unified Documentation: Plugin authors can write their documentation just once (such as in the project's README) and automatically generate vim documentation, ensuring consistency and saving time.
  3. Preserving Vim Features: Vimdoc isn’t just plain text; it supports syntax highlighting, tags, links, and careful formatting using whitespace. It's essential to preserve these features when converting to ensure the quality and usefulness of the documentation. See https://vimhelp.org/helphelp.txt.html#help-writing or @nanotree's project for more information.
  4. Leveraging Pandoc: Unlike existing solutions, this project leverages Pandoc's wide range of features, including support for multiple Markdown flavors and easy-to-write custom filters in Lua.
  5. Interoperability: The choice of Pandoc allows for enhanced flexibility, making it easier to extend functionality or even adapt the converter for other documentation formats in the future.

Background

Writing documentation in Markdown and converting it to vimdoc is not a novel idea.

For example, ibhagwan/ts-vimdoc.nvim is an implementation a neovim treesitter based markdown to vimdoc converter that works fairly well. There are no dependencies except for the Markdown treesitter parser. It is neovim only but you can use this on github actions even for a vim plugin documentation.

There's also wincent/docvim which is written in Haskell. Finally there's FooSoft/md2vim which is written in Go.

None of these projects use Pandoc. Pandoc Markdown supports a wide number of features: See https://pandoc.org/MANUAL.html for more information. Most importantly, it supports a range of Markdown formats and flavors. And, Pandoc has filters and a custom output writer that can be configured in lua. Pandoc filters can extend the capability of Pandoc with minimal lua scripting, and these are very easy to write and maintain too.

That means, with this project, you can write your Vim documentation in Markdown, RestructuredText, AsciiDoc, etc and convert it to VimDoc, PDF, Word, HTML etc.

Goals

By offering a specification and reference implementation for converting Pandoc Markdown to vimdoc, this project aims to reduce friction in the documentation process for vim plugin authors.

Here are the specific goals that guide this project:

  • Readability: The Markdown files must render correctly when presented as README files on platforms like GitHub, GitLab, or SourceHut.
  • Web-Friendly HTML: If converted to HTML using Pandoc, the Markdown files must be web-friendly and render appropriately.
  • VimDoc Features: The generated vim documentation must support essential features like links and tags.
  • Aesthetically Pleasing: The vim documentation must not only be functional but also visually pleasing in both vim and plain text files. This includes the appropriate use of columns and spacing.
  • Guidelines: While the format of built-in Vim documentation is a valuable reference, it is used as guidelines rather than strict rules.

Features

This project offers a comprehensive suite of features designed to streamline the conversion process from Markdown to vimdoc:

  • Automatically generates titles for vim documentation.
  • Creates a table of contents to enhance navigation within the document.
  • Automatically handles the generation of links and tags.
  • Maintains markdown syntax for tables, ensuring proper rendering.
  • Allows for manual control through raw vimdoc syntax where necessary.
  • Offers the ability to include multiple Markdown files, providing flexibility in documentation structure.

Specification

The specification is described in panvimdoc.md along with examples. The generated output is in panvimdoc.txt. The reference implementation of the Pandoc lua filter is in panvimdoc.lua. See panvimdoc.sh for how to use this script, or check the Usage section.

If you would like to contribute to the specification, or if you have feature requests or opinions, please feel free to comment here: #11.

References

More Repositories

1

taskwarrior-tui

`taskwarrior-tui`: A terminal user interface for taskwarrior
Rust
1,398
star
2

lazygit.nvim

Plugin for calling lazygit from within neovim.
Lua
1,317
star
3

tabline.nvim

A "buffer and tab" tabline for neovim
Lua
232
star
4

cmp-latex-symbols

Add latex symbol support for nvim-cmp.
Lua
125
star
5

TerminalUserInterfaces.jl

Terminal User Interfaces in Julia.
Julia
93
star
6

monochrome.nvim

A monochrome colorscheme for neovim
Lua
88
star
7

JuliaFormatter.vim

A (N)Vim plugin for formatting Julia code using JuliaFormatter.jl.
Vim Script
70
star
8

Presentation.jl

Julia
41
star
9

c3.py

Commit Counter Chart is a Python Flask app to view git history using D3.js
HTML
39
star
10

FIGlet.jl

Julia
26
star
11

awesome-advent-of-code

19
star
12

dotfiles

Shell
16
star
13

ReverseStackTraces.jl

Display stack traces in reverse order
Julia
13
star
14

github-release

github-release is a command line utility tool that allows you to easily manage your releases on GitHub.
Nim
13
star
15

nvim-dap-julia

Lua
13
star
16

moonshine.nvim

Rust
12
star
17

keystrokes.nvim

Show keystrokes in neovim.
Lua
11
star
18

PyomoGettingStarted

IPython notebooks that illustrate the Pyomo optimization modeling software
Python
10
star
19

JET.nvim

Julia
10
star
20

pandoc-ieee-template

TeX
9
star
21

psst

Python
9
star
22

pelican-smoothie

Pelican-Smoothie - A Bootstrap theme for the static site generator Pelican
CSS
8
star
23

think-git

A intermediate git tutorial
HTML
7
star
24

PySyntax.jl

(*deprecated*) PySyntax.jl allows Python-like syntax in Julia. Py.jl provides a light wrapper on top of PyCall.jl in the form of a macro.
Jupyter Notebook
6
star
25

TERMIOS.jl

This Julia package provides an TERMIOS interface to the POSIX calls for tty I/O control.
Julia
6
star
26

Pandoc.jl

Pandoc Interface and Types in Julia
Julia
5
star
27

Notcurses.jl

Julia
5
star
28

blog

My personal thoughts and notes
TeX
4
star
29

sveltekit-shiki-endpoint-error

JavaScript
4
star
30

tasker_sl4a

Python Code that parses public Google Calendar feed for events and event location
Python
4
star
31

juliacon2020-terminal-user-interfaces-in-julia

Julia
3
star
32

quarto-svgbob

Render svgbob diagrams directly in your quarto documents.
Lua
3
star
33

mpld3_plugins

Python
3
star
34

ts-julia-actions

Lua
3
star
35

libcrossterm

libcrossterm is a Rust cdylib library providing a C-API to access the excellent crossterm crate.
Rust
3
star
36

pandoc-paper

CSS
3
star
37

Crossterm.jl

Julia
2
star
38

fono

Find number of optimal order from websites considering shipping costs
Python
2
star
39

jupyter-notebook

HTML
2
star
40

kdheepak.github.io

TeX
2
star
41

GeekToolBash

A bash script to download random Calvin and Hobbes comic strips from gocomics.com/calvinandhobbes/
Shell
2
star
42

remark-svgbob

Convert markdown codeblock with ascii diagram to svg using svgbob wasm
JavaScript
2
star
43

juliacon2019-open-source-power-system-production-cost-modeling-in-julia

Jupyter Notebook
2
star
44

Tasker_WhatsPush

Forward Whatsapp Messages to and Reply from Desktop
1
star
45

pandasplexos

Python
1
star
46

mwe-swig-python3-anaconda

C
1
star
47

game-of-life

Rust
1
star
48

juliacon2019-why-writing-c-interfaces-in-julia-is-so-easy-asterisk

Julia
1
star
49

adventofcode

Julia
1
star
50

iou

Solve for the optimally minimum number of transactions to settle debts and expenses with friends
Python
1
star
51

pandoc-ipynb

HTML
1
star
52

opendss-mirror

Pascal
1
star
53

interactive-data-visualizations-with-bokeh

Interactive Data Visualizations with Bokeh
JavaScript
1
star
54

license

`license` is a command line utility tool that allows you to easily add licenses to your open source projects
Nim
1
star
55

mergetool.nvim

1
star
56

d2-markdown-preview

d2 vscode markdown preview extension
TypeScript
1
star
57

nvim

Lua
1
star