Skip to content

Commit cc752a5

Browse files
committed
Initial CMake version of Sphinx stuff.
1 parent d2a1a94 commit cc752a5

File tree

5 files changed

+62
-278
lines changed

5 files changed

+62
-278
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ build/VC2010
2222

2323
# Sphinx generated documentation
2424
docs/_*/
25+
docs/html/
2526

2627
#except for the real one
2728
!build/

CMake/Modules/FindSphinx.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# build the documentation with Sphinx
2+
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
3+
HINTS
4+
$ENV{SPHINX_DIR}
5+
PATH_SUFFIXES bin
6+
DOC "Sphinx Documentation Generator"
7+
)
8+
9+
include(FindPackageHandleStandardArgs)
10+
11+
find_package_handle_standard_args(Sphinx DEFAULT_MSG
12+
SPHINX_EXECUTABLE
13+
)
14+
15+
mark_as_advanced(SPHINX_EXECUTABLE)
16+

CMakeLists.txt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ else(CMAKE_CONFIGURATION_TYPES)
1010
endif (NOT CMAKE_BUILD_TYPE)
1111
endif(CMAKE_CONFIGURATION_TYPES)
1212

13+
SET(BUILD_DOCS "True")# CACHE STRING "Choose whether to build the documentation (requires python and Sphinx.")
14+
1315
## some generic CMake magic
1416
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
1517
project(dfhack)
@@ -173,8 +175,9 @@ endif()
173175
IF(BUILD_LIBRARY)
174176
add_subdirectory (library)
175177
## install the default documentation files
176-
install(FILES LICENSE NEWS "Lua API.html" Readme.html Compile.html Contributors.html DESTINATION ${DFHACK_USERDOC_DESTINATION})
177-
install(DIRECTORY images DESTINATION ${DFHACK_USERDOC_DESTINATION})
178+
#install(FILES LICENSE NEWS "Lua API.html" Readme.html Compile.html Contributors.html DESTINATION ${DFHACK_USERDOC_DESTINATION})
179+
install(FILES LICENSE NEWS DESTINATION ${DFHACK_USERDOC_DESTINATION})
180+
install(DIRECTORY docs/images DESTINATION ${DFHACK_USERDOC_DESTINATION})
178181
endif()
179182

180183
install(DIRECTORY dfhack-config/ DESTINATION dfhack-config/default)
@@ -186,6 +189,31 @@ endif()
186189

187190
add_subdirectory(scripts)
188191

192+
#find_package(Sphinx REQUIRED)
193+
find_package(Sphinx)
194+
if (BUILD_DOCS)
195+
196+
set(SPHINX_THEME "alabaster")
197+
set(SPHINX_THEME_DIR)
198+
set(SPHINX_BINARY_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/_build")
199+
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/_build/_doctrees")
200+
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/")
201+
202+
configure_file(
203+
"${CMAKE_CURRENT_SOURCE_DIR}/docs/conf.py.in"
204+
"${SPHINX_BINARY_BUILD_DIR}/conf.py"
205+
@ONLY)
206+
207+
add_custom_target(dfhack_docs ALL
208+
${SPHINX_EXECUTABLE}
209+
-q -b html
210+
-c "${SPHINX_BINARY_BUILD_DIR}"
211+
-d "${SPHINX_CACHE_DIR}"
212+
"${CMAKE_CURRENT_SOURCE_DIR}"
213+
"${SPHINX_HTML_DIR}"
214+
COMMENT "Building HTML documentation with Sphinx")
215+
endif()
216+
189217
# Packaging with CPack!
190218
IF(UNIX)
191219
if(APPLE)
@@ -204,3 +232,5 @@ ELSE()
204232
ENDIF()
205233
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_PACKAGE_PLATFORM_NAME}")
206234
INCLUDE(CPack)
235+
236+
#INCLUDE(FindSphinx.cmake)

conf.py renamed to docs/conf.py.in

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@
5656
# |version| and |release|, also used in various other places throughout the
5757
# built documents.
5858

59-
def get_version():
60-
"""Return the DFHack version string, from CMakeLists.txt"""
61-
version, release = '', ''
62-
with open('CMakeLists.txt') as f:
63-
for s in f.readlines():
64-
if fnmatch.fnmatch(s.upper(), 'SET(DF_VERSION "?.??.??")\n'):
65-
version = s.upper().replace('SET(DF_VERSION "', '')
66-
elif fnmatch.fnmatch(s.upper(), 'SET(DFHACK_RELEASE "r*")\n'):
67-
release = s.upper().replace('SET(DFHACK_RELEASE "', '').lower()
68-
return (version + '-' + release).replace('")\n', '')
59+
#def get_version():
60+
# """Return the DFHack version string, from CMakeLists.txt"""
61+
# version, release = '', ''
62+
# with open('CMakeLists.txt') as f:
63+
# for s in f.readlines():
64+
# if fnmatch.fnmatch(s.upper(), 'SET(DF_VERSION "?.??.??")\n'):
65+
# version = s.upper().replace('SET(DF_VERSION "', '')
66+
# elif fnmatch.fnmatch(s.upper(), 'SET(DFHACK_RELEASE "r*")\n'):
67+
# release = s.upper().replace('SET(DFHACK_RELEASE "', '').lower()
68+
# return (version + '-' + release).replace('")\n', '')
6969

7070
# The short X.Y version.
71-
version = get_version()
71+
version = '@DFHACK_VERSION@'
7272
# The full version, including alpha/beta/rc tags.
73-
release = get_version()
73+
release = '@DFHACK_VERSION@'
7474

7575
# The language for content autogenerated by Sphinx. Refer to documentation
7676
# for a list of supported languages.
@@ -121,7 +121,7 @@ def get_version():
121121

122122
# The theme to use for HTML and HTML Help pages. See the documentation for
123123
# a list of builtin themes.
124-
html_theme = 'alabaster'
124+
html_theme = '@SPHINX_THEME@'
125125

126126
# Theme options are theme-specific and customize the look and feel of a theme
127127
# further. For a list of options available for each theme, see the

make.bat

Lines changed: 0 additions & 263 deletions
This file was deleted.

0 commit comments

Comments
 (0)