Skip to content
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

build: remove docgen.sh #3574

Merged
merged 1 commit into from
Jan 21, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
version: nightly
- name: Run docgen
run: |
scripts/docgen.sh
scripts/docgen.lua
- name: Commit changes
env:
COMMIT_MSG: |
Expand Down
22 changes: 15 additions & 7 deletions scripts/docgen.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env -S nvim -l
local root = vim.trim(vim.system({ 'git', 'rev-parse', '--show-toplevel' }):wait().stdout)
vim.opt.rtp:append(root)

require 'lspconfig'
local configs = require 'lspconfig.configs'
local util = require 'lspconfig.util'
Expand Down Expand Up @@ -89,7 +93,7 @@ local function require_all_configs()
vim.env.XDG_CACHE_HOME = '/home/user/.cache'

-- Configs are lazy-loaded, tickle them to populate the `configs` singleton.
for _, v in ipairs(vim.fn.glob('lua/lspconfig/configs/*.lua', true, true)) do
for _, v in ipairs(vim.fn.glob(vim.fs.joinpath(root, 'lua/lspconfig/configs/*.lua'), true, true)) do
local module_name = v:gsub('.*/', ''):gsub('%.lua$', '')
configs[module_name] = require('lspconfig.configs.' .. module_name)
end
Expand All @@ -107,7 +111,7 @@ local function make_lsp_sections()
local template_def = template_object.config_def
local docs = template_def.docs
-- "lua/lspconfig/configs/xx.lua"
local config_file = ('lua/lspconfig/configs/%s.lua'):format(config_name)
local config_file = (vim.fs.joinpath(root, 'lua/lspconfig/configs/%s.lua')):format(config_name)

local params = {
config_name = config_name,
Expand Down Expand Up @@ -155,13 +159,14 @@ local function make_lsp_sections()
end
end
io.close(file)
local config_relpath = vim.fs.relpath(root, config_file)

-- XXX: "../" because the path is outside of the doc/ dir.
return ('- `%s` source (use "gF" to visit): [../%s:%d](../%s#L%d)'):format(
k,
config_file,
config_relpath,
linenr,
config_file,
config_relpath,
linenr
)
end),
Expand Down Expand Up @@ -284,14 +289,17 @@ local function generate_readme(template_file, params)
local input_template = readfile(template_file)
local readme_data = template(input_template, params)

local writer = assert(io.open('doc/configs.md', 'w'))
local conf_md = vim.fs.joinpath(root, 'doc/configs.md')
local conf_txt = vim.fs.joinpath(root, 'doc/configs.txt')

local writer = assert(io.open(conf_md, 'w'))
writer:write(readme_data)
writer:close()
vim.loop.fs_copyfile('doc/configs.md', 'doc/configs.txt')
vim.loop.fs_copyfile(conf_md, conf_txt)
end

require_all_configs()
generate_readme('scripts/docs_template.md', {
generate_readme(vim.fs.joinpath(root, 'scripts/docs_template.md'), {
implemented_servers_list = make_implemented_servers_list(),
lsp_server_details = make_lsp_sections(),
})
2 changes: 0 additions & 2 deletions scripts/docgen.sh

This file was deleted.

Loading