docs/_parser.lua: parse_files() doesn't produce duplicate entries

anymore.

TODO: Handle duplicate's links.
This commit is contained in:
Andrei Florea 2021-07-31 11:42:38 +02:00
parent 832483dd60
commit 66bb09718b
No known key found for this signature in database
GPG Key ID: 3176062DD1B6FDA8
1 changed files with 12 additions and 7 deletions

View File

@ -121,6 +121,7 @@ local function parse_files(paths, property_name, matcher, name_matcher)
local exp2 = matcher or "[-*]*[ ]*".. property_name ..".(.+)"
local exp3 = name_matcher or "[. ](.+)"
local names = {} -- Used to check for duplicates
local ret = {}
table.sort(paths)
@ -162,13 +163,17 @@ local function parse_files(paths, property_name, matcher, name_matcher)
"seems to be misformatted. Use `beautiful.namespace_name`"
)
else
table.insert(ret, {
file = file,
name = name:gsub("_", "_"),
link = get_link(file, var, var:match(exp3):gsub("_", "\\_")),
desc = buffer:gmatch("[-*/ \n]+([^\n.]*)")() or "",
mod = path_to_module(file),
})
local insert_name = name:gsub("_", "_")
if names[insert_name] == nil then
table.insert(ret, {
file = file,
name = insert_name,
link = get_link(file, var, var:match(exp3):gsub("_", "\\_")),
desc = buffer:gmatch("[-*/ \n]+([^\n.]*)")() or "",
mod = path_to_module(file)
})
names[insert_name] = 1
end
end
buffer = ""