Generate gromacs.7 from the wrapper binary
authorTeemu Murtola <teemu.murtola@gmail.com>
Mon, 25 Nov 2013 04:51:01 +0000 (06:51 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 28 Nov 2013 16:16:11 +0000 (17:16 +0100)
Use the same mechanism for generating gromacs.7 as with the by-topic
list of programs for the HTML pages.  Now the man page content is
up-to-date, no longer requires programs.txt, and uses the new
gmx-something names for the referenced programs.

Part of #685

Change-Id: I070f88fd366b37d1ba287a3c2e8e26a846774002

share/man/CMakeLists.txt
share/man/man7/gromacs.7.in [moved from share/man/man7/gromacs.7.cmakein with 95% similarity]
src/gromacs/commandline/cmdlinemodulemanager.cpp

index 0f347dbc716ce375a6bf3f562ea80413f7d20ca1..254a453995d374fda203b0fd1b8d004928f2f2ff 100644 (file)
@@ -51,33 +51,10 @@ else()
 endif()
 
 if(GMX_BUILD_MANPAGES)
-    # create gromacs.7
-    FILE(READ "${CMAKE_SOURCE_DIR}/admin/programs.txt" contents)
-
-    # Convert file contents into a CMake list. First escape ;
-    STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
-    STRING(REGEX REPLACE "\n" ";" contents "${contents}")
-
-    set(PROGMANPAGES "")
-    foreach(line ${contents})
-        if (${line} MATCHES "^HEAD\\|")
-            string(REGEX REPLACE "^HEAD\\|" "" DESC ${line})
-            set(PROGMANPAGES "${PROGMANPAGES}.Sh \"${DESC}\"\n.IX Subsection \"${DESC}\"\n.Vb\n.ta 16n\n")
-        elseif(${line} MATCHES "^END$")
-            set(PROGMANPAGES "${PROGMANPAGES}.Ve\n")
-        elseif(${line} MATCHES "\\|")
-            string(REGEX REPLACE "\\|" "\t" line ${line})
-            set(PROGMANPAGES "${PROGMANPAGES}\\&  ${line}\n")
-        else()
-            message(WARNING "Incorrectly formated line \"${line}\" in programs.txt")
-        endif()
-    endforeach()
-    configure_file(man7/gromacs.7.cmakein man7/gromacs.7)
-    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man7/gromacs.7
-        DESTINATION ${MAN_INSTALL_DIR}/man7
-        COMPONENT man)
-
     file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1)
+    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man7)
+    file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/man7/gromacs.7.in
+         DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/man7)
     # TODO: It could be nicer to not do this as part of the ALL target,
     # but instead on demand as part of make install.
     add_custom_target(man ALL
@@ -88,6 +65,9 @@ if(GMX_BUILD_MANPAGES)
     install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man1
         DESTINATION ${MAN_INSTALL_DIR}
         COMPONENT man)
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man7/gromacs.7
+        DESTINATION ${MAN_INSTALL_DIR}/man7
+        COMPONENT man)
     set_directory_properties(PROPERTIES
         ADDITIONAL_MAKE_CLEAN_FILES man1)
 
similarity index 95%
rename from share/man/man7/gromacs.7.cmakein
rename to share/man/man7/gromacs.7.in
index 829867a4c649bfe5edd012cdff972697a240e75e..09d307fc56ed1867dcd86e622850286573457490 100644 (file)
 .\" ========================================================================
 .\"
 .IX Title "GROMACS 7"
-.TH GROMACS 7 "" "${PROJECT_VERSION}" "GROMACS Manual"
+.TH GROMACS 7 "" "@VERSION@" "GROMACS Manual"
 .SH "NAME"
 gromacs \- molecular dynamics simulation suite
 .SH "DESCRIPTION"
@@ -146,7 +146,7 @@ to a wide variety of chemical and biological research questions.
 .PP
 The following commands make up the GROMACS suite.  Please refer to their
 individual man pages for further details.
-${PROGMANPAGES}
+@PROGMANPAGES@
 .PP
 .SH "ADDITIONAL DOCUMENTATION"
 .IX Header "ADDITIONAL DOCUMENTATION"
