Salome HOME
Revert "Synchronize adm files"
[tools/documentation.git] / CMakeModules / SalomeDocumentationMacros.cmake
1 # Copyright (C) 2013-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Author: Roman NIKOLAEV
20 #
21
22 #----------------------------------------------------------------------------
23 # SALOME_ADD_SPHINX_DOC is a macro useful for generating sphinx documentation
24 #
25 # USAGE: SALOME_ADD_SPHINX_DOC(sphinx_type [path1 path2 ... ])
26 #
27 # ARGUMENTS:
28 #
29 # sphinx_type: IN - type of the sphinx generator, use one of the following  types: 
30 #
31 #                       html       - to make standalone HTML files
32 #                       dirhtml    - to make HTML files named index.html in directories
33 #                       singlehtml - to make a single large HTML file
34 #                       pickle     - to make pickle files
35 #                       json       - to make JSON files
36 #                       htmlhelp   - to make HTML files and a HTML help project
37 #                       qthelp     - to make HTML files and a qthelp project"
38 #                       devhelp    to make HTML files and a Devhelp project"
39 #                       epub       to make an epub"
40 #                       latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
41 #                       latexpdf   to make LaTeX files and run them through pdflatex"
42 #                       text       to make text files"
43 #                       man        to make manual pages"
44 #                       texinfo    to make Texinfo files"
45 #                       info       to make Texinfo files and run them through makeinfo
46 #                       gettext    to make PO message catalogs"
47 #                       changes    to make an overview of all changed/added/deprecated items
48 #                       linkcheck  to check all external links for integrity"
49 #                       doctest    to run all doctests embedded in the documentation (if enabled)\
50
51 # sphinx_name: IN - documentation target name
52 #
53 # path<N>    : IN - optional arguments, list of the paths whese contains the sphinx configuration files.
54 #
55 # ADDITIONAL SETTINGS:
56 #
57 # Also you can set these variables to define additional sphinx settings:
58 #
59 #                        SPHINXOPTS    - sphinx executable options
60 #                        PAPER         - LaTeX paper type          ("a4" by default)
61 #                        BUILDDIR      - local sphinx build directory  ("_build" by default)
62 #----------------------------------------------------------------------------
63
64 MACRO(SALOME_ADD_SPHINX_DOC sphinx_type sphinx_name)
65
66 # Get type and additional settings
67  SET(SPHINX_TYPE ${sphinx_type})
68  IF(${SPHINX_TYPE} STREQUAL "")
69    SET(SPHINX_TYPE html)
70  ENDIF(${SPHINX_TYPE} STREQUAL "")
71
72  IF("${PAPER}" STREQUAL "")
73    SET(PAPER a4)
74  ENDIF()
75  
76  IF("${BUILDDIR}" STREQUAL "")
77    SET(BUILDDIR _build)
78  ENDIF()
79
80  # Initialize internal variables
81  SET(PAPEROPT_a4 -D latex_paper_size=a4)
82  SET(PAPEROPT_letter -D latex_paper_size=letter)
83  SET(ALLSPHINXOPTS  -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS})
84  SET(I18NSPHINXOPTS  ${PAPEROPT_${PAPER}} ${SPHINXOPTS})
85
86  FOREACH(value ${ARGN})
87    SET(ALLSPHINXOPTS ${ALLSPHINXOPTS} ${value})
88    SET(I18NSPHINXOPTS ${I18NSPHINXOPTS} ${value})
89  ENDFOREACH(value ${ARGN})
90
91  # Set internal out directory
92  SET(_OUT_DIR ${sphinx_type}) 
93  IF(${sphinx_type} STREQUAL "gettext")
94    SET(_OUT_DIR gettext)
95    SET(ALLSPHINXOPTS ${I18NSPHINXOPTS})
96  ENDIF(${sphinx_type} STREQUAL "gettext")
97
98  # Build sphinx command
99  SET(_CMD_OPTIONS -b ${sphinx_type} ${ALLSPHINXOPTS} ${BUILDDIR}/${_OUT_DIR})
100
101  # This macro mainly prepares the environment in which sphinx should run:
102  # this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ...
103  SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_CMD_OPTIONS}")
104  ADD_CUSTOM_TARGET(${sphinx_name} ALL ${_cmd})
105
106 ENDMACRO(SALOME_ADD_SPHINX_DOC sphinx_type)