[frameworks/kdoctools] /: kdoctools_install: fix doc detection in path with special chars

Luigi Toscano null at kde.org
Sun Mar 5 00:02:58 GMT 2023


Git commit b3cc46ca3d643ce88d984daf0148ecc70ae050eb by Luigi Toscano, on behalf of Pino Toscano.
Committed on 04/03/2023 at 23:51.
Pushed by ltoscano into branch 'master'.

kdoctools_install: fix doc detection in path with special chars

${lang_dir} represents the absolute path of a directory within the
sources that contains the files for a language; if this path contains
special characters (e.g. "+"), then using it in a regex such as
  "${lang_dir}/docs/(.*)/index.docbook"
will not produce matches.

To avoid special characters getting in the way of the lookup for
manpages or index.docbook files, restrict the results of the glob search
relative to ${lang_dir}, making sure to compose full paths back when
invoking kdoctools_create_manpage() and kdoctools_create_handbook().

To make sure it can be tested and it does not regress, rename the
existing "kdoctools-install" autotest to "kdoctools+install".

M  +4    -4    KF6DocToolsMacros.cmake
M  +5    -5    autotests/CMakeLists.txt
R  +0    -0    autotests/kdoctools+install/CMakeLists.txt [from: autotests/kdoctools-install/CMakeLists.txt - 100% similarity]
R  +0    -0    autotests/kdoctools+install/po/es/docs/foobar/index.docbook [from: autotests/kdoctools-install/po/es/docs/foobar/index.docbook - 100% similarity]
R  +0    -0    autotests/kdoctools+install/po/es/docs/kioslave5/fooslave/index.docbook [from: autotests/kdoctools-install/po/es/docs/kioslave5/fooslave/index.docbook - 100% similarity]
R  +0    -0    autotests/kdoctools+install/po/es/docs/man-kjscmd.1.docbook [from: autotests/kdoctools-install/po/es/docs/man-kjscmd.1.docbook - 100% similarity]
R  +0    -0    autotests/kdoctools+install/po/fr/docs/foobar/index.docbook [from: autotests/kdoctools-install/po/fr/docs/foobar/index.docbook - 100% similarity]
R  +0    -0    autotests/kdoctools+install/po/fr/docs/man-kjscmd.1.docbook [from: autotests/kdoctools-install/po/fr/docs/man-kjscmd.1.docbook - 100% similarity]
R  +0    -0    autotests/kdoctools+install/test.cmake [from: autotests/kdoctools-install/test.cmake - 100% similarity]

https://invent.kde.org/frameworks/kdoctools/commit/b3cc46ca3d643ce88d984daf0148ecc70ae050eb

diff --git a/KF6DocToolsMacros.cmake b/KF6DocToolsMacros.cmake
index a37f8c1..e74aa6b 100644
--- a/KF6DocToolsMacros.cmake
+++ b/KF6DocToolsMacros.cmake
@@ -227,17 +227,17 @@ function(kdoctools_install podir)
     foreach(lang_dir ${lang_dirs})
         get_filename_component(lang ${lang_dir} NAME)
 
-        file(GLOB_RECURSE docbooks "${lang_dir}/docs/*.docbook")
+        file(GLOB_RECURSE docbooks RELATIVE "${lang_dir}" "${lang_dir}/docs/*.docbook")
         foreach(docbook ${docbooks})
             string(REGEX MATCH "\\.([0-9])\\.docbook" match ${docbook})
             if (match)