@@ -154,9 +154,7 @@ Consult the manual at <\fIhttp://www.gromacs.org/content/view/27/42/\fR> for an
 introduction to molecular dynamics in general and GROMACS in particular,
 as well as an overview of the individual programs.
 .PP
-The shorter HTML reference and GROMACS FAQ are available in \fB/usr/share/doc/gromacs/html/\fR .
-.PP
-Tutorial files and other miscellaneous references are stored in \fB/usr/share/gromacs/\fR .
+The shorter HTML reference is available in \fB/usr/share/doc/gromacs/html/\fR .
 .SH "REFERENCES"
 .IX Header "REFERENCES"
 The development of GROMACS is mainly funded by academic research grants.
index 8c1b657e675123dc545ec74d54fc2d8a46936905..d709f562ffe3e1622914507d20ce97d03a843e98 100644 (file)
@@ -447,13 +447,15 @@ class HelpExportMan : public HelpExportInterface
             const std::string                &displayName);
         virtual void finishModuleExport() {}
 
-        virtual void startModuleGroupExport() {}
-        virtual void exportModuleGroup(const char                * /*title*/,
-                                       const ModuleGroupContents & /*modules*/) {}
-        virtual void finishModuleGroupExport() {}
+        virtual void startModuleGroupExport();
+        virtual void exportModuleGroup(const char                *title,
+                                       const ModuleGroupContents &modules);
+        virtual void finishModuleGroupExport();
 
     private:
-        HelpLinks  links_;
+        HelpLinks                links_;
+        boost::scoped_ptr<File>  man7File_;
+        std::string              man7Footer_;
 };
 
 void HelpExportMan::exportModuleHelp(
@@ -483,6 +485,46 @@ void HelpExportMan::exportModuleHelp(
     file.writeLine("More information about \\fBGROMACS\\fR is available at <\\fIhttp://www.gromacs.org/\\fR>.");
 }
 
+void HelpExportMan::startModuleGroupExport()
+{
+    const char *const programListPlaceholder = "@PROGMANPAGES@";
+
+    const std::string man7Template = gmx::File::readToString("man7/gromacs.7.in");
+    const size_t      index        = man7Template.find(programListPlaceholder);
+    GMX_RELEASE_ASSERT(index != std::string::npos,
+                       "gromacs.7.in must contain a @PROGMANPAGES@ line");
+    std::string header = man7Template.substr(0, index);
+    man7Footer_ = man7Template.substr(index + std::strlen(programListPlaceholder));
+    header      = replaceAll(header, "@VERSION@", GromacsVersion());
+    man7File_.reset(new File("man7/gromacs.7", "w"));
+    man7File_->writeLine(header);
+}
+
+void HelpExportMan::exportModuleGroup(const char                *title,
+                                      const ModuleGroupContents &modules)
+{
+    man7File_->writeLine(formatString(".Sh \"%s\"", title));
+    man7File_->writeLine(formatString(".IX Subsection \"%s\"", title));
+    man7File_->writeLine(".Vb");
+    man7File_->writeLine(".ta 16n");
+
+    ModuleGroupContents::const_iterator module;
+    for (module = modules.begin(); module != modules.end(); ++module)
+    {
+        const std::string &tag(module->first);
+        man7File_->writeLine(formatString("\\&  %s\t%s",
+                                          tag.c_str(), module->second));
+    }
+
+    man7File_->writeLine(".Ve");
+}
+
+void HelpExportMan::finishModuleGroupExport()
+{
+    man7File_->writeLine(man7Footer_);
+    man7File_->close();
+}
+
 /********************************************************************
  * HelpExportHtml
  */
@@ -516,8 +558,8 @@ class HelpExportHtml : public HelpExportInterface
         void writeHtmlHeader(File *file, const std::string &title) const;
         void writeHtmlFooter(File *file) const;
 
-        boost::scoped_ptr<File>  indexFile_;
         HelpLinks                links_;
+        boost::scoped_ptr<File>  indexFile_;
         std::string              header_;
         std::string              footer_;
 };