Pass version from CMake to Sphinx
This commit is contained in:
parent
646829e34d
commit
b83fd00183
@ -117,6 +117,14 @@ endif ()
|
||||
set_target_properties(cppformat
|
||||
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
||||
|
||||
set(CPPFORMAT_VERSION 1.2.0)
|
||||
if (NOT CPPFORMAT_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||
message(FATAL_ERROR "Invalid version format ${CPPFORMAT_VERSION}.")
|
||||
endif ()
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
|
||||
if (FMT_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif ()
|
||||
@ -126,14 +134,6 @@ if (FMT_TEST)
|
||||
add_subdirectory(test)
|
||||
endif ()
|
||||
|
||||
set(CPPFORMAT_VERSION 1.2.0)
|
||||
if (NOT CPPFORMAT_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||
message(FATAL_ERROR "Invalid version format ${CPPFORMAT_VERSION}.")
|
||||
endif ()
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
|
||||
set_target_properties(cppformat PROPERTIES
|
||||
VERSION ${CPPFORMAT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||
|
||||
|
@ -4,7 +4,8 @@ if (NOT DOXYGEN)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
add_custom_target(doc COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py)
|
||||
add_custom_target(doc
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${CPPFORMAT_VERSION})
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
DESTINATION share/doc/cppformat)
|
||||
|
2
doc/_templates/layout.html
vendored
2
doc/_templates/layout.html
vendored
@ -51,7 +51,7 @@
|
||||
<li class="dropdown">
|
||||
{# TODO: update versions automatically #}
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
|
||||
aria-expanded="false">dev <span class="caret"></span></a>
|
||||
aria-expanded="false">{{ version }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="http://cppformat.github.io/1.1.0/">1.1.0</a></li>
|
||||
<li><a href="http://cppformat.github.io/1.0.0/">1.0.0</a></li>
|
||||
|
@ -18,7 +18,7 @@ def pip_install(package, commit=None, **kwargs):
|
||||
print('Installing {}'.format(package))
|
||||
check_call(['pip', 'install', '--upgrade', package])
|
||||
|
||||
def build_docs():
|
||||
def build_docs(version='dev'):
|
||||
# Create virtualenv.
|
||||
doc_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
virtualenv_dir = 'virtualenv'
|
||||
@ -77,8 +77,9 @@ def build_docs():
|
||||
'''.format(os.path.dirname(doc_dir)).encode('UTF-8'))
|
||||
if p.returncode != 0:
|
||||
raise CalledProcessError(p.returncode, cmd)
|
||||
check_call(['sphinx-build', '-D',
|
||||
'breathe_projects.format=' + os.path.join(os.getcwd(), 'doxyxml'),
|
||||
check_call(['sphinx-build',
|
||||
'-Dbreathe_projects.format=' + os.path.join(os.getcwd(), 'doxyxml'),
|
||||
'-Dversion=' + version, '-Drelease=' + version, '-Aversion=' + version,
|
||||
'-b', 'html', doc_dir, 'html'])
|
||||
try:
|
||||
check_call(['lessc', '--clean-css',
|
||||
@ -93,4 +94,4 @@ def build_docs():
|
||||
return 'html'
|
||||
|
||||
if __name__ == '__main__':
|
||||
build_docs()
|
||||
build_docs(sys.argv[1])
|
||||
|
12
doc/conf.py
12
doc/conf.py
@ -47,7 +47,7 @@ source_suffix = '.rst'
|
||||
|
||||
# General information about the project.
|
||||
project = u'C++ Format'
|
||||
copyright = u'2012-2014, Victor Zverovich'
|
||||
copyright = u'2012-2015, Victor Zverovich'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
@ -55,15 +55,11 @@ copyright = u'2012-2014, Victor Zverovich'
|
||||
#
|
||||
# The short X.Y version.
|
||||
|
||||
# Get version from CMakeLists.txt.
|
||||
with open('../CMakeLists.txt') as f:
|
||||
for line in f:
|
||||
m = re.match(r'set\(CPPFORMAT_VERSION (.+)\)', line.strip())
|
||||
if m:
|
||||
version = m.group(1)
|
||||
# Version and release are passed from CMake.
|
||||
#version = None
|
||||
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
#release = version
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
Loading…
Reference in New Issue
Block a user