doc: Build property indexes for more classes instead of only client.

These index will be used for the rules documentation.
This commit is contained in:
Emmanuel Lepage Vallee 2019-08-18 16:37:17 -04:00
parent 3da2264df2
commit c1d59fef24
3 changed files with 62 additions and 43 deletions

View File

@ -382,21 +382,25 @@ add_custom_command(
${SOURCE_DIR}/docs/_parser.lua ${SOURCE_DIR}/docs/_parser.lua
) )
add_custom_command( foreach(RULE_TYPE client tag screen notification)
OUTPUT ${BUILD_DIR}/docs/common/rules_index.ldoc add_custom_command(
OUTPUT ${BUILD_DIR}/docs/common/${RULE_TYPE}_rules_index.ldoc
COMMAND lua ${SOURCE_DIR}/docs/build_rules_index.lua COMMAND lua ${SOURCE_DIR}/docs/build_rules_index.lua
${BUILD_DIR}/docs/common/rules_index.ldoc ${BUILD_DIR}/docs/common/${RULE_TYPE}_rules_index.ldoc
${RULE_TYPE}
# Cheap trick until the ldoc `configure_file` is ported to be a build # Cheap trick until the ldoc `configure_file` is ported to be a build
# step rather than part of cmake. # step rather than part of cmake.
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/docs/common/rules_index.ldoc COMMAND ${CMAKE_COMMAND} -E
${SOURCE_DIR}/docs/common/rules_index.ldoc copy ${BUILD_DIR}/docs/common/${RULE_TYPE}_rules_index.ldoc
${SOURCE_DIR}/docs/common/${RULE_TYPE}_rules_index.ldoc
DEPENDS DEPENDS
lgi-check-run lgi-check-run
${SOURCE_DIR}/docs/build_rules_index.lua ${SOURCE_DIR}/docs/build_rules_index.lua
${SOURCE_DIR}/docs/_parser.lua ${SOURCE_DIR}/docs/_parser.lua
) )
endforeach()
add_custom_command( add_custom_command(
OUTPUT ${BUILD_DIR}/awesomerc.lua ${BUILD_DIR}/docs/05-awesomerc.md OUTPUT ${BUILD_DIR}/awesomerc.lua ${BUILD_DIR}/docs/05-awesomerc.md
@ -423,7 +427,10 @@ add_custom_target(generate_awesomerc DEPENDS
${BUILD_DIR}/docs/06-appearance.md ${BUILD_DIR}/docs/06-appearance.md
${SOURCE_DIR}/docs/05-awesomerc.md.lua ${SOURCE_DIR}/docs/05-awesomerc.md.lua
${SOURCE_DIR}/docs/build_rules_index.lua ${SOURCE_DIR}/docs/build_rules_index.lua
${BUILD_DIR}/docs/common/rules_index.ldoc ${BUILD_DIR}/docs/common/client_rules_index.ldoc
${BUILD_DIR}/docs/common/tag_rules_index.ldoc
${BUILD_DIR}/docs/common/screen_rules_index.ldoc
${BUILD_DIR}/docs/common/notification_rules_index.ldoc
${SOURCE_DIR}/docs/sample_theme.lua ${SOURCE_DIR}/docs/sample_theme.lua
${SOURCE_DIR}/docs/sample_files.lua ${SOURCE_DIR}/docs/sample_files.lua
${SOURCE_DIR}/awesomerc.lua ${SOURCE_DIR}/awesomerc.lua

View File

@ -131,7 +131,8 @@ local function parse_files(paths, property_name, matcher, name_matcher)
local buffer = "" local buffer = ""
for line in f:lines() do if f then
for line in f and f:lines() do
local var = line:gmatch(exp1)() local var = line:gmatch(exp1)()
@ -163,7 +164,7 @@ local function parse_files(paths, property_name, matcher, name_matcher)
else else
table.insert(ret, { table.insert(ret, {
file = file, file = file,
name = name:gsub("_", "\\_"), name = name:gsub("_", "_"),
link = get_link(file, var, var:match(exp3):gsub("_", "\\_")), link = get_link(file, var, var:match(exp3):gsub("_", "\\_")),
desc = buffer:gmatch("[-*/ \n]+([^\n.]*)")() or "", desc = buffer:gmatch("[-*/ \n]+([^\n.]*)")() or "",
mod = path_to_module(file), mod = path_to_module(file),
@ -173,6 +174,9 @@ local function parse_files(paths, property_name, matcher, name_matcher)
buffer = "" buffer = ""
end end
end end
f:close()
end
end end
return ret return ret

View File

@ -1,15 +1,23 @@
#! /usr/bin/lua #! /usr/bin/lua
local args = {...} local args = {...}
local typename = args[2]
local parser = require("docs._parser") local parser = require("docs._parser")
local files = {"./objects/client.c", "./lib/awful/client.lua"} assert(typename)
local files = {
"./objects/"..typename..".c",
"./lib/awful/"..typename..".lua",
"./lib/naughty/"..typename..".lua"
}
local matcher, matcher2 = "(.*)", ".*" local matcher, matcher2 = "(.*)", ".*"
-- The client function comes from 5 different files, but all of those are -- The client function comes from 5 different files, but all of those are
-- merged into one documentation page (aka, awful.client doesn't have content -- merged into one documentation page (aka, awful.client doesn't have content
-- anymore). This override the path so the parser doesn't have to be aware of it -- anymore). This override the path so the parser doesn't have to be aware of it
function parser.path_to_html() function parser.path_to_html()
return "../core_components/client.html#" return "../core_components/"..typename..".html#"
end end
local clientruleproperty = parser.parse_files(files, "clientruleproperty", matcher, matcher2) local clientruleproperty = parser.parse_files(files, "clientruleproperty", matcher, matcher2)