Commit a0651abc authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Added logic to automatically generate TOC when not provided.

This makes it possible for plugin files to be listed automatically.
parent 1e101d55
......@@ -385,6 +385,9 @@ endfunction()
# in the qhp file. Note that these files/paths are relative to the
# DESTINATION_DIRECTORY.
# DEPENDS :- (optional) targets or files that the qch generation target depends on.
#
# If neither TABLE_OF_CONTENTS or TABLE_OF_CONTENTS_FILE is specified, then the
# TOC is auto-generated.
#------------------------------------------------------------------------------
function(build_help_project name)
pv_parse_arguments(arg
......@@ -419,16 +422,7 @@ function(build_help_project name)
file(READ ${arg_TABLE_OF_CONTENTS_FILE} arg_TABLE_OF_CONTENTS)
endif()
pv_set_if_not_set(arg_TABLE_OF_CONTENTS
"<toc><section title=\"${name}\" ref=\"index.html\"></section></toc>")
set (files)
foreach(filename ${arg_FILEPATTERNS})
set (files "${files}<file>${filename}</file>\n")
endforeach()
configure_file(${ParaView_CMAKE_DIR}/build_help_project.qhp.in
${arg_DESTINATION_DIRECTORY}/${name}.qhp)
set (qhp_filename ${arg_DESTINATION_DIRECTORY}/${name}.qhp)
set (extra_args)
if (DEFINED arg_DOCUMENTATION_SOURCE_DIR)
......@@ -441,18 +435,46 @@ function(build_help_project name)
)
endif()
if (NOT DEFINED arg_TABLE_OF_CONTENTS)
# sanitize arg_FILEPATTERNS since we pass it as a command line argument.
string (REPLACE ";" "+" arg_FILEPATTERNS "${arg_FILEPATTERNS}")
set (extra_args ${extra_args}
# generate the toc at run-time.
COMMAND ${CMAKE_COMMAND}
-Doutput_file="${qhp_filename}"
-Dfile_patterns="${arg_FILEPATTERNS}"
-Dnamespace="${arg_NAMESPACE}"
-Dfolder="${arg_FOLDER}"
-Dname="${name}"
-P "${ParaView_CMAKE_DIR}/generate_qhp.cmake"
)
else ()
# toc is provided, we'll just configure the file.
set (files)
foreach(filename ${arg_FILEPATTERNS})
set (files "${files}<file>${filename}</file>\n")
endforeach()
configure_file(${ParaView_CMAKE_DIR}/build_help_project.qhp.in
${qhp_filename})
list (APPEND arg_DEPENDS ${qhp_filename})
endif()
ADD_CUSTOM_COMMAND(
OUTPUT "${arg_DESTINATION_DIRECTORY}/${name}.qch"
DEPENDS "${arg_DESTINATION_DIRECTORY}/${name}.qhp"
${arg_DEPENDS}
DEPENDS ${arg_DEPENDS}
"${ParaView_CMAKE_DIR}/generate_qhp.cmake"
${extra_args}
# Now, compile the qhp file to generate the qch.
COMMAND ${QT_HELP_GENERATOR}
"${arg_DESTINATION_DIRECTORY}/${name}.qhp"
"${qhp_filename}"
-o "${arg_DESTINATION_DIRECTORY}/${name}.qch"
COMMENT "Compiling Qt help project ${name}.qhp"
WORKING_DIRECTORY "${arg_DESTINATION_DIRECTORY}"
)
endfunction(build_help_project)
......@@ -933,7 +933,7 @@ FUNCTION(ADD_PARAVIEW_PLUGIN NAME VERSION)
if (proxy_documentation_files)
build_help_project(${NAME}
DESTINATION_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc"
FILEPATTERNS "*.html; *.css;*.png;*.jpg"
FILEPATTERNS "*.html;*.css;*.png;*.jpg"
DEPENDS "${proxy_documentation_files}")
# we don't compile the help project as a Qt resource. Instead it's
......
# Used by build_help_project CMake function to generate the qhp file.
# The WORKING_DIRECTORY for this script must be the same as the location for the
# qhp file otherwise the toc won't be generated correctly.
# Input environment:
# output_file :-
# file_patterns :-
# namespace :-
# folder :-
# name :-
set (qhp_contents
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<QtHelpProject version=\"1.0\">
<namespace>@namespace@</namespace>
<virtualFolder>@folder@</virtualFolder>
<filterSection>
@toc@
<keywords>
<!-- how to handle keywords? -->
</keywords>
<files>
@files@
</files>
</filterSection>
</QtHelpProject>")
if (NOT output_file OR NOT file_patterns OR NOT namespace OR NOT folder OR NOT name)
message(FATAL_ERROR "Missing one of the required arguments!!")
endif ()
string (REPLACE "+" ";" file_patterns "${file_patterns}")
get_filename_component(working_dir "${output_file}" PATH)
# We generate a toc using the files present.
file (GLOB matching_files RELATIVE "${CMAKE_CURRENT_BINARY_DIR}" ${file_patterns} )
set (toc)
foreach (filename ${matching_files})
string (REGEX MATCH "^(.*)\\.html$" _tmp "${filename}")
set (name_we ${CMAKE_MATCH_1})
if (name_we)
get_filename_component(filename_name "${filename}" NAME)
set (toc
"${toc} <section title=\"${filename_name}\" ref=\"${filename}\" />\n")
endif()
endforeach()
set (toc
"<toc>
<section title=\"${name}\" ref=\"index.html\" >\n
${toc}
</section>
</toc>")
set (files)
foreach(filename ${file_patterns})
set (files "${files}<file>${filename}</file>\n")
endforeach()
string(CONFIGURE "${qhp_contents}" text @ONLY)
file (WRITE "${output_file}" "${text}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment