doc: Find and post-process untracked SVG files.

Right now the UML template write many files which were not tracked
by CMake. This caused them to be missing from the doc since the
post-processing was added.
This commit is contained in:
Emmanuel Lepage Vallee 2022-07-05 00:07:25 -07:00
parent 4bd90f0f35
commit 3510d96d6c
4 changed files with 55 additions and 5 deletions

View file

@ -292,7 +292,7 @@ if(GENERATE_DOC)
configure_file(${SOURCE_DIR}/docs/ldoc.ltp ${BUILD_DIR}/docs COPYONLY)
add_custom_target(ldoc ALL
DEPENDS ${BUILD_DIR}/doc/index.html
DEPENDS ${BUILD_DIR}/doc/index.html DOC_EXAMPLES_PPOSTPROCESS_CLEANUP
)
if (STRICT_TESTS)

View file

@ -309,7 +309,6 @@ function(run_test test_path namespace escaped_content)
DEPENDS ${TARGET_NAME}_RAW "${TOP_SOURCE_DIR}/tests/examples/_postprocess.lua"
)
if(NOT ${OUTPUT_RAW_IMAGE_PATH} STREQUAL "")
file(RELATIVE_PATH rel_output "${TOP_SOURCE_DIR}" "${OUTPUT_RAW_IMAGE_PATH}")
if(tmp_content MATCHES "--DOC_GEN_OUTPUT")
@ -382,4 +381,11 @@ endforeach()
add_custom_target(generate-examples DEPENDS ${EXAMPLE_DOC_GENERATED_FILES})
add_custom_target(check-examples DEPENDS ${EXAMPLE_DOC_TEST_TARGETS})
# Some tests produce multiple files, find them and post-process them.
add_custom_target(DOC_EXAMPLES_PPOSTPROCESS_CLEANUP
COMMAND "${TOP_SOURCE_DIR}/tests/examples/_postprocess_cleanup.lua" ${RAW_IMAGE_DIR} ${IMAGE_DIR} "${TOP_SOURCE_DIR}/tests/examples/_postprocess.lua"
VERBATIM
DEPENDS ${BUILD_DIR}/doc/index.html
)
# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker

View file

@ -23,9 +23,8 @@ local i, o = io.open(input, "r"), io.open(output, "w")
if (not i) or (not o) then return end
local line, count = i:read("*line"), 0
local add_link = false
local line = i:read("*line")
local count
while line do
-- Deduplicate and concatenate the classes.

View file

@ -0,0 +1,45 @@
#!/usr/bin/env lua
-- This script locate and post process all "dangling" files CMake
-- didn't track. This allows the `tests/examples/` file to save more
-- than one output artifact.
pcall(require, "luarocks.loader")
local gio = require("lgi").Gio
local name_attr = gio.FILE_ATTRIBUTE_STANDARD_NAME
local type_attr = gio.FILE_ATTRIBUTE_STANDARD_TYPE
local raw_path, processed_path, script_path = ...
local function list_svg(path)
local ret = {}
local enumerator = gio.File.new_for_path(path):enumerate_children(
table.concat({name_attr, type_attr}, ",") , 0, nil, nil
)
for file in function() return enumerator:next_file() end do
local file_name = file:get_attribute_as_string(name_attr)
local file_type = file:get_file_type()
local match_ext = file_name:match("[.]svg$")
if file_type == "REGULAR" and match_ext then
ret[file_name] = true
end
end
return ret
end
local raw_files, processed_files = list_svg(raw_path), list_svg(processed_path)
for file in pairs(raw_files) do
if not processed_files[file] then
os.execute(table.concat({
script_path,
raw_path .. "/" .. file,
processed_path .. "/" .. file
}, " "))
end
end