diff options
author | Roger Leigh <rleigh@codelibre.net> | 2022-05-30 07:21:53 +0100 |
---|---|---|
committer | Roger Leigh <rleigh@codelibre.net> | 2022-06-04 20:53:23 +0100 |
commit | 21ae5bbb020fe649d8059079ebb1c2def8aef6a4 (patch) | |
tree | d54791ff4a49308c441b594f0d1930fd428d413b /cmake/Sphinx.cmake | |
parent | 9ba9c66ccaed95abc4be074801ecd7fdf058fb37 (diff) | |
download | libtiff-git-21ae5bbb020fe649d8059079ebb1c2def8aef6a4.tar.gz |
Convert HTML documentation to Sphinx RST
* Add CMake build logic
* Add Autotools build logic
* Move from html/ to doc/
* Manual pages are still generated HTML for the time being
Diffstat (limited to 'cmake/Sphinx.cmake')
-rw-r--r-- | cmake/Sphinx.cmake | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/cmake/Sphinx.cmake b/cmake/Sphinx.cmake new file mode 100644 index 00000000..8b78d41c --- /dev/null +++ b/cmake/Sphinx.cmake @@ -0,0 +1,92 @@ +# #%L +# OME Files C++ libraries (cmake build infrastructure) +# %% +# Copyright © 2015 Open Microscopy Environment: +# - Massachusetts Institute of Technology +# - National Institutes of Health +# - University of Dundee +# - Board of Regents of the University of Wisconsin-Madison +# - Glencoe Software, Inc. +# %% +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing official +# policies, either expressed or implied, of any organization. +# #L% + +find_package(Python3 COMPONENTS Interpreter) + +# Sphinx documentation generator +find_program(SPHINX_BUILD sphinx-build) +if (SPHINX_BUILD) + message(STATUS "Looking for sphinx-build - ${SPHINX_BUILD}") +else() + message(STATUS "Looking for sphinx-build - not found") +endif() + +set(SPHINX_DEFAULT OFF) +if(SPHINX_BUILD) + set(SPHINX_DEFAULT ON) +endif() +option(sphinx "Enable sphinx manual page and HTML documentation" ${SPHINX_DEFAULT}) +option(sphinx-linkcheck "Check sphinx documentation links by default" OFF) + +set(BUILD_SPHINX ${sphinx}) + +set(_ome_sphinx_list_dir "${CMAKE_CURRENT_LIST_DIR}") + +function(sphinx_manpages srcdir confdir mandir manvar) + execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${_ome_sphinx_list_dir}/list-manpages.py + "${confdir}" "${srcdir}" "${mandir}" + RESULT_VARIABLE sphinx_man_fail + OUTPUT_VARIABLE MAN_PAGES) + if (sphinx_man_fail) + message(WARNING "Failed to get generated sphinx manual pages from ${confdir}") + endif() + string(REPLACE "\n" ";" MAN_PAGES "${MAN_PAGES}") + set(${manvar} "${MAN_PAGES}" PARENT_SCOPE) +endfunction(sphinx_manpages) + +function(sphinx_manpage_dependencies srcdir confdir depvar) + execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${_ome_sphinx_list_dir}/list-manpage-dependencies.py + "${confdir}" + "${srcdir}" + RESULT_VARIABLE sphinx_dep_fail + OUTPUT_VARIABLE SPHINX_MAN_DEPENDENCIES) + if (sphinx_dep_fail) + message(WARNING "Failed to get Sphinx dependencies from ${confdir}") + endif() + string(REPLACE "\n" ";" SPHINX_MAN_DEPENDENCIES "${SPHINX_MAN_DEPENDENCIES}") + set(${depvar} "${SPHINX_MAN_DEPENDENCIES}" PARENT_SCOPE) +endfunction(sphinx_manpage_dependencies) + +function(sphinx_dependencies srcdir depvar) + file(GLOB_RECURSE CRUDE_SPHINX_DEPENDENCIES "${srcdir}/*.rst") + foreach(file ${CRUDE_SPHINX_DEPENDENCIES}) + string(FIND "${file}" "_build" FILE_MATCH) + if(FILE_MATCH EQUAL -1) + list(APPEND SPHINX_DEPENDENCIES "${file}") + endif() + endforeach() + set(${depvar} "${SPHINX_DEPENDENCIES}" PARENT_SCOPE) +endfunction(sphinx_dependencies) |