From f88332f5b7e325d9ee6d43b54aa3dc8f78b2dc72 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Oct 2013 09:58:25 -0400 Subject: 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. --- Help/manual/ccmake.1.rst | 2 ++ Help/manual/cmake-commands.7.rst | 2 ++ Help/manual/cmake-developer.7.rst | 2 ++ Help/manual/cmake-generator-expressions.7.rst | 2 ++ Help/manual/cmake-generators.7.rst | 2 ++ Help/manual/cmake-gui.1.rst | 2 ++ Help/manual/cmake-modules.7.rst | 2 ++ Help/manual/cmake-policies.7.rst | 2 ++ Help/manual/cmake-properties.7.rst | 2 ++ Help/manual/cmake-variables.7.rst | 2 ++ Help/manual/cmake.1.rst | 2 ++ Help/manual/cpack.1.rst | 2 ++ Help/manual/ctest.1.rst | 2 ++ Utilities/Sphinx/CMakeLists.txt | 1 + Utilities/Sphinx/conf.py.in | 39 ++++++++++++++++----------- 15 files changed, 51 insertions(+), 15 deletions(-) diff --git a/Help/manual/ccmake.1.rst b/Help/manual/ccmake.1.rst index 62a7dcf..0c4f47e 100644 --- a/Help/manual/ccmake.1.rst +++ b/Help/manual/ccmake.1.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Curses Dialog Command-Line Reference + ccmake(1) ********* diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 71d7375..9b23efa 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Language Command Reference + cmake-commands(7) ***************** diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 198a240..ee2016f 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Developer Reference + cmake-developer(7) ****************** diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 849ee36..ddde183 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Generator Expressions + cmake-generator-expressions(7) ****************************** diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index c73d587..4f0d9c3 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Generators Reference + cmake-generators(7) ******************* diff --git a/Help/manual/cmake-gui.1.rst b/Help/manual/cmake-gui.1.rst index e773ee1..ff01332 100644 --- a/Help/manual/cmake-gui.1.rst +++ b/Help/manual/cmake-gui.1.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake GUI Command-Line Reference + cmake-gui(1) ************ diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index da518d3..1f3e59f 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Modules Reference + cmake-modules(7) **************** diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index fcbccba..e3cf74d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Policies Reference + cmake-policies(7) ***************** diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 6fbde74..7fe1bf2 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Properties Reference + cmake-properties(7) ******************* diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 22a1c4d..dccaf64 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Variables Reference + cmake-variables(7) ****************** diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index d2a45aa..f74402e 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CMake Command-Line Reference + cmake(1) ******** diff --git a/Help/manual/cpack.1.rst b/Help/manual/cpack.1.rst index 5c6567c..22e5d5a 100644 --- a/Help/manual/cpack.1.rst +++ b/Help/manual/cpack.1.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CPack Command-Line Reference + cpack(1) ******** diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index 43fb961..4a5f12e 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -1,3 +1,5 @@ +.. cmake-manual-description: CTest Command-Line Reference + ctest(1) ******** diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 16d9aac..2ecd7ed 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -35,6 +35,7 @@ elseif(NOT SPHINX_EXECUTABLE) message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") endif() +set(conf_docs "${CMake_SOURCE_DIR}/Help") set(conf_path "${CMAKE_CURRENT_SOURCE_DIR}") set(conf_copyright "2000-2013 Kitware, Inc.") set(conf_version "${CMake_MAJOR_VERSION}.${CMake_MINOR_VERSION}.${CMake_PATCH_VERSION}") diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in index 5dbdede..ea00b78 100644 --- a/Utilities/Sphinx/conf.py.in +++ b/Utilities/Sphinx/conf.py.in @@ -10,6 +10,9 @@ # See the License for more information. #============================================================================= import sys +import os +import re +import glob sys.path.insert(0, r'@conf_path@') @@ -27,21 +30,27 @@ exclude_patterns = [] extensions = ['cmake'] -man_pages = [ - ('manual/cmake.1', 'cmake', 'CMake Command-Line Reference', [], 1), - ('manual/ccmake.1', 'ccmake', 'CMake Curses Dialog Command-Line Reference', [], 1), - ('manual/cmake-gui.1', 'cmake-gui', 'CMake GUI Command-Line Reference', [], 1), - ('manual/cpack.1', 'cpack', 'CPack Command-Line Reference', [], 1), - ('manual/ctest.1', 'ctest', 'CTest Command-Line Reference', [], 1), - ('manual/cmake-commands.7', 'cmake-commands', 'CMake Language Command Reference', [], 7), - ('manual/cmake-generators.7', 'cmake-generators', 'CMake Generators Reference', [], 7), - ('manual/cmake-modules.7', 'cmake-modules', 'CMake Modules Reference', [], 7), - ('manual/cmake-policies.7', 'cmake-policies', 'CMake Policies Reference', [], 7), - ('manual/cmake-properties.7', 'cmake-properties', 'CMake Properties Reference', [], 7), - ('manual/cmake-variables.7', 'cmake-variables', 'CMake Variables Reference', [], 7), - ('manual/cmake-generator-expressions.7', 'cmake-generator-expressions', 'CMake Generator Expressions', [], 7), - ('manual/cmake-developer.7', 'cmake-developer', 'CMake Developer Reference', [], 7), -] +cmake_manuals = sorted(glob.glob(r'@conf_docs@/manual/*.rst')) +cmake_manual_description = re.compile('^\.\. cmake-manual-description:(.*)$') +man_pages = [] +for fpath in cmake_manuals: + try: + name, sec, rst = os.path.basename(fpath).split('.') + desc = None + f = open(fpath, 'r') + for l in f: + m = cmake_manual_description.match(l) + if m: + desc = m.group(1).strip() + break + 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 html_show_sourcelink = True -- cgit v0.12