Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Jun 2, 2022
1 parent f7893b5 commit 2f31139
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 16 deletions.
25 changes: 10 additions & 15 deletions test/documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,16 @@ include (seqan3-doxygen-layout.cmake)

enable_testing ()

### Copy over snippets from sharg
### -----------------------------
### This is needed to replace sharg with seqan3 in all snippets for correct documentation.
set (SHARG_SNIPPET_OUTPUT_DIR "${CMAKE_BINARY_DIR}/sharg_snippets")
file(MAKE_DIRECTORY ${SHARG_SNIPPET_OUTPUT_DIR})
message(STATUS "Created sharg snippet directory: ${SHARG_SNIPPET_OUTPUT_DIR}")

include (${CMAKE_SOURCE_DIR}/../cmake/seqan3_test_files.cmake)
seqan3_test_files (sharg_snippet_files "${SEQAN3_INCLUDE_DIR}/../submodules/sharg-parser/test/snippet/" "*.cpp")

foreach (sharg_snippet_filename ${sharg_snippet_files})
file(READ "${SEQAN3_INCLUDE_DIR}/../submodules/sharg-parser/test/snippet/${sharg_snippet_filename}" SNIPPET_INPUT_CONTENT)
string(REGEX REPLACE "sharg" "seqan3" SNIPPET_OUTPUT_CONTENT ${SNIPPET_INPUT_CONTENT})
file(WRITE "${SHARG_SNIPPET_OUTPUT_DIR}/${sharg_snippet_filename}" ${SNIPPET_OUTPUT_CONTENT})
endforeach ()
include ("${CMAKE_SOURCE_DIR}/seqan3-doxygen-copy-and-replace.cmake")

file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/additional_doc)

# Copy over snippets from sharg into ${CMAKE_SOURCE_DIR}/sharg_snippets
# This is needed to replace sharg with seqan3 in all snippets for correct documentation.
copy_files_and_replace_seqan3 ("${SEQAN3_INCLUDE_DIR}/../submodules/sharg-parser/test/snippet/"
"*.cpp"
"sharg_snippets"
"sharg")

### Add subdirectories
if (SEQAN3_USER_DOC)
Expand Down
65 changes: 65 additions & 0 deletions test/documentation/seqan3-doxygen-copy-and-replace.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# -----------------------------------------------------------------------------------------------------
# Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
# Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
# shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
# -----------------------------------------------------------------------------------------------------

cmake_minimum_required (VERSION 3.10)

include (${CMAKE_SOURCE_DIR}/../cmake/seqan3_test_files.cmake)

function (copy_files_and_replace_seqan3 INPUT_PATH WILDCARDS OUTPUT_DIR_NAME NAME_TO_REPLACE_WITH_SEQAN3)

# collect files to copy
seqan3_test_files (input_files "${INPUT_PATH}" "${WILDCARDS}")

# create output directory
file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/additional_doc/${OUTPUT_DIR_NAME})

# for each file: (1) read the file, (2) replace ${NAME_TO_REPLACE_WITH_SEQAN3} with "seqan3", (3) write the file
foreach (input_filename ${input_files})
file (READ "${INPUT_PATH}/${input_filename}" INPUT_CONTENT)
string (REGEX REPLACE "${NAME_TO_REPLACE_WITH_SEQAN3}" "seqan3" OUTPUT_CONTENT ${INPUT_CONTENT})
file (WRITE "${CMAKE_BINARY_DIR}/additional_doc/${OUTPUT_DIR_NAME}/${input_filename}" ${OUTPUT_CONTENT})
endforeach ()

endfunction()

function (copy_tutorial_and_replace_seqan3 INPUT_PATH OUTPUT_DIR_NAME NAME_TO_REPLACE_WITH_SEQAN3)

# collect files to copy
seqan3_test_files (doc_index_md_files "${INPUT_PATH}" "index.md")

# create output directory
file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/additional_doc/${OUTPUT_DIR_NAME})

# for each file: (1) read the file, (2) replace ${NAME_TO_REPLACE_WITH_SEQAN3} with "seqan3", (3) write the file
foreach (index_md_filename ${doc_index_md_files})

file (READ "${INPUT_PATH}/${index_md_filename}" INPUT_CONTENT)

string (REGEX REPLACE "${NAME_TO_REPLACE_WITH_SEQAN3}" "seqan3" OUTPUT_CONTENT ${INPUT_CONTENT})

# in case this is a documentation page, also change inlcudes and references.
# since the regex should not match any content in snippets, it's fine like this.
string(REGEX MATCHALL "[^ ]+\\.cpp" INCLUDED_CPP_FILES ${INPUT_CONTENT})

