-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(API): add emmylua annotations #378
base: master
Are you sure you want to change the base?
Conversation
I agree, it makes sense to have the documentation next to the code, should prevent it becoming outdated. It would be really cool to automatically generate the entries in |
I was looking earlier at There's also this script from neovim-core, https://github.com/neovim/neovim/blob/8055f9857b8e384634d457533dfdb08618fc36f0/scripts/gen_vimdoc.py#L2 Lastly, I had an idea to leverage LSP for this, but it's a bit fiddley (redirect local write_tmpfile = function(data)
local tmpname = os.tmpname()
local file = io.open(tmpname, "w")
if type(data) == "table" then
data = table.concat(data, "\n")
end
file:write(data)
file:close()
return tmpname
end
local util = require "vim.lsp.util"
vim.lsp.handlers["textDocument/hover"] = function(_, result, ctx, config)
config = config or {}
config.focus_id = ctx.method
if not (result and result.contents) then
-- return { 'No information available' }
return
end
local markdown_lines = util.convert_input_to_markdown_lines(result.contents)
markdown_lines = util.trim_empty_lines(markdown_lines)
if vim.tbl_isempty(markdown_lines) then
-- return { 'No information available' }
return
end
local tmpfile = write_tmpfile(markdown_lines) -- can also just copy the lines into some register instead
print(tmpfile)
vim.cmd([[edit ]] .. tmpfile)
return tmpfile
end |
LDoc looks promising, but I'm surprised that there is no tool that straightforwardly generates markdown |
Here's my script so far, just give it a valid bufnr (check Here are the results, which as you can see need better formatting, but that's why I included the raw response as well I'm also counting on the fact that you have more experience with string manipulation 😃 |
Oh wow, that looks pretty good already 👍👍 |
There's also this treesitter module available for generating documentation thorough Emmy |
Interesting, but it only generates vimdoc (afaict) :/ |
Wonder why this one wasn't merged. Nice PR. Many projects are underdocumented. |
Hey @kylo252, are you fine with merging this as-is (or, more-or-less as-is, after looking into how up to date it still is)? |
I think it might be better to let the API documentation live inside the code, and it also benefits from LSP capabilities
TODO