-                kdoctools_create_manpage(${docbook} ${CMAKE_MATCH_1}
+                kdoctools_create_manpage("${lang_dir}/${docbook}" ${CMAKE_MATCH_1}
                     INSTALL_DESTINATION ${KDE_INSTALL_MANDIR}/${lang}
                 )
             else()
-                string(REGEX MATCH "${lang_dir}/docs/(.*)/index.docbook" match ${docbook})
+                string(REGEX MATCH "^docs/(.*)/index.docbook" match ${docbook})
                 if (match)
-                    kdoctools_create_handbook(${docbook}
+                    kdoctools_create_handbook("${lang_dir}/${docbook}"
                         INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/${lang}
                         SUBDIR ${CMAKE_MATCH_1}
                     )
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index a71c881..33a957c 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -14,14 +14,14 @@ endif()
 
 add_test(kdoctools_install ${CMAKE_CTEST_COMMAND}
     --build-and-test
-    "${CMAKE_CURRENT_SOURCE_DIR}/kdoctools-install"
-    "${CMAKE_CURRENT_BINARY_DIR}/kdoctools-install"
+    "${CMAKE_CURRENT_SOURCE_DIR}/kdoctools+install"
+    "${CMAKE_CURRENT_BINARY_DIR}/kdoctools+install"
     --build-generator ${CMAKE_GENERATOR}
     --build-makeprogram ${CMAKE_MAKE_PROGRAM}
     --build-target install
     --build-options
         "-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}"
-        "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/kdoctools-install/destdir"
+        "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/kdoctools+install/destdir"
         "-DKF6DocTools_DIR=${CMAKE_BINARY_DIR}/cmake"
         "-DKDocTools_BINARY_DIR=${CMAKE_BINARY_DIR}"
         "-DKDOCTOOLS_CUSTOMIZATION_DIR=${KDOCTOOLS_CUSTOMIZATION_DIR}"
@@ -32,5 +32,5 @@ add_test(kdoctools_install ${CMAKE_CTEST_COMMAND}
     --test-command ${CMAKE_COMMAND}
         "-DKDE_INSTALL_MANDIR=${KDE_INSTALL_MANDIR}"
         "-DKDE_INSTALL_DOCBUNDLEDIR=${KDE_INSTALL_DOCBUNDLEDIR}"
-        "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/kdoctools-install/destdir"
-        -P "${CMAKE_CURRENT_SOURCE_DIR}/kdoctools-install/test.cmake")
+        "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/kdoctools+install/destdir"
+        -P "${CMAKE_CURRENT_SOURCE_DIR}/kdoctools+install/test.cmake")
diff --git a/autotests/kdoctools-install/CMakeLists.txt b/autotests/kdoctools+install/CMakeLists.txt
similarity index 100%
rename from autotests/kdoctools-install/CMakeLists.txt
rename to autotests/kdoctools+install/CMakeLists.txt
diff --git a/autotests/kdoctools-install/po/es/docs/foobar/index.docbook b/autotests/kdoctools+install/po/es/docs/foobar/index.docbook
similarity index 100%
rename from autotests/kdoctools-install/po/es/docs/foobar/index.docbook
rename to autotests/kdoctools+install/po/es/docs/foobar/index.docbook
diff --git a/autotests/kdoctools-install/po/es/docs/kioslave5/fooslave/index.docbook b/autotests/kdoctools+install/po/es/docs/kioslave5/fooslave/index.docbook
similarity index 100%
rename from autotests/kdoctools-install/po/es/docs/kioslave5/fooslave/index.docbook
rename to autotests/kdoctools+install/po/es/docs/kioslave5/fooslave/index.docbook
diff --git a/autotests/kdoctools-install/po/es/docs/man-kjscmd.1.docbook b/autotests/kdoctools+install/po/es/docs/man-kjscmd.1.docbook
similarity index 100%
rename from autotests/kdoctools-install/po/es/docs/man-kjscmd.1.docbook
rename to autotests/kdoctools+install/po/es/docs/man-kjscmd.1.docbook
diff --git a/autotests/kdoctools-install/po/fr/docs/foobar/index.docbook b/autotests/kdoctools+install/po/fr/docs/foobar/index.docbook
similarity index 100%
rename from autotests/kdoctools-install/po/fr/docs/foobar/index.docbook
rename to autotests/kdoctools+install/po/fr/docs/foobar/index.docbook
diff --git a/autotests/kdoctools-install/po/fr/docs/man-kjscmd.1.docbook b/autotests/kdoctools+install/po/fr/docs/man-kjscmd.1.docbook
similarity index 100%
rename from autotests/kdoctools-install/po/fr/docs/man-kjscmd.1.docbook
rename to autotests/kdoctools+install/po/fr/docs/man-kjscmd.1.docbook
diff --git a/autotests/kdoctools-install/test.cmake b/autotests/kdoctools+install/test.cmake
similarity index 100%
rename from autotests/kdoctools-install/test.cmake
rename to autotests/kdoctools+install/test.cmake


More information about the kde-doc-english mailing list