Skip to content

Commit 974f8a9

Browse files
committed
(build) Using sphinx-flags
- including locale on cycle - cleanup update_locale.sh
1 parent 7cf0f31 commit 974f8a9

File tree

2 files changed

+60
-54
lines changed

2 files changed

+60
-54
lines changed

.github/scripts/update_locale.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
# ------------------------------------------------------------------------------
32
# /*PGR-GNU*****************************************************************
43
# File: update_locale.sh
54
# Copyright (c) 2021 pgRouting developers
@@ -17,32 +16,34 @@
1716
# along with this program; if not, write to the Free Software
1817
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1918
# ********************************************************************PGR-GNU*/
20-
# ------------------------------------------------------------------------------
2119

2220
DIR=$(git rev-parse --show-toplevel)
2321

2422
pushd "${DIR}" > /dev/null || exit 1
2523

2624
mkdir -p build
2725
pushd build > /dev/null || exit 1
28-
cmake -DLOCALE=ON ..
26+
cmake -DBUILD_HTML=OFF -DBUILD_LOCALE=ON ..
2927

3028
make locale
3129
popd > /dev/null || exit 1
3230

3331
# List all the files that needs to be committed in build/docs/locale_changes.txt
3432
awk '/^Update|^Create/{print $2}' build/docs/locale_changes.txt > build/docs/locale_changes_po.txt # .po files
3533
cp build/docs/locale_changes_po.txt build/docs/locale_changes_po_pot.txt
36-
perl -ne '/\/en\// && print' build/docs/locale_changes_po.txt | \
34+
35+
if [ -s build/docs/locale_changes_po.txt ]; then
36+
37+
perl -ne '/\/en\// && print' build/docs/locale_changes_po.txt | \
3738
perl -pe 's/(.*)en\/LC_MESSAGES(.*)/$1pot$2t/' >> build/docs/locale_changes_po_pot.txt # .pot files
3839

39-
# Do not create empty translation files
40-
git status locale/es --porcelain | awk 'match($1, "?"){print $2}' | xargs -r rm -rf
41-
git status locale/ja --porcelain | awk 'match($1, "?"){print $2}' | xargs -r rm -rf
40+
fi
4241

4342
# Remove obsolete entries #~ from .po files
44-
bash .github/scripts/remove_obsolete_entries.sh
43+
find locale -type f -name '*.po' -exec sh -c '
44+
msgattrib --no-obsolete -o "$1" "$1"
45+
' sh {} \;
4546

46-
cat build/docs/locale_changes_po_pot.txt | xargs -I {} sh -c "(ls {} >> /dev/null 2>&1 && git add {} )"
47+
while read -r f; do git add "$f"; done < build/docs/locale_changes_po_pot.txt
4748

4849
popd > /dev/null || exit 1

docs/CMakeLists.txt

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -43,68 +43,73 @@ add_subdirectory(_themes)
4343
set(SPHINX_DOCUMENTATION_DIR "${CMAKE_CURRENT_BINARY_DIR}")
4444
set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
4545

46+
foreach (format ${PGR_WORKSHOP_DOC_TARGETS})
4647

47-
# build the locale files
48-
if (LOCALE)
49-
add_custom_target(locale ALL
50-
COMMAND ${SPHINX_EXECUTABLE}
48+
message(STATUS "format=${format}")
49+
if ("${format}" STREQUAL "locale")
5150

52-
-b gettext
51+
find_program(SPHINX_INTL_EXECUTABLE
52+
NAMES sphinx-intl
53+
DOC "Sphinx Documentation Builder (sphinx-doc.org)"
54+
)
5355

54-
# the location of the documentation to be build
55-
"${CMAKE_CURRENT_BINARY_DIR}"
56-
"${CMAKE_SOURCE_DIR}/locale/pot"
56+
if (SPHINX_INTL_EXECUTABLE)
5757

58-
COMMAND sphinx-intl update -d ${CMAKE_SOURCE_DIR}/locale -l ${SPHINXINTL_LANGUAGE} > locale_changes.txt
59-
DEPENDS "conf.py"
58+
add_custom_target(locale
59+
COMMAND ${SPHINX_EXECUTABLE}
60+
-b gettext
61+
-c "${SPHINX_DOCUMENTATION_DIR}"
62+
"${SPHINX_DOCUMENTATION_DIR}"
63+
"${CMAKE_SOURCE_DIR}/locale/pot"
6064

61-
COMMENT "Generating POT & PO files ..."
62-
)
63-
add_dependencies(locale examples general-intro advanced appendix basic un_sdg scripts interactions)
64-
add_dependencies(doc locale)
65-
endif()
65+
COMMAND ${SPHINX_INTL_EXECUTABLE} update
66+
-d ${CMAKE_SOURCE_DIR}/locale
67+
-l en > locale_changes.txt
6668

69+
COMMENT "Generating POT and PO files"
70+
SOURCES ${PROJECT_DOC_FILES})
6771

