-
Hello, @sumneko. First of all I want to say that I admire your work, I like it very much! Your tool is almost perfect and the only thing I miss is the local documentation generator. Hints in code are cool, but sometimes I want to look at my project "from above" to clearly see the API and the hierarchy of all the modules I wrote. Some time ago I started a project that does it! It parses the code and generates markdown documentation like this. The only problem is that it uses my own comment format and not emmylua. To be honest I like my format much more. It's simpler and more compact but that's not the point now :) Now I've set myself the task of adapting my documentation generator to emmylua. I want to write additional parser. And before I start working on the emmylua parser, I'd like to know, maybe is there's a way to just get the parsed project model as lua table directly from your server? It would save me a lot of time. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You may use the following plugin, learn plugin here: https://github.com/sumneko/lua-language-server/wiki/Plugin local files = require 'files'
local util = require 'utility'
local furi = require 'file-uri'
local fs = require 'bee.filesystem'
local function isEnableKey(k)
if type(k) ~= 'string' then
return true
end
if k == 'parent'
or k == 'typeGeneric'
or k == 'fields'
or k:find '_'
or k:find 'Cache'
or k:find 'bind' then
return false
end
return true
end
local function copyData(t)
local nt = {}
for k, v in pairs(t) do
if isEnableKey(k) then
if type(v) == 'table' then
nt[k] = copyData(v)
else
nt[k] = v
end
end
end
return nt
end
fs.create_directories(fs.path(LOGPATH) / 'LuaDoc')
files.watch(function (ev, uri)
if ev == 'update' then
local state = files.getState(uri)
local docs = {}
for i, doc in ipairs(state.ast.docs) do
docs[i] = copyData(doc)
end
local filepath = furi.decode(uri)
local filename = filepath:match '[^/\\]+$'
util.saveFile(LOGPATH .. '/' .. filename, 'return ' .. util.dump(docs))
end
end) |
Beta Was this translation helpful? Give feedback.
You may use the following plugin, learn plugin here: https://github.com/sumneko/lua-language-server/wiki/Plugin