Skip to content

Commit

Permalink
fix(doc): generate link instead of tag in ToC
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hui committed Dec 8, 2023
1 parent 2c93274 commit 3f5a5bb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/build-options-docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ options:
---@field options Option[]|nil
---@field shortname string
---@field tag string
---@field link string
---@field title_line string

---@class Option
Expand Down Expand Up @@ -105,7 +106,14 @@ for _, filename in ipairs(files) do
else
--- Current module
---@type OptionsModule
local module = { filename = filename, docs = {}, shortname = "Options from " .. filename, tag = "", title_line = "" }
local module = {
filename = filename,
docs = {},
shortname = "Options from " .. filename,
tag = "",
link = "",
title_line = ""
}

--- Current option
---@type Option
Expand Down Expand Up @@ -218,6 +226,7 @@ for _, module in ipairs(modules) do

module.tag = #opts.tag_prefix > 0 and string.format("%s.%s", opts.tag_prefix, module.prefix) or module.prefix or
"ERROR.NO.TAG"
module.link = string.format("|%s|", module.tag)
module.tag = string.format("*%s*", module.tag)
module.title_line = string.format("%s%s%s", module.shortname,
string.rep(" ", math.max(opts.width_num - (#module.shortname + #module.tag), 2)), module.tag)
Expand Down Expand Up @@ -301,7 +310,7 @@ if opts.toc then
for _, module in ipairs(modules) do
if #module.options > 0 then
print(string.format("%s %s %s", module.shortname,
string.rep(".", math.max(opts.width_num - 2 - (#module.shortname + #module.tag), 0)), module.tag))
string.rep(".", math.max(opts.width_num - 2 - (#module.shortname + #module.link), 0)), module.link))
end
end
blank()
Expand Down

0 comments on commit 3f5a5bb

Please sign in to comment.