From f5e7d62f90f5eb88afad45d56017c42835149d0c Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 28 Dec 2025 21:37:23 +0100 Subject: Generate code block documentation using FLTK (#1353) The Doxygen-to-pdf toolchain can not easily generate pdf's with Japanese and Chinese characters. This patch generates code blocks by rendering them in FLTK. --- documentation/CMakeLists.txt | 4 ++++ documentation/Doxyfile.in | 8 +++++--- documentation/src/unicode.dox | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'documentation') diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt index 3dc9fbd1b..bbf8da6ae 100644 --- a/documentation/CMakeLists.txt +++ b/documentation/CMakeLists.txt @@ -103,6 +103,7 @@ if(FLTK_BUILD_HTML_DOCS) set(GENERATE_HTML YES) set(GENERATE_LATEX NO) + set(EXTRA_SECTIONS "HTML_SECTIONS") set(LATEX_HEADER "") set(DOXYFILE "Doxyfile") set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") @@ -152,6 +153,7 @@ if(FLTK_BUILD_PDF_DOCS) set(GENERATE_HTML NO) set(GENERATE_LATEX YES) + set(EXTRA_SECTIONS "LATEX_SECTIONS") set(LATEX_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex") set(DOXYFILE "Doxybook") set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log") @@ -202,6 +204,7 @@ if(FLTK_BUILD_PDF_DOCS) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf + COMMAND code_snapshot ${CMAKE_CURRENT_SOURCE_DIR}/src/unicode.dox COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_header ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex @@ -220,6 +223,7 @@ if(FLTK_BUILD_PDF_DOCS) add_custom_target(pdf DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf ) + add_dependencies(pdf code_snapshot) endif(FLTK_BUILD_PDF_DOCS) diff --git a/documentation/Doxyfile.in b/documentation/Doxyfile.in index d1dec82db..10c277a72 100644 --- a/documentation/Doxyfile.in +++ b/documentation/Doxyfile.in @@ -229,7 +229,8 @@ TAB_SIZE = 8 # newlines (in the resulting output). You can put ^^ in the value part of an # alias to insert a newline as if a physical newline was in the original file. -ALIASES = +ALIASES = code_international{1}="@if LATEX_SECTIONS^^@image latex \1 width=\\linewidth^^@endif^^@if HTML_SECTIONS^^@code" +ALIASES += endcode_international="@endcode^^@endif" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" @@ -639,7 +640,7 @@ GENERATE_DEPRECATEDLIST= YES # sections, marked by \if ... \endif and \cond # ... \endcond blocks. -ENABLED_SECTIONS = @DRIVER_DOCS@ +ENABLED_SECTIONS = @DRIVER_DOCS@ @EXTRA_SECTIONS@ # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -920,7 +921,8 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/src +IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/src \ + @CMAKE_CURRENT_BINARY_DIR@/generated # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program diff --git a/documentation/src/unicode.dox b/documentation/src/unicode.dox index b2eb7b872..b640e170e 100644 --- a/documentation/src/unicode.dox +++ b/documentation/src/unicode.dox @@ -20,6 +20,16 @@ are not yet implemented. \section unicode_quick_start Quick Start +International code test for HTML and PDF: + +\code_international{"generated/unicode_about.png"} +// This is a test +// 日本語テストテキスト +// 中文测试文本 +// Ελληνικό κείμενο δοκιμής +\endcode_international + + For most applications, you simply need to ensure your text is UTF-8 encoded: \code -- cgit v1.2.3