Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
mkdir -p "${DIR_NVIM_SRC}"
curl -L "https://github.com/neovim/neovim/archive/refs/tags/${{ matrix.nvim_version }}.tar.gz" | tar zx --directory "${DIR_NVIM_SRC}/.."
cd "${DIR_NVIM_SRC}"
make doc
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that doc is successful without our changes for easier diagnosis.

make lintdoc

- run: make help-check
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Help is generated for:

Please add or update documentation when you make changes, see `:help dev-lua-doc` for docstring format.

`scripts/gen_vimdoc_config.lua` contains the manifest of help sources.
`scripts/vimdoc_config.lua` contains the manifest of help sources.

### Config And Mappings

Expand All @@ -160,7 +160,7 @@ make help-update
- `*nvim-tree-mappings-default*`
- `*nvim-tree-quickstart-help*`

- `scripts/gen_vimdoc.sh`
- `scripts/vimdoc.sh doc`
- Remove content starting at `*nvim-tree-config*`
- Generate config classes `*nvim-tree-config*`
- Generate API `*nvim-tree-api*`
Expand All @@ -175,7 +175,7 @@ make help-check

- Re-runs `make help-update`
- Checks that `git diff` is empty, to ensure that all content has been generated. This is why a stage or commit is necessary.
- Lints `doc/nvim-tree-lua.txt` using `scripts/lintdoc.sh` to check for no broken links etc.
- Lints `doc/nvim-tree-lua.txt` using `scripts/vimdoc.sh lintdoc` to check for no broken links etc.

# Windows

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ style-fix:
# utility
#
help-update:
scripts/gen_vimdoc.sh
scripts/vimdoc.sh doc
scripts/help-defaults.sh

#
# CI
# --ignore-blank-lines is used as nightly has removed unnecessary blank lines that stable (0.11.5) currently inserts
#
help-check: help-update
scripts/lintdoc.sh
scripts/vimdoc.sh lintdoc
git diff --ignore-blank-lines --exit-code doc/nvim-tree-lua.txt


Expand Down
74 changes: 0 additions & 74 deletions scripts/gen_vimdoc.sh

This file was deleted.

61 changes: 0 additions & 61 deletions scripts/lintdoc.sh

This file was deleted.

101 changes: 101 additions & 0 deletions scripts/vimdoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env sh

# Wrapper around Nvim make targets:
#
# make doc - gen_vimdoc.lua
# Generates doc/nvim-tree-lua.txt
# Uses nvim-tree sources defined in scripts/vimdoc_config.lua
# Shims above into src/gen/gen_vimdoc.lua, replacing Nvim's config.
#
# make lintdoc - lintdoc.lua
# Validates doc/nvim-tree-lua.txt
# Desired:
# - tags valid
# - links valid
# Also:
# - brand spelling, notably Nvim and Lua
#
# There are some hardcoded expectations which we work around as commented.

set -e

if [ $# -ne 1 ] || [ "${1}" != "doc" ] && [ "${1}" != "lintdoc" ]; then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the nvim make targets.

echo "usage: ${0} <doc|lintdoc>" 1>&2
exit 1
fi

DIR_NVIM_SRC_DEF="/tmp/src/neovim-stable"

if [ ! -d "lua/nvim-tree" ]; then
echo "Must be run from nvim-tree root" 1>&2
exit 1
fi

if [ -z "${DIR_NVIM_SRC}" ] && [ -d "${DIR_NVIM_SRC_DEF}" ]; then
export DIR_NVIM_SRC="${DIR_NVIM_SRC_DEF}"
fi

if [ ! -d "${DIR_NVIM_SRC}" ]; then
cat << EOM

Nvim source v0.11+ is required to run ${0}

Unavailable: ${DIR_NVIM_SRC_DEF} or \$DIR_NVIM_SRC=${DIR_NVIM_SRC}

Please:
mkdir -p ${DIR_NVIM_SRC_DEF}
curl -L 'https://github.com/neovim/neovim/archive/refs/tags/stable.tar.gz' | tar zx --directory $(dirname "${DIR_NVIM_SRC_DEF}")
or use your own e.g.
export DIR_NVIM_SRC="\${HOME}/src/neovim"

EOM
exit 1
fi

cleanup() {
# remove source link
rm -fv "${DIR_NVIM_SRC}/runtime/lua/nvim_tree"

# remove our config
rm -fv "${DIR_NVIM_SRC}/src/gen/vimdoc_config.lua"

# remove generated help
rm -fv "${DIR_NVIM_SRC}/runtime/doc/nvim-tree-lua.txt"

# revert generator if present
if [ -f "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua.org" ]; then
mv -v "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua.org" "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua"
fi
}

# clean up any previous failed runs
cleanup

# runtime/doc is hardcoded, copy the help in
cp -v "doc/nvim-tree-lua.txt" "${DIR_NVIM_SRC}/runtime/doc"

# setup doc generation
if [ "${1}" = "doc" ]; then
# runtime/lua is available, link our sources in there
# gen_vimdoc.lua doesn't like dashes in lua module names
# -> use nvim_tree instead of nvim-tree
ln -sv "${PWD}/lua/nvim-tree" "${DIR_NVIM_SRC}/runtime/lua/nvim_tree"

# modify gen_vimdoc.lua to use our config, backing up original
cp "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua" "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua.org"
sed -i -E 's/spairs\(config\)/spairs\(require("gen.vimdoc_config")\)/g' "${DIR_NVIM_SRC}/src/gen/gen_vimdoc.lua"

# copy our config
cp -v "scripts/vimdoc_config.lua" "${DIR_NVIM_SRC}/src/gen"
fi

# run from within Nvim source
cd "${DIR_NVIM_SRC}"
make "${1}"
cd -

# copy the generated help out
cp -v "${DIR_NVIM_SRC}/runtime/doc/nvim-tree-lua.txt" "doc"

# cleanup as everything succeeded
cleanup
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--nvim-tree configuration for Nvim's gen_vimdoc.lua
--Returned config is injected into the above.
--See gen_vimdoc.sh
--Execute with `make doc`, see scripts/vimdoc.sh for details.

--gen_vimdoc keys by filename: -- FIXME: Using f_base will confuse `_meta/protocol.lua` with `protocol.lua`
--Hence we must ensure that filenames are unique within each nvim.gen_vimdoc.Config[]
Expand Down
Loading