Improve user guide text for command line interface
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 3 Jun 2015 10:54:56 +0000 (13:54 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 9 Jun 2015 04:40:58 +0000 (06:40 +0200)
- Restructure the tools.rst to have all the content on a single page.
- Correct inaccuracies in the information about common options and
  general behavior, and extend the text to cover more cases.
- Include the list of common options on the HTML pages (somewhat ugly
  still).
- Restructure the Sphinx input for easier management and
  understandability: all pages generated from the gmx binary is now
  under onlinehelp/, and all rst fragments (whether generated or not)
  are under fragments/ to make it easy to apply the same rules to all of
  them.

Change-Id: I2d55281bfba7dc781afcc2b09a9fef843730de5f

docs/CMakeLists.txt
docs/conf.py
docs/dev-manual/doxygen.rst
docs/dev-manual/gmxtree.rst
docs/dev-manual/testutils.rst
docs/dev-manual/tools.rst
docs/fragments/doxygen-links.rst [moved from docs/dev-manual/doxygen-links.rst with 100% similarity]
docs/user-guide/tools.rst
src/gromacs/commandline/cmdlinehelpmodule.cpp
src/gromacs/commandline/tests/refdata/CommandLineHelpModuleTest_ExportsHelp.xml

index f2a3809d31e817b594ae7ce8b2c13e54f50868cf..2c2c7c000edb138db664ff55100e24b7b51d869c 100644 (file)
@@ -109,7 +109,6 @@ if (SPHINX_FOUND)
         dev-manual/index.rst
         dev-manual/codelayout.rst
         dev-manual/doxygen.rst
-        dev-manual/doxygen-links.rst
         dev-manual/formatting.rst
         dev-manual/gmxtree.rst
         dev-manual/includestyle.rst
@@ -119,6 +118,7 @@ if (SPHINX_FOUND)
         dev-manual/testutils.rst
         dev-manual/tools.rst
         dev-manual/uncrustify.rst
+        fragments/doxygen-links.rst
         install-guide/index.rst
         user-guide/index.rst
         user-guide/getting-started.rst
@@ -141,8 +141,11 @@ if (SPHINX_FOUND)
          ${SPHINX_INPUT_DIR}/*.rst)
     list(REMOVE_ITEM _obsolete_sources ${SPHINX_SOURCE_FILES})
     foreach(_file ${_obsolete_sources})
-        # Skip generated files.
-        if (NOT _file MATCHES "^(programs/.*|man/bytopic)\\.rst$")
+        # Skip generated files in onlinehelp/, and fragments.
+        # The latter do not cause issues with obsolete files, as they
+        # are not considered as Sphinx input files, but will only be
+        # included using an explicit .. include::.
+        if (NOT _file MATCHES "^(onlinehelp|fragments)/.*\\.rst$")
             message(STATUS "Removing obsolete Sphinx input ${_file}")
             file(REMOVE ${SPHINX_INPUT_DIR}/${_file})
         endif()
@@ -173,8 +176,7 @@ if (SPHINX_FOUND)
         DEPENDS ${SPHINX_INPUT_FILES})
     # TODO: Make this remove obsolete .rst files.
     gmx_add_custom_output_target(sphinx-programs OUTPUT STAMP
-        COMMAND ${CMAKE_COMMAND} -E make_directory programs
-        COMMAND ${CMAKE_COMMAND} -E make_directory man
+        COMMAND ${CMAKE_COMMAND} -E make_directory onlinehelp
         COMMAND gmx -quiet help -export rst
         DEPENDS gmx
         WORKING_DIRECTORY ${SPHINX_INPUT_DIR}
index 8c903fcba6589961aa2fd2fdbac60adf3783b3af..f3d8830df971f4fb0d50a249b4aef2d164cc3f2a 100644 (file)
@@ -109,11 +109,9 @@ release = gmx_version_string_full
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-exclude_patterns = ['dev-manual/doxygen-links.rst']
+exclude_patterns = ['fragments']
 if not tags.has('do_man'):
     exclude_patterns += ['man']
-else:
-    exclude_patterns += ['man/bytopic.rst']
 
 # The reST default role (used for this markup: `text`) to use for all
 # documents.
index 6d2429b0dc5813a55fbdbe3a6f4ab3136957d537..e24b4244b999043b19a3eb97512ca9f72e05091e 100644 (file)
@@ -808,4 +808,4 @@ documented mostly along these guidelines.  Some comments in
 ``src/gromacs/selection/`` (in particular, any C-like code) predate the
 introduction of these guidelines, so those are not the best examples.
 
-.. include:: doxygen-links.rst
+.. include:: /fragments/doxygen-links.rst
index e2b624fb4b41cb13d227cce9dd1a88f983978c71..c942b6d99a26adae2dd6c8367e443b536c091b97 100644 (file)
@@ -236,4 +236,4 @@ white
 Each edge signifies an include dependency; there is no additional information
 currently included.
 
-.. include:: doxygen-links.rst
+.. include:: /fragments/doxygen-links.rst
index dadea148ddb9f2d6c77cf194f8690aa377a717f3..5e9536e34dd64d4d9c18364921fd1493365901a6 100644 (file)
@@ -196,4 +196,4 @@ Here are some things to keep in mind when working with the unit tests:
 .. _Google Test Primer: http://code.google.com/p/googletest/wiki/V1_7_Primer
 .. _Google Mock: http://code.google.com/p/googlemock/
 
-.. include:: doxygen-links.rst
+.. include:: /fragments/doxygen-links.rst
index 46fde62b1606819bf9435df7d288c30c81fe6e2c..855202aaff247be93be8135cac0fd4e9646b9e19 100644 (file)
@@ -259,4 +259,4 @@ documentation exported from source files
 
 __ doxygen-page-wrapperbinary_
 
-.. include:: doxygen-links.rst
+.. include:: /fragments/doxygen-links.rst
index ad3755ac6e5f588de01ed614a30af7c6ea7ace2a..4f193f3abb580224b2562a6ea8342143380aaed5 100644 (file)
-Command-line tools
-==================
-
-|Gromacs| includes many tools for preparing, running and analysing
-molecular dynamics simulations. These are all structured as part of the
-gmx wrapper binary, and invoked with commands like :ref:`gmx grompp`.
-:ref:`mdrun <gmx mdrun>` is the only other binary that
-:ref:`can be built <building just the mdrun binary>`; in the normal
-build it can be run with ``gmx mdrun``. Documentation for these can
-be found at the links below:
-
-.. toctree::
-
-   /programs/byname
-   /programs/bytopic
-
-   /programs/selections
+Command-line reference
+======================
 
 .. toctree::
    :hidden:
    :glob:
 
-   /programs/gmx-*
-
-Common options and behaviour
-----------------------------
-
-Optional files are not used unless the option is set, in contrast to
-non-optional files, where the default file name is used when the option is
-not set.
-
-All |Gromacs| tools will accept file options without a file extension or
-filename being specified. In such cases the default filenames will be
-used. With multiple input file types, such as generic structure format,
-the directory will be searched for files of each type with the supplied
-or default name. When no such file is found, or with output files the
-first file type will be used.
+   /onlinehelp/gmx
+   /onlinehelp/gmx-*
 
-All |Gromacs| tools check if the command line options are valid. If this
-is not the case, the program will be halted.
-
-All |Gromacs| tools have 3 hidden options:
-
-+-------------------+--------+---------------+-------------------------------------------------+
-| option            | type   | default       | description                                     |
-+===================+========+===============+=================================================+
-| ``-[no]hidden``   | bool   | \[``yes``\]   | \[hidden\] Print description for hidden options |
-+-------------------+--------+---------------+-------------------------------------------------+
-| ``-[no]quiet``    | bool   | \[``no``\]    | \[hidden\] Do not print help info               |
-+-------------------+--------+---------------+-------------------------------------------------+
-| ``-[no]debug``    | bool   | \[``no``\]    | \[hidden\] Write file with debug information    |
-+-------------------+--------+---------------+-------------------------------------------------+
-
-Many tools accept enumerated options (enum), which should be used with
-one of the arguments listed in the option description. The argument may
-be abbreviated, and the first match to the shortest argument in the list
-will be selected.
-
-Many tools also use options that may accept a vector of values. Either 1
-or 3 parameters can be supplied; when only one parameter is supplied the
-two other values are also set to this value.
+|Gromacs| includes many tools for preparing, running and analysing
+molecular dynamics simulations. These are all structured as part of a single
+:command:`gmx` wrapper binary, and invoked with commands like :command:`gmx grompp`.
+:ref:`mdrun <gmx mdrun>` is the only other binary that
+:ref:`can be built <building just the mdrun binary>`; in the normal
+build it can be run with :command:`gmx mdrun`. Documentation for these can
+be found at the respective sections below, as well as on man pages (e.g.,
+:manpage:`gmx-grompp(1)`) and with :samp:`gmx help {command}` or
+:samp:`gmx {command} -h`.
+
+Command-line interface and conventions
+--------------------------------------
+
+All |Gromacs| commands require an option before any arguments (i.e., all
+command-line arguments need to be preceded by an argument starting with a
+dash, and values not starting with a dash are arguments to the preceding
+option).  Most options, except for boolean flags, expect an argument (or
+multiple in some cases) after the option name.
+The argument must be a separate command-line argument, i.e., separated by
+space, as in ``-f traj.xtc``.  If more than one argument needs to be given to
+an option, they should be similarly separated from each other.
+Some options also have default arguments, i.e., just specifying the option
+without any argument uses the default argument.
+If an option is not specified at all, a default value is used; in the case of
+optional files, the default might be not to use that file (see below).
+
+All |Gromacs| command options start with a single dash, whether they are
+single- or multiple-letter options.  However, two dashes are also recognized
+(starting from 5.1).
+
+In addition to command-specific options, some options are handled by the
+:command:`gmx` wrapper, and can be specified for any command.  See
+:doc:`wrapper binary help </onlinehelp/gmx>` for the list of such options.
+These options are recognized both before the command name (e.g.,
+:command:`gmx -quiet grompp`) as well as after the command name (e.g.,
+:command:`gmx grompp -quiet`).
+There is also a ``-hidden`` option that can be specified in combination with
+``-h`` to show help for advanced/developer-targeted options.
+
+Most analysis commands can process a trajectory with fewer atoms than the
+run input or structure file, but only if the trajectory consists of the
+first *n* atoms of the run input or structure file.
+
+Handling specific types of command-line options
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+boolean options
+  Boolean flags can be specified like ``-pbc`` and negated like ``-nopbc``.
+  It is also possible to use an explicit value like ``-pbc no`` and
+  ``-pbc yes``.
+file name options
+  Options that accept files names have features that support using default file
+  names (where the default file name is specific to that option):
+
+  * If a required option is not set, the default is used.
+  * If an option is marked optional, the file is not used unless the option
+    is set (or other conditions make the file required).
+  * If an option is set, and no file name is provided, the default is used.
+
+  All such options will accept file names without a file extension.
+  The extension is automatically appended in such a case.
+  When multiple input formats are accepted, such as a generic structure format,
+  the directory will be searched for files of each type with the supplied or
+  default name. When no file with a recognized extension is found, an error is given.
+  For output files with multiple formats, a default file type will be used.
+
+  Some file formats can also be read from compressed (:file:`.Z` or
+  :file:`.gz`) formats.
+enum options
+  Enumerated options (enum) should be used with one of the arguments listed in
+  the option description. The argument may be abbreviated, and the first match
+  to the shortest argument in the list will be selected.
+vector options
+  Some options accept a vector of values.  Either 1 or 3 parameters can be
+  supplied; when only one parameter is supplied the two other values are also
+  set to this value.
+selection options
+  See :doc:`/onlinehelp/selections`.
+
+Commands by name
+----------------
+
+.. include:: /fragments/byname.rst
+
+Commands by topic
+-----------------
+
+.. include:: /fragments/bytopic.rst
+
+Special topics
+--------------
+
+The information in these topics is also accessible through
+:samp:`gmx help {topic}` on the command line.
 
-All |Gromacs| tools can read compressed (``*.Z``) or g-zipped (``*.gz``)
-files. There might be a problem with reading compressed [.tng] or [.xtc]
-files, but these will not compress very well anyway.
+.. toctree::
 
-Most |Gromacs| tools can process a trajectory with fewer atoms than the
-run input or structure file, but only if the trajectory consists of the
-first n atoms of the run input or structure file.
+   /onlinehelp/selections
index db58fec1040cd9efb60b1afae1e7c9d046b62092..bc883a084974685adb2028d45d22d2379b3c2d72 100644 (file)
@@ -304,13 +304,14 @@ void RootHelpTopic::writeHelp(const HelpWriterContext &context) const
     }
     else
     {
+        // TODO: This should not really end up on the HTML page.
         context.writeTitle(formatString("%s commands", helpModule_.binaryName_.c_str()));
         context.writeTextBlock(
                 "The following commands are available. Please refer to their "
                 "individual man pages or [TT][PROGRAM] help <command>[tt] "
                 "for further details.");
         context.writeTextBlock("");
-        context.writeTextBlock(".. include:: /man/bytopic.rst");
+        context.writeTextBlock(".. include:: /fragments/bytopic-man.rst");
     }
 }
 
@@ -537,9 +538,10 @@ HelpExportReStructuredText::HelpExportReStructuredText(
 void HelpExportReStructuredText::startModuleExport()
 {
     indexFile_.reset(
-            new File(outputRedirector_->openFileForWriting("programs/byname.rst")));
-    indexFile_->writeLine("Tools by Name");
-    indexFile_->writeLine("=============");
+            new File(outputRedirector_->openFileForWriting("fragments/byname.rst")));
+    indexFile_->writeLine(formatString("* :doc:`%s </onlinehelp/%s>` - %s",
+                                       binaryName_.c_str(), binaryName_.c_str(),
+                                       RootHelpText::title));
     manPagesFile_.reset(
             new File(outputRedirector_->openFileForWriting("conf-man.py")));
     manPagesFile_->writeLine("man_pages = [");
@@ -552,7 +554,7 @@ void HelpExportReStructuredText::exportModuleHelp(
 {
     // TODO: Ideally, the file would only be touched if it really changes.
     // This would make Sphinx reruns much faster.
-    File file(outputRedirector_->openFileForWriting("programs/" + tag + ".rst"));
+    File file(outputRedirector_->openFileForWriting("onlinehelp/" + tag + ".rst"));
     file.writeLine(formatString(".. _%s:", displayName.c_str()));
     if (0 == displayName.compare(binaryName_ + " mdrun"))
     {
@@ -578,7 +580,7 @@ void HelpExportReStructuredText::exportModuleHelp(
     file.writeLine("   More information about |Gromacs| is available at <http://www.gromacs.org/>.");
     file.close();
 
-    indexFile_->writeLine(formatString("* :doc:`%s <%s>` - %s",
+    indexFile_->writeLine(formatString("* :doc:`%s </onlinehelp/%s>` - %s",
                                        displayName.c_str(), tag.c_str(),
                                        module.shortDescription()));
     manPagesFile_->writeLine(
@@ -603,11 +605,9 @@ void HelpExportReStructuredText::finishModuleExport()
 void HelpExportReStructuredText::startModuleGroupExport()
 {
     indexFile_.reset(
-            new File(outputRedirector_->openFileForWriting("programs/bytopic.rst")));
-    indexFile_->writeLine("Tools by Topic");
-    indexFile_->writeLine("==============");
+            new File(outputRedirector_->openFileForWriting("fragments/bytopic.rst")));
     manPagesFile_.reset(
-            new File(outputRedirector_->openFileForWriting("man/bytopic.rst")));
+            new File(outputRedirector_->openFileForWriting("fragments/bytopic-man.rst")));
 }
 
 void HelpExportReStructuredText::exportModuleGroup(
@@ -615,7 +615,7 @@ void HelpExportReStructuredText::exportModuleGroup(
         const ModuleGroupContents &modules)
 {
     indexFile_->writeLine(title);
-    indexFile_->writeLine(std::string(std::strlen(title), '-'));
+    indexFile_->writeLine(std::string(std::strlen(title), '^'));
     manPagesFile_->writeLine(title);
     manPagesFile_->writeLine(std::string(std::strlen(title), '^'));
 
@@ -630,7 +630,7 @@ void HelpExportReStructuredText::exportModuleGroup(
         GMX_RELEASE_ASSERT(dashPos != std::string::npos,
                            "There should always be at least one dash in the tag");
         displayName[dashPos] = ' ';
-        indexFile_->writeLine(formatString("| :doc:`%s <%s>` - %s",
+        indexFile_->writeLine(formatString(":doc:`%s </onlinehelp/%s>`\n  %s",
                                            displayName.c_str(), tag.c_str(),
                                            module->second));
         manPagesFile_->writeLine(formatString(":manpage:`%s(1)`\n  %s",
@@ -651,14 +651,9 @@ void HelpExportReStructuredText::finishModuleGroupExport()
 
 void HelpExportReStructuredText::exportTopic(const HelpTopicInterface &topic)
 {
-    const std::string path("programs/" + std::string(topic.name()) + ".rst");
+    const std::string path("onlinehelp/" + std::string(topic.name()) + ".rst");
     File              file(outputRedirector_->openFileForWriting(path));
     HelpWriterContext context(&file, eHelpOutputFormat_Rst, &links_);
-    if (topic.name() == binaryName_)
-    {
-        context.writeTextBlock(":orphan:");
-        context.writeTextBlock("");
-    }
     HelpManager       manager(topic, context);
     manager.writeCurrentTopic();
 }
index dbb0ffa7ca43995fbc279ca7ffe0e18fa83157c5..2f4103fdcc162471a6d19b6cbd1bf87352cfdcf3 100644 (file)
@@ -1,12 +1,11 @@
 <?xml version="1.0"?>
 <?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
 <ReferenceData>
-  <String Name="programs/byname.rst"><![CDATA[
-Tools by Name
-=============
-* :doc:`test help <test-help>` - Print help information
-* :doc:`test module <test-module>` - First module
-* :doc:`test other <test-other>` - Second module
+  <String Name="fragments/byname.rst"><![CDATA[
+* :doc:`test </onlinehelp/test>` - molecular dynamics simulation suite
+* :doc:`test help </onlinehelp/test-help>` - Print help information
+* :doc:`test module </onlinehelp/test-module>` - First module
+* :doc:`test other </onlinehelp/test-other>` - Second module
 ]]></String>
   <String Name="conf-man.py"><![CDATA[
 man_pages = [
@@ -16,7 +15,7 @@ man_pages = [
     ('programs/test', 'test', 'molecular dynamics simulation suite', '', 1)
 ]
 ]]></String>
-  <String Name="programs/test-help.rst"><![CDATA[
+  <String Name="onlinehelp/test-help.rst"><![CDATA[
 .. _test help:
 
 test help
@@ -31,7 +30,7 @@ test help
 
    More information about |Gromacs| is available at <http://www.gromacs.org/>.
 ]]></String>
-  <String Name="programs/test-module.rst"><![CDATA[
+  <String Name="onlinehelp/test-module.rst"><![CDATA[
 .. _test module:
 
 test module
@@ -64,7 +63,7 @@ Other options:
 
    More information about |Gromacs| is available at <http://www.gromacs.org/>.
 ]]></String>
-  <String Name="programs/test-other.rst"><![CDATA[
+  <String Name="onlinehelp/test-other.rst"><![CDATA[
 .. _test other:
 
 test other
@@ -85,19 +84,19 @@ Synopsis
 
    More information about |Gromacs| is available at <http://www.gromacs.org/>.
 ]]></String>
-  <String Name="programs/bytopic.rst"><![CDATA[
-Tools by Topic
-==============
+  <String Name="fragments/bytopic.rst"><![CDATA[
 Group 1
--------
-| :doc:`test module <test-module>` - First module
+^^^^^^^
+:doc:`test module </onlinehelp/test-module>`
+  First module
 
 Group 2
--------
-| :doc:`test other <test-other>` - Second module
+^^^^^^^
+:doc:`test other </onlinehelp/test-other>`
+  Second module
 
 ]]></String>
-  <String Name="man/bytopic.rst"><![CDATA[
+  <String Name="fragments/bytopic-man.rst"><![CDATA[
 Group 1
 ^^^^^^^
 :manpage:`test-module(1)`
@@ -109,7 +108,7 @@ Group 2
   Second module
 
 ]]></String>
-  <String Name="programs/topic1.rst"><![CDATA[
+  <String Name="onlinehelp/topic1.rst"><![CDATA[
 Test topic
 ==========
 Help text
@@ -126,14 +125,12 @@ Out-of-order subtopic
 ---------------------
 Sub text
 ]]></String>
-  <String Name="programs/topic2.rst"><![CDATA[
+  <String Name="onlinehelp/topic2.rst"><![CDATA[
 Another topic
 =============
 Help text
 ]]></String>
-  <String Name="programs/test.rst"><![CDATA[
-:orphan:
-
+  <String Name="onlinehelp/test.rst"><![CDATA[
 molecular dynamics simulation suite
 ===================================
 Synopsis
@@ -173,6 +170,6 @@ test commands
 -------------
 The following commands are available. Please refer to their individual man pages or ``commandline-test help <command>`` for further details.
 
-.. include:: /man/bytopic.rst
+.. include:: /fragments/bytopic-man.rst
 ]]></String>
 </ReferenceData>