diff --git a/Makefile b/Makefile index 5656e7b..5cf4a10 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ MINIMAL_INIT := ./scripts/minimal_init.vim +DOC_GEN_SCRIPT := ./scripts/docs.lua +PLUGIN_DIR := lua/ + test: nvim --headless --noplugin -u ${MINIMAL_INIT} \ - -c "PlenaryBustedDirectory lua/ { minimal_init = '${MINIMAL_INIT}' }" + -c "PlenaryBustedDirectory ${PLUGIN_DIR} { minimal_init = '${MINIMAL_INIT}' }" +docs: + nvim --headless --noplugin -u ${MINIMAL_INIT} \ + -c "luafile ${DOC_GEN_SCRIPT}" -c 'qa' diff --git a/scripts/docs.lua b/scripts/docs.lua new file mode 100644 index 0000000..17921ef --- /dev/null +++ b/scripts/docs.lua @@ -0,0 +1,33 @@ +local docgen = require "docgen" + +local docs = {} + +docs.test = function() + -- Filepaths that should generate docs + local input_files = { + "./lua/unclutter/init.lua", + "./lua/unclutter/config.lua", + } + + -- Maybe sort them that depends what you want and need + table.sort(input_files, function(a, b) + return #a < #b + end) + + -- Output file + local output_file = "./doc/unclutter.txt" + local output_file_handle = io.open(output_file, "w") + assert(output_file_handle, "Could not open " .. output_file) + + 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 index 3d4d7c1..7456fb2 100644 --- a/scripts/minimal_init.vim +++ b/scripts/minimal_init.vim @@ -1,6 +1,13 @@ -let plenary_path = stdpath('data') . '/lazy/plenary.nvim/' -execute 'set rtp+=' . plenary_path +let plugins_path = stdpath('data') . '/lazy' + + set rtp+=. +" for tests +execute 'set rtp+=' . plugins_path . '/plenary.nvim/' +" for docs generation +execute 'set rtp+=' . plugins_path . '/tree-sitter-lua/' + runtime! plugin/plenary.vim runtime! plugin/unclutter.lua +runtime! plugin/ts_lua.lua