foreach (cpp_file_path ${INCLUDED_CPP_FILES})
get_filename_component(cpp_filename ${cpp_file_path} NAME)
file (READ "${INPUT_PATH}../../${cpp_file_path}" CPP_CONTENT)
string (REGEX REPLACE "${NAME_TO_REPLACE_WITH_SEQAN3}" "seqan3" CPP_OUTPUT_CONTENT ${CPP_CONTENT})
file (WRITE "${CMAKE_BINARY_DIR}/additional_doc/${OUTPUT_DIR_NAME}/${cpp_filename}" ${CPP_OUTPUT_CONTENT})
endforeach()

string (REGEX REPLACE
" [^ ]*/\([^/]*\)\.cpp"
" ${CMAKE_BINARY_DIR}/additional_doc/${OUTPUT_DIR_NAME}/\\1.cpp"
OUTPUT_CONTENT2
${OUTPUT_CONTENT})
string (REGEX REPLACE "{#\(.*\)}" "{#seqan3_\\1}" OUTPUT_CONTENT3 ${OUTPUT_CONTENT2})

file (WRITE "${CMAKE_BINARY_DIR}/additional_doc/index_files/${index_md_filename}" ${OUTPUT_CONTENT3})
endforeach ()

endfunction()
7 changes: 7 additions & 0 deletions test/documentation/seqan3-doxygen-layout.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
cmake_minimum_required (VERSION 3.10)

include (${SEQAN3_INCLUDE_DIR}/../test/cmake/seqan3_test_files.cmake)
include ("${CMAKE_SOURCE_DIR}/seqan3-doxygen-copy-and-replace.cmake")

# Replaces documentation entries in variable `DOXYGEN_LAYOUT`
#
Expand Down Expand Up @@ -69,5 +70,11 @@ replace_in_doxygen_layout ("${SEQAN3_INCLUDE_DIR}/../doc/about/" "About")
replace_in_doxygen_layout ("${SEQAN3_INCLUDE_DIR}/../doc/setup/" "Setup")
replace_in_doxygen_layout ("${SEQAN3_INCLUDE_DIR}/../doc/tutorial/" "Tutorial")
replace_in_doxygen_layout ("${SEQAN3_INCLUDE_DIR}/../doc/howto/" "How-To")
# add sharg doc
copy_tutorial_and_replace_seqan3 ("${SEQAN3_INCLUDE_DIR}/../submodules/sharg-parser/doc/tutorial/" "sharg_tut" "sharg")
replace_in_doxygen_layout ("${CMAKE_BINARY_DIR}/additional_doc/index_files" "Tutorial")

copy_tutorial_and_replace_seqan3 ("${SEQAN3_INCLUDE_DIR}/../submodules/sharg-parser/doc/howto/" "sharg_howto" "sharg")
replace_in_doxygen_layout ("${CMAKE_BINARY_DIR}/additional_doc/index_files" "How-To")

file (WRITE "${CMAKE_BINARY_DIR}/DoxygenLayout.xml" ${DOXYGEN_LAYOUT})
3 changes: 2 additions & 1 deletion test/documentation/seqan3_doxygen_cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ INPUT = ${SEQAN3_DOXYGEN_SOURCE_DIR}/submodules/sharg-parser/in
${SEQAN3_DOXYGEN_SOURCE_DIR}/LICENSE.md \
${SEQAN3_DOXYGEN_SOURCE_DIR}/CHANGELOG.md \
${SEQAN3_DOXYGEN_SOURCE_DIR}/CODE_OF_CONDUCT.md \
${CMAKE_BINARY_DIR}/additional_doc/index_files \
${SEQAN3_DOXYGEN_SOURCE_DIR}/CONTRIBUTING.md
STRIP_FROM_PATH = ${SEQAN3_DOXYGEN_SOURCE_DIR}/include \
${SEQAN3_DOXYGEN_SOURCE_DIR}/submodules/sharg-parser/include
Expand All @@ -25,7 +26,7 @@ IMAGE_PATH = ${SEQAN3_DOXYGEN_SOURCE_DIR}/doc \
${SEQAN3_DOXYGEN_SOURCE_DIR}/test/documentation

# Replace namespace sharg with seqan3 when including the API documentation of sharg
FILTER_PATTERNS= *sharg*.hpp="sed -e 's/sharg/seqan3/g' -e 's/SHARG/SEQAN3/g' -e 's;\\include .*/;\\include ${CMAKE_BINARY_DIR}/sharg_snippets/;g'"
FILTER_PATTERNS= *sharg*.hpp="sed -e 's/sharg/seqan3/g' -e 's/SHARG/SEQAN3/g' -e 's;\\include .*/;\\include ${CMAKE_BINARY_DIR}/additional_doc/sharg_snippets/;g'"

## DOT SUPPORT
HAVE_DOT = ${SEQAN3_DOXYGEN_HAVE_DOT}
Expand Down

0 comments on commit 2f31139

Please sign in to comment.