diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index ade78ede6..15f2f91e9 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -408,8 +408,23 @@ add_custom_command( ${BUILD_DIR}/script_files/rc.lua ) -# Create a target for the auto-generated awesomerc.lua -add_custom_target(generate_awesomerc DEPENDS ${BUILD_DIR}/awesomerc.lua) +add_custom_command( + OUTPUT ${BUILD_DIR}/script_files/theme.lua + COMMAND lua ${SOURCE_DIR}/docs/sample_theme.lua ${BUILD_DIR}/script_files/ +) + +# Create a target for the auto-generated awesomerc.lua and other files +add_custom_target(generate_awesomerc DEPENDS + ${BUILD_DIR}/awesomerc.lua + ${BUILD_DIR}/script_files/theme.lua + ${BUILD_DIR}/script_files/rc.lua + ${SOURCE_DIR}/awesomerc.lua + ${BUILD_DIR}/docs/06-appearance.md + ${SOURCE_DIR}/docs/05-awesomerc.md.lua + ${SOURCE_DIR}/docs/sample_theme.lua + ${SOURCE_DIR}/docs/sample_files.lua + ${SOURCE_DIR}/awesomerc.lua +) #}}} diff --git a/docs/sample_files.lua b/docs/sample_files.lua new file mode 100644 index 000000000..2b86ae3b5 --- /dev/null +++ b/docs/sample_files.lua @@ -0,0 +1,32 @@ +-- Take a Lua file and add it to the documentation sample files. +-- Also add \` to generate all links + +-- Tell ldoc to generate links + local function add_links(line) + for _, module in ipairs { + "awful", "wibox", "gears", "naughty", "menubar", "beautiful" + } do + if line:match(module.."%.") then + line = line:gsub("("..module.."[.a-zA-Z]+)", "`%1`") + end + end + + return "-- "..line + end + +return function(name, input_path, output_path, header) + local input = assert(io.open(input_path)) + local output_script = {header} + + -- Escape all lines + for line in input:lines() do + table.insert(output_script, add_links(line)) + end + + -- Add the script name + table.insert(output_script, "-- @script "..name) + + output_path = assert(io.open(output_path, "w")) + output_path:write(table.concat(output_script, "\n")) + output_path:close() +end diff --git a/docs/sample_theme.lua b/docs/sample_theme.lua new file mode 100644 index 000000000..1a5f6e5a8 --- /dev/null +++ b/docs/sample_theme.lua @@ -0,0 +1,29 @@ +--- Take the default theme and add it to ldoc as a sample file. +local output_path = ... + +local path = debug.getinfo(1,"S").source:gsub("sample_theme.*",""):gsub("@","") +package.path = path .. '?.lua;' .. package.path + +require("sample_files")( + "theme.lua", + path.."../themes/default/theme.lua", + output_path.."/theme.lua", +[[--------------------------------------------------------------------------- +--- The default theme file. +-- +-- If you wish to create a custom theme, copy this file to +-- `~/.config/awesome/mytheme.lua` +-- and replace: +-- +-- beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua") +-- +-- with +-- +-- beautiful.init(awful.util.getdir("config") .. "mytheme.lua") +-- +-- in your `rc.lua`. +-- +-- Here is the default theme content: +-- +--]] +)