Skip to content

Commit 8ee7c96

Browse files
committed
docs: adds a 'make sphinx' target that can be run after 'make install' to generate the Python docs.
1 parent 141d2ec commit 8ee7c96

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

cmake/Modules/FindSphinx.cmake

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# - This module looks for Sphinx
2+
# Find the Sphinx documentation generator
3+
#
4+
# This modules defines
5+
# SPHINX_EXECUTABLE
6+
# SPHINX_FOUND
7+
8+
#=============================================================================
9+
# Copyright 2002-2009 Kitware, Inc.
10+
# Copyright 2009-2011 Peter Colberg
11+
#
12+
# Distributed under the OSI-approved BSD License (the "License");
13+
# see accompanying file COPYING-CMAKE-SCRIPTS for details.
14+
#
15+
# This software is distributed WITHOUT ANY WARRANTY; without even the
16+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17+
# See the License for more information.
18+
#=============================================================================
19+
# (To distribute this file outside of CMake, substitute the full
20+
# License text for the above reference.)
21+
22+
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
23+
HINTS
24+
$ENV{SPHINX_DIR}
25+
PATH_SUFFIXES bin
26+
DOC "Sphinx documentation generator"
27+
)
28+
29+
include(FindPackageHandleStandardArgs)
30+
31+
find_package_handle_standard_args(Sphinx DEFAULT_MSG
32+
SPHINX_EXECUTABLE
33+
)
34+
35+
mark_as_advanced(
36+
SPHINX_EXECUTABLE
37+
)

docs/CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
# Setup dependencies
2222
########################################################################
2323
find_package(Doxygen)
24+
find_package(Sphinx)
2425

2526
########################################################################
2627
# Register component
2728
########################################################################
2829
include(GrComponent)
2930
GR_REGISTER_COMPONENT("doxygen" ENABLE_DOXYGEN DOXYGEN_FOUND)
31+
GR_REGISTER_COMPONENT("sphinx" ENABLE_SPHINX SPHINX_FOUND)
3032

3133
########################################################################
3234
# Begin conditional configuration
@@ -48,3 +50,25 @@ CPACK_COMPONENT("docs"
4850
add_subdirectory(doxygen)
4951

5052
endif(ENABLE_DOXYGEN)
53+
54+
55+
########################################################################
56+
# Begin conditional configuration
57+
########################################################################
58+
if(ENABLE_SPHINX)
59+
60+
########################################################################
61+
# Setup CPack components
62+
########################################################################
63+
include(GrPackage)
64+
CPACK_COMPONENT("docs"
65+
DISPLAY_NAME "Documentation"
66+
DESCRIPTION "Sphinx generated documentation"
67+
)
68+
69+
########################################################################
70+
# Add subdirectories
71+
########################################################################
72+
add_subdirectory(sphinx)
73+
74+
endif(ENABLE_SPHINX)

docs/sphinx/CMakeLists.txt

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2012 Free Software Foundation, Inc.
2+
#
3+
# This file is part of GNU Radio
4+
#
5+
# GNU Radio is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 3, or (at your option)
8+
# any later version.
9+
#
10+
# GNU Radio is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with GNU Radio; see the file COPYING. If not, write to
17+
# the Free Software Foundation, Inc., 51 Franklin Street,
18+
# Boston, MA 02110-1301, USA.
19+
20+
include(GrPython)
21+
22+
# You can set these variables from the command line.
23+
set(SPHINXOPTS)
24+
set(SPHINXBUILD sphinx-build)
25+
set(PAPER)
26+
set(BUILDDIR ${CMAKE_CURRENT_BINARY_DIR}/build)
27+
set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
28+
29+
# Internal variables.
30+
set(PAPEROPT_a4 -D latex_paper_size=a4)
31+
set(PAPEROPT_letter -D latex_paper_size=letter)
32+
set(ALLSPHINXOPTS -d ${BUILDDIR}/doctrees ${PAPEROPT_${PAPER}} ${SPHINXOPTS} ${SRCDIR})
33+
34+
# Set up environmental variables to pass to sphinx
35+
set(LDPATH LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR})
36+
set(PYPATH PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${GR_PYTHON_DIR})
37+
message(STATUS "ENVIRONS: ${LDPATH} ${PYPATH}")
38+
39+
add_custom_target(sphinx
40+
COMMAND ${LDPATH} ${PYPATH} ${SPHINX_EXECUTABLE} -b html ${ALLSPHINXOPTS} ${BUILDDIR}/html
41+
COMMENT "Building Sphinx Documents from installed system."
42+
)
43+

0 commit comments

Comments
 (0)