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 exp2 = matcher or "[-*]*[ ]*".. property_name ..".(.+)"
local exp3 = name_matcher or "[. ](.+)" local exp3 = name_matcher or "[. ](.+)"
local names = {} -- Used to check for duplicates
local ret = {} local ret = {}
table.sort(paths) 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`" "seems to be misformatted. Use `beautiful.namespace_name`"
) )
else else
table.insert(ret, { local insert_name = name:gsub("_", "_")
file = file, if names[insert_name] == nil then
name = name:gsub("_", "_"), table.insert(ret, {
link = get_link(file, var, var:match(exp3):gsub("_", "\\_")), file = file,
desc = buffer:gmatch("[-*/ \n]+([^\n.]*)")() or "", name = insert_name,
mod = path_to_module(file), 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 end
buffer = "" buffer = ""