diff options
| author | max397574 <[email protected]> | 2021-12-09 18:41:23 +0100 | 
|---|---|---|
| committer | max397574 <[email protected]> | 2021-12-09 18:41:23 +0100 | 
| commit | 4595f296ce2040847510302d4d7da994358f9bf5 (patch) | |
| tree | cd8895b6323b72ea4464ee1fc77089268e12ad70 | |
| parent | 174c29615c106b72ce4a151afe1644683d61d03f (diff) | |
feat(github): added docgen workflow
| -rw-r--r-- | .github/workflows/docgen.yml | 61 | ||||
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | scripts/gendocs.lua | 25 | ||||
| -rw-r--r-- | scripts/minimal_init.vim | 5 | 
4 files changed, 93 insertions, 0 deletions
| diff --git a/.github/workflows/docgen.yml b/.github/workflows/docgen.yml new file mode 100644 index 0000000..d1d8cbf --- /dev/null +++ b/.github/workflows/docgen.yml @@ -0,0 +1,61 @@ +name: Generate docs + +on: workflow_dispatch + +jobs: +  build-sources: +    name: Generate docs +    runs-on: ${{ matrix.os }} +    strategy: +      fail-fast: false +      matrix: +        include: +          - os: ubuntu-20.04 +            url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz +    steps: +      - uses: actions/checkout@v2 +      - run: date +%F > todays-date +      - name: Restore cache for today's nightly. +        uses: actions/cache@v2 +        with: +          path: _neovim +          key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }} + +      - name: Prepare +        run: | +          test -d _neovim || { +            mkdir -p _neovim +            curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim" +          } +          mkdir -p ~/.local/share/nvim/site/pack/vendor/start +          git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim +          git clone --depth 1 https://github.com/tjdevries/tree-sitter-lua ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua +          ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start +      - name: Build parser +        run: | +          # We have to build the parser every single time to keep up with parser changes +          cd ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua +          mkdir -p build parser +          cc -o ./build/parser.so -I./src src/parser.c src/scanner.cc -shared -Os -lstdc++ -fPIC +          ln -s ../build/parser.so parser/lua.so +          cd - +      - name: Generating docs +        run: | +          export PATH="${PWD}/_neovim/bin:${PATH}" +          export VIM="${PWD}/_neovim/share/nvim/runtime" +          nvim --version +          make docgen +      # inspired by nvim-lspconfigs +      - name: Update documentation +        env: +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +          COMMIT_MSG: | +            [docgen] Update doc/startup.txt +            skip-checks: true +        run: | +          git config user.email "actions@github" +          git config user.name "Github Actions" +          git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git +          git add doc/ +          # Only commit and push if we have changes +          git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF}) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3dbeb14 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +docgen: +	nvim --headless --noplugin -u scripts/minimal_init.vim -c "luafile ./scripts/gendocs.lua" -c 'qa' diff --git a/scripts/gendocs.lua b/scripts/gendocs.lua new file mode 100644 index 0000000..246f9e9 --- /dev/null +++ b/scripts/gendocs.lua @@ -0,0 +1,25 @@ +local docgen = require("docgen") + +local docs = {} + +docs.test = function() +  -- TODO: Fix the other files so that we can add them here. +  local input_files = { +    "./lua/startup/functions.lua", +  } + +  local output_file = "./doc/startup.txt" +  local output_file_handle = io.open(output_file, "w") + +  for _, input_file in ipairs(input_files) do +    docgen.write(input_file, output_file_handle) +  end + +  output_file_handle:write(" vim:tw=78:ts=8:ft=help:norl:\n") +  output_file_handle:close() +  vim.cmd([[checktime]]) +end + +docs.test() + +return docs diff --git a/scripts/minimal_init.vim b/scripts/minimal_init.vim new file mode 100644 index 0000000..56ca396 --- /dev/null +++ b/scripts/minimal_init.vim @@ -0,0 +1,5 @@ +set rtp+=. +set rtp+=../plenary.nvim/ +set rtp+=../tree-sitter-lua/ + +runtime! plugin/plenary.vim | 
