Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(1) Remove OASIS XSL StyleSheets from GnuCash-docs Tree #307

Open
wants to merge 11 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
40 changes: 8 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ cmake_minimum_required (VERSION 3.5)

# This sets a number of environment variables we can use later on
# The names of these variables start with PROJECT_ and gnucash-docs_VERSION
# We don't actually use C, but GNUInstallDirs doesn't work if we don't
# specify a language.
project (gnucash-docs
VERSION 4.8
LANGUAGES C)
LANGUAGES NONE)

set (PACKAGE_NAME GnuCash Docs)
set (PACKAGE_BUGREPORT "https://bugs.gnucash.org/describecomponents.cgi?product=Documentation")
Expand All @@ -25,7 +23,6 @@ include (AddHtmlTarget)
include (AddPdfTarget)
include (AddGncDocTargets)
include (DistCommon)
include (GNUInstallDirs)

# Clear cache variables that will be filled later during the cmake run
unset(dist_files CACHE)
Expand Down Expand Up @@ -67,10 +64,6 @@ set(JAPANESE_MINCHO_TTF "ume-tmo3.ttf" CACHE STRING "Mincho TrueType font used f
set(JAPANESE_GOTHIC_TTF "ume-tmo3.ttf" CACHE STRING "Gothic TrueType font used for Japanese pdf")
set(japanese_fontdir "${CMAKE_SOURCE_DIR}/fonts/truetype" CACHE STRING "Directory to search for Japanese fonts")

# Buildtime destination directories for our generated documentation
set(DATADIR_BUILD "${CMAKE_BINARY_DIR}/share")
set(DOCDIR_BUILD "${DATADIR_BUILD}/doc/${PACKAGE}")

# ############################################################
# Find the documentation dependencies

Expand All @@ -80,28 +73,14 @@ find_program(XSLTPROC xsltproc)
if(NOT XSLTPROC)
message(SEND_ERROR "Can't find xsltproc, perhaps you should install the xsltproc or libxslt package ?")
endif(NOT XSLTPROC)
SET (XSLTPROCFLAGS --path "${CMAKE_SOURCE_DIR}/docbook" --xinclude "$ENV{XSLTPROCFLAGS}")
SET (XSLTPROCFLAGS --path "${CMAKE_SOURCE_DIR}/docbook" --xinclude "$ENV{XSLTPROCFLAGS}" --nonet)

# Same for xmllint
find_program(XMLLINT xmllint)
if(NOT XMLLINT)
message(SEND_ERROR "Can't find xmllint, perhaps you should install the xsltproc or libxslt package ?")
endif(NOT XMLLINT)

# Find a proper bash executable, only used in case of distcheck with autotools
set(GNC_SHELL $ENV{GNC_SHELL})
if (GNC_SHELL) # Replacing this with if ($ENV{GNC_SHELL}) doesn't work.
# Allow shell override by setting the GNC_SHELL environment variable
set(SHELL ${GNC_SHELL})
else()
find_package(UnixCommands)
if (BASH)
set(SHELL ${BASH})
else()
message(SEND_ERROR "Can't find a suitable bash executable. Please set GNC_SHELL.")
endif()
endif()

# Check for optional fop
if(WITH_PDF)
find_program(FOP fop)
Expand All @@ -127,12 +106,11 @@ endif()
# To find our figures in the source directory each run of fop
# will be passed a fop.xconf file to set a base-dir.
# The default fop.xconf file below does just that.
# Every document/language can define its own FOP_XCONF
# Every document/language can overwrite its own FOP_XCONF
# to point at a document/language specific fop.xconf
# instead for additional fop configuration as needed.
# For example the Japanese document will use it to embed Japanese fonts
set (FOP_XCONF_DFLT "${CMAKE_SOURCE_DIR}/fop.xconf.in")
set (FOP_XCONF "${FOP_XCONF_DFLT}")
# For example the Japanese document will use it to embed Japanese fonts.
set (FOP_XCONF "${CMAKE_SOURCE_DIR}/fop.xconf.in")

# Find the htmlhelp compiler for chm output
if(WITH_CHM)
Expand All @@ -158,7 +136,7 @@ if (WITH_HTML)
add_custom_target(html)
endif()
if (WITH_GHELP)
add_custom_target(ghelp)
add_custom_target(ghelp ALL)
endif()
if (WITH_PDF)
add_custom_target(pdf)
Expand All @@ -183,12 +161,10 @@ add_subdirectory (manual)

file(GLOB_RECURSE extrafiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
cmake/* fonts/* stylesheet/* xsl/* docbook/*)
cmake/* fonts/* xsl/* docbook/*)
add_to_dist(${extrafiles})

configure_file(COPYING ${DATADIR_BUILD}/${PROJECT_NAME}/COPYING COPYONLY)
configure_file(COPYING-DOCS ${DATADIR_BUILD}/${PROJECT_NAME}/COPYING-DOCS COPYONLY)
install(FILES COPYING COPYING-DOCS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
install(FILES COPYING COPYING-DOCS DESTINATION "share/doc/${PROJECT_NAME}")

add_to_dist(
AUTHORS
Expand Down
125 changes: 94 additions & 31 deletions cmake/AddChmTarget.cmake
Original file line number Diff line number Diff line change
@@ -1,37 +1,100 @@
function (add_chm_target docname lang entities figures)
#
# A function to generate chm documentation
#
# FUNCTION:
# add_chm_target
# ARGUMENTS:
# - docname: The basename of the main xml file. Will be used to locate
# this primary xml file and for various output files/directories.
# Either "gnucash-guide" or "gnucash-help" now.
# - lang: The language of the current document, such as "C", "de" and so on.
# - entities: A list of all xml files this document is composed of. ONLY filename, WITHOUT path.
# It does NOT contain "${docname}.xml".
# - figures: A list of FULL PATH image files.
# - dtd_files: A list of FULL PATH DTD files.
#
function (add_chm_target docname lang entities figures dtd_files)

set(chmfile "${docname}.chm")
set(mapfile "${docname}.hhmap")
# Setup base directory
set(fmt "chm")
set(outfile "${docname}.${fmt}")

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")
set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${fmt}")
set(OUTPUT_DIR "${CMAKE_BINARY_DIR}/share/doc/${lang}")

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp")
# GnuCash-specific xsl files
file(GLOB xsl_files "${CMAKE_SOURCE_DIR}/xsl/*.xsl")
file(GLOB gnucash_icon_files "${CMAKE_SOURCE_DIR}/xsl/icons/*")

# Prepare ${BUILD_DIR}
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/figures"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/images/callouts"
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTPUT_DIR}"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger")

# Create CHM file from hhp (the output of xsltproc)
add_custom_command(
OUTPUT "${BUILD_DIR}/${chmfile}" "${BUILD_DIR}/${mapfile}"
COMMAND ${CMAKE_COMMAND} -v
-D docname=${docname}
-D SRC_DIR=${CMAKE_SOURCE_DIR}
-D CURRENT_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-D CURRENT_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}
-D BUILD_DIR=${BUILD_DIR}
-D XSLTPROC=${XSLTPROC}
"-DXSLTPROCFLAGS=\"${XSLTPROCFLAGS}\""
"-Dentities=\"${entities}\""
-D HHC=${HHC}
-P ${CMAKE_SOURCE_DIR}/cmake/MakeChm.cmake
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd" ${figures}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp")

add_custom_target("${lang}-${docname}-chm"
DEPENDS "${BUILD_DIR}/${chmfile}" "${BUILD_DIR}/${mapfile}")

add_dependencies(${docname}-chm "${lang}-${docname}-chm")

install(FILES
"${BUILD_DIR}/${chmfile}"
"${BUILD_DIR}/${mapfile}"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${lang}"
COMPONENT "chm")
OUTPUT "${OUTPUT_DIR}/${outfile}"
# A workaround because ${HHC} always returns FALSE.
COMMAND COMMAND ${HHC} htmlhelp.hhp || cd .
COMMAND cp "${outfile}" "${OUTPUT_DIR}/${outfile}"
WORKING_DIRECTORY "${BUILD_DIR}"
DEPENDS "${BUILD_DIR}/htmlhelp.hhp"
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-fig-trigger"
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-gnucashicon-trigger")


# Create HTML files for CHM with xsltproc
# "${BUILD_DIR}/htmlhelp.hhp" and "${BUILD_DIR}/toc.hhc" are also cleated.
add_custom_command(
OUTPUT "${BUILD_DIR}/htmlhelp.hhp"
COMMAND ${XSLTPROC} ${XSLTPROCFLAGS} ${XSLTPROCFLAGS_CHM}
-o "${BUILD_DIR}/"
--stringparam htmlhelp.chm ${outfile}
--stringparam gnc.lang ${lang}
"${CMAKE_SOURCE_DIR}/xsl/gnc-custom-${fmt}.xsl"
"${CMAKE_CURRENT_SOURCE_DIR}/${docname}.xml"
DEPENDS ${entities} "${docname}.xml" ${dtd_files} ${xsl_files})

# Copy figures for this document
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-fig-trigger"
COMMAND ${CMAKE_COMMAND} -E copy ${figures} "${BUILD_DIR}/figures"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-fig-trigger"
DEPENDS ${figures}
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger")

# Copy XSL Stylesheet icons
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-xslticon-trigger"
# PNG admonition icons are used in chm.
COMMAND cp -f "${CMAKE_SOURCE_DIR}/xsl/images/*.png" "${BUILD_DIR}/images"
# PNG callout icons are used in chm.
COMMAND cp -f "${CMAKE_SOURCE_DIR}/xsl/images/callouts/*.png" "${BUILD_DIR}/images/callouts"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-xslticon-trigger"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger")

# Copy GnuCash-Specific icons
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-gnucashicon-trigger"
# PNG icons are used in chm. SVG is not supported.
COMMAND cp -f "${CMAKE_SOURCE_DIR}/xsl/icons/*.png" "${BUILD_DIR}/images"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-gnucashicon-trigger"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-xslticon-trigger"
"${gnucash_icon_files}")



add_custom_target("${lang}-${docname}-${fmt}"
DEPENDS "${OUTPUT_DIR}/${outfile}")

add_dependencies(${docname}-${fmt} "${lang}-${docname}-${fmt}")

install(FILES "${OUTPUT_DIR}/${outfile}"
DESTINATION "share/doc/${lang}"
OPTIONAL
COMPONENT "${fmt}")

endfunction()
134 changes: 106 additions & 28 deletions cmake/AddEpubTarget.cmake
Original file line number Diff line number Diff line change
@@ -1,51 +1,129 @@
function (add_epub_target docname lang entities figures)
#
# A function to generate epub and mobi documentation
# A mobi is converted from epub.
#
# FUNCTION:
# add_epub_target
# ARGUMENTS:
# - docname: The basename of the main xml file. Will be used to locate
# this primary xml file and for various output files/directories.
# Either "gnucash-guide" or "gnucash-help" now.
# - lang: The language of the current document, such as "C", "de" and so on.
# - entities: A list of all xml files this document is composed of. ONLY filename, WITHOUT path.
# It does NOT contain "${docname}.xml".
# - figures: A list of FULL PATH image files.
# - dtd_files: A list of FULL PATH DTD files.
##########################
# FUNCTION:
# add_mobi_target
# ARGUMENTS:
# - docname: The basename of the main xml file. Will be used to locate
# this primary xml file and for various output files/directories.
# Either "gnucash-guide" or "gnucash-help" now.
# - lang: The language of the current document, such as "C", "de" and so on.
#
function (add_epub_target docname lang entities figures dtd_files)

set(epubfile "${docname}.epub")
set(EPUB_TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/epub")
# Setup base directory
set(fmt "epub")
set(outfile "${docname}.${fmt}")

set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${fmt}")
set(OUTPUT_DIR "${CMAKE_BINARY_DIR}/share/doc/${lang}")


# GnuCash-specific xsl files
file(GLOB xsl_files "${CMAKE_SOURCE_DIR}/xsl/*.xsl")
file(GLOB gnucash_icon_files "${CMAKE_SOURCE_DIR}/xsl/icons/*")

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")

# Prepare ${BUILD_DIR}
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/OEBPS/figures"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/OEBPS/images/callouts"
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTPUT_DIR}"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger")

# Copy figures for this document
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-fig-trigger"
COMMAND ${CMAKE_COMMAND} -E copy ${figures} "${BUILD_DIR}/OEBPS/figures"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-fig-trigger"
DEPENDS ${figures}
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger")

# Copy XSL Stylesheet icons
add_custom_command(
OUTPUT "${BUILD_DIR}/${epubfile}"
COMMAND rm -fr "${EPUB_TMPDIR}"
COMMAND mkdir "${EPUB_TMPDIR}"
COMMAND echo "application/epub+zip" > "${EPUB_TMPDIR}/mimetype"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-xslticon-trigger"
# PNG admonition icons are used in EPUB.
COMMAND cp -f "${CMAKE_SOURCE_DIR}/xsl/images/*.png" "${BUILD_DIR}/OEBPS/images"
# SVG callout icons are used in EPUB.
COMMAND cp -f "${CMAKE_SOURCE_DIR}/xsl/images/callouts/*.svg" "${BUILD_DIR}/OEBPS/images/callouts"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-xslticon-trigger"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger")

# Copy GnuCash-Specific icons
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-gnucashicon-trigger"
COMMAND cp -f "${CMAKE_SOURCE_DIR}/xsl/icons/*" "${BUILD_DIR}/OEBPS/images"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-gnucashicon-trigger"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${fmt}-xslticon-trigger"
"${gnucash_icon_files}")

# Create EPUB file.
add_custom_command(
OUTPUT "${OUTPUT_DIR}/${outfile}"
COMMAND echo "application/epub+zip" > "${BUILD_DIR}/mimetype"
COMMAND ${XSLTPROC} ${XSLTPROCFLAGS}
-o "${EPUB_TMPDIR}/"
-o "${BUILD_DIR}/"
--stringparam base.dir OEBPS/
--stringparam epub.metainf.dir META-INF/
--stringparam epub.oebps.dir OEBPS/
--stringparam fop1.extensions 1
"${CMAKE_SOURCE_DIR}/xsl/1.79.2/epub/docbook.xsl"
"${CMAKE_SOURCE_DIR}/xsl/gnc-custom-${fmt}.xsl"
"${CMAKE_CURRENT_SOURCE_DIR}/${docname}.xml"
COMMAND cmake -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/figures" "${EPUB_TMPDIR}/OEBPS/figures"
COMMAND cd "${EPUB_TMPDIR}" && zip -X -r "${BUILD_DIR}/${epubfile}" mimetype META-INF OEBPS
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd" ${figures})
COMMAND cd "${BUILD_DIR}" && zip -X -r "${OUTPUT_DIR}/${outfile}" mimetype META-INF OEBPS
DEPENDS ${entities} "${docname}.xml" ${dtd_files} ${xsl_files} ${figures}
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-preparedir-trigger"
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-fig-trigger"
"${CMAKE_CURRENT_BINARY_DIR}/${fmt}-gnucashicon-trigger")

add_custom_target("${lang}-${docname}-epub"
DEPENDS "${BUILD_DIR}/${epubfile}")
add_custom_target("${lang}-${docname}-${fmt}"
DEPENDS "${OUTPUT_DIR}/${outfile}")

add_dependencies(${docname}-epub "${lang}-${docname}-epub")
add_dependencies(${docname}-${fmt} "${lang}-${docname}-${fmt}")

install(FILES "${OUTPUT_DIR}/${outfile}"
DESTINATION "share/doc/${lang}"
OPTIONAL
COMPONENT "${fmt}")

endfunction()

function (add_mobi_target docname lang)

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")
set(fmt "mobi")
set(BUILD_DIR "${CMAKE_BINARY_DIR}/share/doc/${lang}")
set(OUTPUT_DIR "${BUILD_DIR}")

set(epubfile "${BUILD_DIR}/${docname}.epub")
set(mobifile "${BUILD_DIR}/${docname}.mobi")
set(outfile "${docname}.${fmt}")
set(epubfile "${docname}.epub")

add_custom_command(
OUTPUT "${mobifile}"
COMMAND ${EBOOK_CONVERT} "${epubfile}" "${mobifile}"
DEPENDS "${epubfile}")
OUTPUT "${OUTPUT_DIR}/${outfile}"
COMMAND ${EBOOK_CONVERT} "${OUTPUT_DIR}/${epubfile}" "${OUTPUT_DIR}/${outfile}"
DEPENDS "${OUTPUT_DIR}/${epubfile}"
"${lang}-${docname}-${fmt}")

add_custom_target("${lang}-${docname}-${fmt}"
DEPENDS "${OUTPUT_DIR}/${outfile}")

add_custom_target("${lang}-${docname}-mobi"
DEPENDS "${mobifile}")
add_dependencies(${lang}-${docname}-${fmt} "${lang}-${docname}-epub")
add_dependencies(${docname}-${fmt} "${lang}-${docname}-${fmt}")

add_dependencies(${docname}-mobi "${lang}-${docname}-mobi")
install(FILES "${OUTPUT_DIR}/${outfile}"
DESTINATION "share/doc/${lang}"
OPTIONAL
COMPONENT "${fmt}")

endfunction()
Loading