aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/docgen.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-03-19 21:50:32 -0700
committerMichael Lingelbach <m.j.lbach@gmail.com>2021-03-19 21:50:32 -0700
commit0351d354e292d3016522081e8bca48215fba1341 (patch)
tree726f67534f5e775d38a19e6509517fbefef447a3 /scripts/docgen.lua
parentStart texlab in file's current working directory (diff)
downloadnvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.tar
nvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.tar.gz
nvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.tar.bz2
nvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.tar.lz
nvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.tar.xz
nvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.tar.zst
nvim-lspconfig-0351d354e292d3016522081e8bca48215fba1341.zip
docgen: when no description provided fallback to reading function from source
Diffstat (limited to 'scripts/docgen.lua')
-rw-r--r--scripts/docgen.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/docgen.lua b/scripts/docgen.lua
index 33f78130..42ae95cd 100644
--- a/scripts/docgen.lua
+++ b/scripts/docgen.lua
@@ -114,6 +114,23 @@ local function make_lsp_sections()
local description = ((docs or {}).default_config or {})[k]
if description and type(description) ~= 'string' then
description = inspect(description)
+ elseif not description and type(v) == "function" then
+ local info = debug.getinfo(v)
+ local file = io.open(string.sub(info.source, 2), 'r')
+
+ local fileContent = {}
+ for line in file:lines() do
+ table.insert (fileContent, line)
+ end
+ io.close(file)
+
+ local root_dir = {}
+ for i = info.linedefined, info.lastlinedefined do
+ table.insert(root_dir, fileContent[i])
+ end
+
+ description = table.concat(root_dir, '\n')
+ description = string.gsub(description, ".*function", "function")
end
return indent(2, string.format("%s = %s", k, description or inspect(v)))
end)