Skip to content

Commit

Permalink
Initial CMake version of Sphinx stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
expwnent committed Sep 24, 2015
1 parent d2a1a94 commit cc752a5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 278 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ build/VC2010

# Sphinx generated documentation
docs/_*/
docs/html/

#except for the real one
!build/
Expand Down
16 changes: 16 additions & 0 deletions CMake/Modules/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# build the documentation with Sphinx
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx Documentation Generator"
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Sphinx DEFAULT_MSG
SPHINX_EXECUTABLE
)

mark_as_advanced(SPHINX_EXECUTABLE)

34 changes: 32 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ else(CMAKE_CONFIGURATION_TYPES)
endif (NOT CMAKE_BUILD_TYPE)
endif(CMAKE_CONFIGURATION_TYPES)

SET(BUILD_DOCS "True")# CACHE STRING "Choose whether to build the documentation (requires python and Sphinx.")

## some generic CMake magic
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(dfhack)
Expand Down Expand Up @@ -173,8 +175,9 @@ endif()
IF(BUILD_LIBRARY)
add_subdirectory (library)
## install the default documentation files
install(FILES LICENSE NEWS "Lua API.html" Readme.html Compile.html Contributors.html DESTINATION ${DFHACK_USERDOC_DESTINATION})
install(DIRECTORY images DESTINATION ${DFHACK_USERDOC_DESTINATION})
#install(FILES LICENSE NEWS "Lua API.html" Readme.html Compile.html Contributors.html DESTINATION ${DFHACK_USERDOC_DESTINATION})
install(FILES LICENSE NEWS DESTINATION ${DFHACK_USERDOC_DESTINATION})
install(DIRECTORY docs/images DESTINATION ${DFHACK_USERDOC_DESTINATION})
endif()

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

add_subdirectory(scripts)

#find_package(Sphinx REQUIRED)
find_package(Sphinx)
if (BUILD_DOCS)

set(SPHINX_THEME "alabaster")
set(SPHINX_THEME_DIR)
set(SPHINX_BINARY_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/_build")
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/_build/_doctrees")
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/")

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/docs/conf.py.in"
"${SPHINX_BINARY_BUILD_DIR}/conf.py"
@ONLY)

add_custom_target(dfhack_docs ALL
${SPHINX_EXECUTABLE}
-q -b html
-c "${SPHINX_BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${SPHINX_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx")
endif()

# Packaging with CPack!
IF(UNIX)
if(APPLE)
Expand All @@ -204,3 +232,5 @@ ELSE()
ENDIF()
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_PACKAGE_PLATFORM_NAME}")
INCLUDE(CPack)

#INCLUDE(FindSphinx.cmake)
26 changes: 13 additions & 13 deletions conf.py → docs/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@
# |version| and |release|, also used in various other places throughout the
# built documents.

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

# The short X.Y version.
version = get_version()
version = '@DFHACK_VERSION@'
# The full version, including alpha/beta/rc tags.
release = get_version()
release = '@DFHACK_VERSION@'

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

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

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
263 changes: 0 additions & 263 deletions make.bat

This file was deleted.

0 comments on commit cc752a5

Please sign in to comment.