Help: Glob manual/*.rst in Sphinx configuration
Add the man page description line as explicit markup at the top of each Help/manual/*.rst file and scan it from conf.py to automatically generate the man_pages Sphinx configuration value. This reduces the number of places that need to be changed when a new manual is added.
This commit is contained in:
parent
a1254ddd74
commit
f88332f5b7
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Curses Dialog Command-Line Reference
|
||||||
|
|
||||||
ccmake(1)
|
ccmake(1)
|
||||||
*********
|
*********
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Language Command Reference
|
||||||
|
|
||||||
cmake-commands(7)
|
cmake-commands(7)
|
||||||
*****************
|
*****************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Developer Reference
|
||||||
|
|
||||||
cmake-developer(7)
|
cmake-developer(7)
|
||||||
******************
|
******************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Generator Expressions
|
||||||
|
|
||||||
cmake-generator-expressions(7)
|
cmake-generator-expressions(7)
|
||||||
******************************
|
******************************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Generators Reference
|
||||||
|
|
||||||
cmake-generators(7)
|
cmake-generators(7)
|
||||||
*******************
|
*******************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake GUI Command-Line Reference
|
||||||
|
|
||||||
cmake-gui(1)
|
cmake-gui(1)
|
||||||
************
|
************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Modules Reference
|
||||||
|
|
||||||
cmake-modules(7)
|
cmake-modules(7)
|
||||||
****************
|
****************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Policies Reference
|
||||||
|
|
||||||
cmake-policies(7)
|
cmake-policies(7)
|
||||||
*****************
|
*****************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Properties Reference
|
||||||
|
|
||||||
cmake-properties(7)
|
cmake-properties(7)
|
||||||
*******************
|
*******************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Variables Reference
|
||||||
|
|
||||||
cmake-variables(7)
|
cmake-variables(7)
|
||||||
******************
|
******************
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CMake Command-Line Reference
|
||||||
|
|
||||||
cmake(1)
|
cmake(1)
|
||||||
********
|
********
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CPack Command-Line Reference
|
||||||
|
|
||||||
cpack(1)
|
cpack(1)
|
||||||
********
|
********
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.. cmake-manual-description: CTest Command-Line Reference
|
||||||
|
|
||||||
ctest(1)
|
ctest(1)
|
||||||
********
|
********
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ elseif(NOT SPHINX_EXECUTABLE)
|
||||||
message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
|
message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(conf_docs "${CMake_SOURCE_DIR}/Help")
|
||||||
set(conf_path "${CMAKE_CURRENT_SOURCE_DIR}")
|
set(conf_path "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
set(conf_copyright "2000-2013 Kitware, Inc.")
|
set(conf_copyright "2000-2013 Kitware, Inc.")
|
||||||
set(conf_version "${CMake_MAJOR_VERSION}.${CMake_MINOR_VERSION}.${CMake_PATCH_VERSION}")
|
set(conf_version "${CMake_MAJOR_VERSION}.${CMake_MINOR_VERSION}.${CMake_PATCH_VERSION}")
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
# See the License for more information.
|
# See the License for more information.
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import glob
|
||||||
|
|
||||||
sys.path.insert(0, r'@conf_path@')
|
sys.path.insert(0, r'@conf_path@')
|
||||||
|
|
||||||
|
@ -27,21 +30,27 @@ exclude_patterns = []
|
||||||
|
|
||||||
extensions = ['cmake']
|
extensions = ['cmake']
|
||||||
|
|
||||||
man_pages = [
|
cmake_manuals = sorted(glob.glob(r'@conf_docs@/manual/*.rst'))
|
||||||
('manual/cmake.1', 'cmake', 'CMake Command-Line Reference', [], 1),
|
cmake_manual_description = re.compile('^\.\. cmake-manual-description:(.*)$')
|
||||||
('manual/ccmake.1', 'ccmake', 'CMake Curses Dialog Command-Line Reference', [], 1),
|
man_pages = []
|
||||||
('manual/cmake-gui.1', 'cmake-gui', 'CMake GUI Command-Line Reference', [], 1),
|
for fpath in cmake_manuals:
|
||||||
('manual/cpack.1', 'cpack', 'CPack Command-Line Reference', [], 1),
|
try:
|
||||||
('manual/ctest.1', 'ctest', 'CTest Command-Line Reference', [], 1),
|
name, sec, rst = os.path.basename(fpath).split('.')
|
||||||
('manual/cmake-commands.7', 'cmake-commands', 'CMake Language Command Reference', [], 7),
|
desc = None
|
||||||
('manual/cmake-generators.7', 'cmake-generators', 'CMake Generators Reference', [], 7),
|
f = open(fpath, 'r')
|
||||||
('manual/cmake-modules.7', 'cmake-modules', 'CMake Modules Reference', [], 7),
|
for l in f:
|
||||||
('manual/cmake-policies.7', 'cmake-policies', 'CMake Policies Reference', [], 7),
|
m = cmake_manual_description.match(l)
|
||||||
('manual/cmake-properties.7', 'cmake-properties', 'CMake Properties Reference', [], 7),
|
if m:
|
||||||
('manual/cmake-variables.7', 'cmake-variables', 'CMake Variables Reference', [], 7),
|
desc = m.group(1).strip()
|
||||||
('manual/cmake-generator-expressions.7', 'cmake-generator-expressions', 'CMake Generator Expressions', [], 7),
|
break
|
||||||
('manual/cmake-developer.7', 'cmake-developer', 'CMake Developer Reference', [], 7),
|
f.close()
|
||||||
]
|
if desc:
|
||||||
|
man_pages.append(('manual/%s.%s' % (name, sec),
|
||||||
|
name, desc, [], int(sec)))
|
||||||
|
else:
|
||||||
|
sys.stderr.write("ERROR: No cmake-manual-description in '%s'\n" % fpath)
|
||||||
|
except Exception, e:
|
||||||
|
sys.stderr.write("ERROR: %s\n" % str(e))
|
||||||
man_show_urls = False
|
man_show_urls = False
|
||||||
|
|
||||||
html_show_sourcelink = True
|
html_show_sourcelink = True
|
||||||
|
|
Loading…
Reference in New Issue