72+
add_dependencies("${format}" examples general-intro advanced appendix basic un_sdg scripts interactions)
73+
add_dependencies(doc "${format}")
6874

69-
foreach (target ${PGR_WORKSHOP_DOC_TARGETS})
70-
add_custom_target(${target} ALL
71-
COMMENT "Building documentation with Sphinx")
75+
else()
7276

73-
configure_file("forward.html" "${SPHINX_BUILD_DIR}/${target}/index.html")
77+
message(WARNING "sphinx-intl not found.
78+
Not building the pot and po locale files")
7479

75-
foreach (lang ${PGR_WORKSHOP_BUILD_LANGUAGES})
76-
if (lang STREQUAL "en")
77-
set(WARNINGS_TO_ERRORS "")
78-
else()
79-
set(WARNINGS_TO_ERRORS "")
8080
endif()
81-
message(STATUS "lang ${lang}")
82-
message(STATUS "WARNINGS_TO_ERRORS ${WARNINGS_TO_ERRORS}")
8381

82+
else()
8483

85-
add_custom_target(
86-
"${target}-${lang}"
87-
COMMAND ${SPHINX_EXECUTABLE}
84+
add_custom_target("${format}"
85+
COMMENT "Building ${format} documentation with Sphinx")
8886

89-
-b ${target}
90-
-c "${CMAKE_CURRENT_BINARY_DIR}"
91-
-D language='${lang}'
87+
configure_file(
88+
"${CMAKE_CURRENT_SOURCE_DIR}/forward.html"
89+
"${SPHINX_BUILD_DIR}/${format}/index.html")
9290

93-
# Convert warnings to errors
94-
${WARNINGS_TO_ERRORS}
91+
foreach (lang ${PGR_WORKSHOP_BUILD_LANGUAGES})
9592

96-
# the location of the documentation to be build
97-
"${CMAKE_CURRENT_BINARY_DIR}"
93+
add_custom_target(
94+
"${format}-${lang}"
95+
COMMAND ${SPHINX_EXECUTABLE}
96+
-c ${CMAKE_CURRENT_BINARY_DIR}
97+
-d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
98+
-b ${format}
99+
-D language='${lang}'
100+
${sphinx_flags}
101+
"${CMAKE_CURRENT_BINARY_DIR}"
102+
"${SPHINX_BUILD_DIR}/${format}/${lang}"
98103

99-
#where the documentations is written
100-
"${SPHINX_BUILD_DIR}/${target}/${lang}"
104+
COMMENT "Generating ${format}/${lang} documentation"
105+
DEPENDS "conf.py"
106+
)
107+
add_dependencies("${format}-${lang}" examples general-intro advanced appendix basic un_sdg scripts interactions)
108+
add_dependencies("${format}" "${format}-${lang}")
109+
endforeach()
101110

102-
COMMENT "Generating ${target}/${lang} documentation ${WARNINGS_TO_ERRORS}..."
111+
add_dependencies(doc "${format}")
112+
113+
endif()
103114

104-
DEPENDS "conf.py"
105-
)
106-
add_dependencies("${target}-${lang}" examples general-intro advanced appendix basic un_sdg scripts interactions)
107-
add_dependencies("${target}" "${target}-${lang}")
108-
endforeach()
109-
add_dependencies(doc "${target}")
110115
endforeach()

0 commit comments

Comments
 (0)