gnucash-docs maint: Multiple changes pushed
Frank H.Ellenberger
fell at code.gnucash.org
Wed Jun 8 12:28:04 EDT 2022
Updated via https://github.com/Gnucash/gnucash-docs/commit/40e3f995 (commit)
via https://github.com/Gnucash/gnucash-docs/commit/72f4a99e (commit)
from https://github.com/Gnucash/gnucash-docs/commit/c2fab792 (commit)
commit 40e3f9955b6bebea717cb772fee147f3e151c824
Author: Geert Janssens <geert at kobaltwit.be>
Date: Wed Jun 8 10:21:58 2022 +0200
Add tests related to images and figures
- warn if document references images that don't exist
- inform if images exist that are not referenced
diff --git a/cmake/AddGncDocTargets.cmake b/cmake/AddGncDocTargets.cmake
index 37b4b313..ab5aa06b 100644
--- a/cmake/AddGncDocTargets.cmake
+++ b/cmake/AddGncDocTargets.cmake
@@ -14,6 +14,12 @@ function (add_gnc_doc_targets docname entities)
--noout
--path ${CMAKE_SOURCE_DIR}/docbook
${CMAKE_CURRENT_SOURCE_DIR}/${docname}.xml
+ COMMAND ${CMAKE_COMMAND}
+ -D XMLLINT=${XMLLINT}
+ -D GNC_SOURCE_DIR=${CMAKE_SOURCE_DIR}
+ -D GNC_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D docname=${docname}
+ -P ${CMAKE_SOURCE_DIR}/cmake/CheckFigures.cmake
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd")
add_dependencies(${docname}-check "${lang}-${docname}-check")
endif()
diff --git a/cmake/CheckFigures.cmake b/cmake/CheckFigures.cmake
new file mode 100644
index 00000000..1a6dfad1
--- /dev/null
+++ b/cmake/CheckFigures.cmake
@@ -0,0 +1,52 @@
+execute_process(
+ COMMAND ${XMLLINT} --postvalid
+ --xinclude
+ --path ${GNC_SOURCE_DIR}/docbook
+ --xpath "//imagedata/@fileref"
+ ${GNC_CURRENT_SOURCE_DIR}/${docname}.xml
+ RESULT_VARIABLE LINT_RESULT
+ OUTPUT_VARIABLE xml_figures
+)
+if (NOT ${LINT_RESULT} STREQUAL "0")
+ message(FATAL_ERROR "Error while scanning document for referenced images: ${LINT_RESULT}")
+endif()
+
+set(fullpath_xml_figures "")
+set(missing_img_files "")
+
+get_filename_component(doc_lang ${GNC_CURRENT_SOURCE_DIR} NAME)
+
+string(REPLACE "\n" ";" xml_figures ${xml_figures})
+foreach(xml_figure ${xml_figures})
+ string (REGEX REPLACE "^.*=\"(.*)\"" "\\1" xml_figure ${xml_figure})
+ find_file(image ${xml_figure} ${GNC_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
+ if(NOT image)
+ list(APPEND missing_img_files " - ${xml_figure}")
+ else()
+ list(APPEND fullpath_xml_figures ${GNC_CURRENT_SOURCE_DIR}/${xml_figure})
+ endif()
+endforeach()
+
+if(missing_img_files)
+ string(REPLACE ";" "\n" missing_img_files "${missing_img_files}")
+ string(PREPEND missing_img_files " Following non-existing images are referenced in document ${docname}(${doc_lang}):\n")
+ message(WARNING ${missing_img_files})
+endif()
+
+set(unused_img_files "")
+file(GLOB_RECURSE images
+ "${GNC_CURRENT_SOURCE_DIR}/figures/*.png"
+ "${GNC_CURRENT_SOURCE_DIR}/figures/*.svg")
+
+foreach(image ${images})
+ list(FIND fullpath_xml_figures "${image}" result)
+ if (${result} EQUAL -1)
+ list(APPEND unused_img_files " - ${image}")
+ endif()
+endforeach()
+
+if(unused_img_files)
+ string(REPLACE ";" "\n" unused_img_files "${unused_img_files}")
+ string(PREPEND unused_img_files " Note: following images exist but are not referenced in document ${docname}(${doc_lang}):\n")
+ message(STATUS ${unused_img_files})
+endif()
commit 72f4a99edb0c5cf8c0a3e394fc534edd2b145216
Author: Geert Janssens <geert at kobaltwit.be>
Date: Wed Jun 8 10:20:51 2022 +0200
Require same cmake version as gnucash program
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6bed08e2..c43b6450 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
# CMakeLists.txt for GnuCash Documenation
-cmake_minimum_required (VERSION 3.5)
+cmake_minimum_required (VERSION 3.10)
# This sets a number of environment variables we can use later on
# The names of these variables start with PROJECT_ and gnucash-docs_VERSION
Summary of changes:
CMakeLists.txt | 2 +-
cmake/AddGncDocTargets.cmake | 6 +++++
cmake/CheckFigures.cmake | 52 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 cmake/CheckFigures.cmake
More information about the gnucash-changes
mailing list