Skip to content

Commit 82af415

Browse files
authored
#245: Fix duplicated examples.md items in website's docs (#254)
1 parent 49d7826 commit 82af415

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ __pycache__
2828

2929
docs/*/initial*
3030
docs/*/result*
31+
docs/documentation/*-example.png
3132
docs/documentation/examples.md
3233

3334
examples/*batch/*/

CMakeLists.txt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,19 @@ if (MFC_SYSCHECK)
446446
endif()
447447

448448
if (MFC_DOCUMENTATION)
449+
# Files in docs/examples are used to generate docs/documentation/examples.md
450+
file(GLOB_RECURSE examples_DOCs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples/*")
451+
452+
add_custom_command(
453+
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/documentation/examples.md"
454+
DEPENDS "${examples_DOCs}"
455+
COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples.sh"
456+
"${CMAKE_CURRENT_SOURCE_DIR}"
457+
COMMENT "Generating examples.md"
458+
)
459+
460+
file(GLOB common_DOCs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/*")
461+
449462
# GEN_DOCS: Given a target name (herein <target>), this macro sets up a
450463
# target, <target>_docs, that generates documentation for <target> using
451464
# Doxygen. It is then added as a dependency of the documentation target.
@@ -472,13 +485,20 @@ if (MFC_DOCUMENTATION)
472485
"${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in"
473486
"${CMAKE_CURRENT_BINARY_DIR}/${target}-Doxyfile" @ONLY)
474487

488+
set(opt_example_dependency "")
489+
if (target STREQUAL "documentation")
490+
set(opt_example_dependency "${CMAKE_CURRENT_SOURCE_DIR}/docs/documentation/examples.md")
491+
endif()
492+
493+
file(GLOB_RECURSE ${target}_DOCs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/${target}/*")
494+
list(APPEND ${target}_DOCs "${common_DOCs}")
495+
475496
add_custom_command(
476497
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}/html/index.html"
477498
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}-Doxyfile"
478-
"${${target}_SRCs}"
479-
COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples.sh"
480-
"${CMAKE_CURRENT_SOURCE_DIR}" &&
481-
"${DOXYGEN_EXECUTABLE}" "${target}-Doxyfile"
499+
"${opt_example_dependency}"
500+
"${${target}_SRCs}" "${${target}_DOCs}"
501+
COMMAND "${DOXYGEN_EXECUTABLE}" "${target}-Doxyfile"
482502
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
483503
COMMENT "${target}: Generating documentation"
484504
)
@@ -503,7 +523,7 @@ if (MFC_DOCUMENTATION)
503523
ExternalProject_Add(doxygen-awesome-css
504524
PREFIX doxygen-awesome-css
505525
GIT_REPOSITORY "https://github.com/jothepro/doxygen-awesome-css"
506-
GIT_TAG "df83fbf22cfff76b875c13d324baf584c74e96d0"
526+
GIT_TAG "df88fe4fdd97714fadfd3ef17de0b4401f804052"
507527
CONFIGURE_COMMAND ""
508528
BUILD_COMMAND ""
509529
INSTALL_COMMAND ""

docs/examples.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ rm "$examples_md" || true
77

88
echo -e "# Example Cases\n" > "$examples_md"
99

10-
for casedir in $(find "$1/examples/" -maxdepth 1 -type d); do
11-
casename="$(basename $casedir)"
12-
13-
if [ "$casename" == "examples" ]; then
14-
continue
15-
fi
10+
for casedir in $(find "$1/examples/" -mindepth 1 -maxdepth 1 -type d); do
11+
casename="$(basename "$casedir")"
1612

1713
if [ -f "$casedir/README.md" ]; then
18-
sed -e "s/\.png/-$casename\.png/g" "$casedir/README.md" | sed 's/^#/##/g' >> "$examples_md"
19-
echo "" >> "$examples_md"
14+
sed -e "s/\.png/-$casename-example\.png/g" "$casedir/README.md" | sed 's/^#/##/g' >> "$examples_md"
15+
echo '' >> "$examples_md"
2016

21-
for png in $(find "$casedir" -maxdepth 1 -name "*.png"); do
22-
cp "$png" "$1/docs/documentation/$(basename $png | sed s/\.png//g)-$casename.png"
17+
for png in $(find "$casedir" -maxdepth 1 -name '*.png'); do
18+
cp "$png" "$1/docs/documentation/$(basename "$png" | sed s/\.png//g)-$casename-example.png"
2319
done
2420
fi
2521
done

0 commit comments

Comments
 (0)