2016-08-12 08:01:45 +02:00
|
|
|
#! /usr/bin/lua
|
|
|
|
local args = {...}
|
2018-10-07 07:29:41 +02:00
|
|
|
local parser = require("docs._parser")
|
2016-08-12 08:01:45 +02:00
|
|
|
|
|
|
|
local gio = require("lgi").Gio
|
|
|
|
local gobject = require("lgi").GObject
|
|
|
|
local glib = require("lgi").GLib
|
|
|
|
|
2018-10-07 07:29:41 +02:00
|
|
|
local paths = parser.get_all_files("./lib/", "lua", parser.get_all_files("./", "c"))
|
2016-08-12 08:01:45 +02:00
|
|
|
|
2018-10-07 07:29:41 +02:00
|
|
|
local beautiful_vars = parser.parse_files(paths, "beautiful")
|
2016-08-12 08:01:45 +02:00
|
|
|
|
|
|
|
local override_cats = {
|
|
|
|
["border" ] = true,
|
|
|
|
["bg" ] = true,
|
|
|
|
["fg" ] = true,
|
|
|
|
["useless" ] = true,
|
|
|
|
["" ] = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
local function categorize(entries)
|
|
|
|
local ret = {}
|
|
|
|
|
|
|
|
local cats = {
|
|
|
|
["Default variables"] = {}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, v in ipairs(entries) do
|
|
|
|
local ns = v.name:match("([^_]+)_") or ""
|
|
|
|
ns = override_cats[ns] and "Default variables" or ns
|
|
|
|
cats[ns] = cats[ns] or {}
|
|
|
|
table.insert(cats[ns], v)
|
|
|
|
end
|
|
|
|
|
|
|
|
return cats
|
|
|
|
end
|
|
|
|
|
|
|
|
local function create_sample(entries)
|
|
|
|
local ret = {
|
|
|
|
" local theme = {}"
|
|
|
|
}
|
|
|
|
|
2018-10-07 07:29:41 +02:00
|
|
|
for name, cat in parser.sorted_pairs(categorize(entries)) do
|
2016-08-12 08:01:45 +02:00
|
|
|
table.insert(ret, "\n -- "..name)
|
|
|
|
for _, v in ipairs(cat) do
|
|
|
|
table.insert(ret, " -- theme."..v.name.." = nil")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(ret, [[
|
|
|
|
|
|
|
|
return theme
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80]]
|
|
|
|
)
|
|
|
|
|
|
|
|
return table.concat(ret, '\n')
|
|
|
|
end
|
|
|
|
|
2018-10-07 07:29:41 +02:00
|
|
|
|
2016-08-12 08:01:45 +02:00
|
|
|
-- Create the file
|
|
|
|
local filename = args[1]
|
|
|
|
|
|
|
|
local f = io.open(filename, "w")
|
|
|
|
|
|
|
|
f:write[[
|
|
|
|
# Change Awesome appearance
|
|
|
|
|
|
|
|
## The beautiful themes
|
|
|
|
|
|
|
|
Beautiful is where Awesome theme variables are stored.
|
|
|
|
|
2018-10-07 07:29:41 +02:00
|
|
|
<br /><br />
|
2016-08-12 08:01:45 +02:00
|
|
|
]]
|
2018-10-07 07:29:41 +02:00
|
|
|
f:write(parser.create_table(beautiful_vars, {"link", "desc"}))
|
2016-08-12 08:01:45 +02:00
|
|
|
|
|
|
|
f:write("\n\n## Sample theme file\n\n")
|
|
|
|
|
|
|
|
f:write(create_sample(beautiful_vars, {"link", "desc"}))
|
|
|
|
|
|
|
|
f:close()
|
|
|
|
|
|
|
|
--TODO add some linting to direct undeclared beautiful variables
|
|
|
|
--TODO re-generate all official themes
|
|
|
|
--TODO generate a complete sample theme
|
|
|
|
|
2017-06-14 14:29:20 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|