bLiteral = true;
if (paragraph.length() == 2)
{
+ if (breakSize == 0)
+ {
+ nextBreakSize = 0;
+ }
continue;
}
if (paragraph[paragraph.length() - 3] == ' ')
testFormatting(text);
}
+TEST_F(HelpWriterContextTest, FormatsLiteralTextAtBeginning)
+{
+ const char *const text[] = {
+ "::",
+ "",
+ " literal block",
+ " another line",
+ "",
+ "Normal paragraph"
+ };
+ testFormatting(text);
+}
+
TEST_F(HelpWriterContextTest, FormatsBulletList)
{
const char *const text[] = {
--- /dev/null
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+ <String Name="Console"><![CDATA[
+ literal block
+ another line
+
+Normal paragraph]]></String>
+ <String Name="reStructuredText"><![CDATA[
+::
+
+ literal block
+ another line
+
+Normal paragraph]]></String>
+</ReferenceData>
#include "selhelp.h"
+#include <set>
#include <string>
#include <utility>
#include <vector>
#include "gromacs/onlinehelp/helpwritercontext.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/file.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/stringutil.h"
#include "selmethod.h"
}
virtual const char *title() const
{
- return NULL;
+ return method_.help.helpTitle;
}
protected:
void printKeywordList(const HelpWriterContext &context,
e_selvalue_t type, bool bModifiers) const;
+ /*! \brief
+ * Prints the detailed help for keywords for rst export.
+ */
+ void writeKeywordSubTopics(const HelpWriterContext &context) const;
+
MethodList methods_;
};
printKeywordList(context, POS_VALUE, true);
printKeywordList(context, NO_VALUE, true);
writeKeywordListEnd(context, NULL);
+
+ writeKeywordSubTopics(context);
}
void KeywordsHelpTopic::writeKeywordListStart(const HelpWriterContext &context,
for (iter = methods_.begin(); iter != methods_.end(); ++iter)
{
const gmx_ana_selmethod_t &method = *iter->second;
- bool bIsModifier = (method.flags & SMETH_MODIFIER) != 0;
+ const bool bIsModifier
+ = (method.flags & SMETH_MODIFIER) != 0;
if (method.type == type && bModifiers == bIsModifier)
{
- bool bHasHelp = (method.help.nlhelp > 0 && method.help.help != NULL);
- file.writeString(formatString(" %c ", bHasHelp ? '*' : ' '));
+ const bool bHasHelp = (method.help.nlhelp > 0 && method.help.help != NULL);
+ const bool bPrintStar
+ = bHasHelp && context.outputFormat() == eHelpOutputFormat_Console;
+ file.writeString(formatString(" %c ", bPrintStar ? '*' : ' '));
if (method.help.syntax != NULL)
{
file.writeLine(method.help.syntax);
}
}
+void KeywordsHelpTopic::writeKeywordSubTopics(const HelpWriterContext &context) const
+{
+ if (context.outputFormat() != eHelpOutputFormat_Rst)
+ {
+ return;
+ }
+ std::set<std::string> usedSymbols;
+ MethodList::const_iterator iter;
+ for (iter = methods_.begin(); iter != methods_.end(); ++iter)
+ {
+ const gmx_ana_selmethod_t &method = *iter->second;
+ const bool bHasHelp
+ = (method.help.nlhelp > 0 && method.help.help != NULL);
+ if (!bHasHelp || usedSymbols.count(iter->first) > 0)
+ {
+ continue;
+ }
+
+ std::string title;
+ if (method.help.helpTitle != NULL)
+ {
+ title = method.help.helpTitle;
+ title.append(" - ");
+ }
+ title.append(iter->first);
+ MethodList::const_iterator mergeIter = iter;
+ for (++mergeIter; mergeIter != methods_.end(); ++mergeIter)
+ {
+ if (mergeIter->second->help.help == method.help.help)
+ {
+ title.append(", ");
+ title.append(mergeIter->first);
+ usedSymbols.insert(mergeIter->first);
+ }
+ }
+
+ const HelpTopicInterface *subTopic = findSubTopic(iter->first.c_str());
+ GMX_RELEASE_ASSERT(subTopic != NULL, "Keyword subtopic no longer exists");
+ HelpWriterContext subContext(context);
+ subContext.enterSubSection(title);
+ subTopic->writeHelp(subContext);
+ context.writeTextBlock("");
+ }
+}
+
} // namespace
//! \cond libapi */
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
&init_frame_example,
&evaluate_example,
NULL,
- {"example from POS_EXPR [cutoff REAL]", 0, NULL},
+ {"example from POS_EXPR [cutoff REAL]", NULL, 0, NULL},
};
* \endcode
*
* If NULL, the name of the method is used.
*/
const char *syntax;
+ /*! \brief
+ * Title for the help text in \p help.
+ *
+ * If NULL, the name of the method is used.
+ * Only used if `nlhelp > 0`.
+ */
+ const char *helpTitle;
/*! \brief
* Number of strings in \p help.
*
* If there is no help available in addition to \p syntax, this can be set
* to NULL.
*/
- const char **help;
+ const char *const *help;
};
/*! \internal
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
NULL,
&evaluate_compare,
NULL,
- {NULL, 0, NULL},
+ {NULL, NULL, 0, NULL},
};
/*! \brief
{"of", {POS_VALUE, -1, {NULL}}, NULL, SPAR_DYNAMIC | SPAR_VARNUM},
};
-/** Help text for the distance selection methods. */
-static const char *help_distance[] = {
- "DISTANCE-BASED SELECTION KEYWORDS",
- "",
+//! Help title for distance selection methods.
+static const char helptitle_distance[] = "Selecting based on distance";
+//! Help text for distance selection methods.
+static const char *const help_distance[] = {
"::",
"",
" distance from POS [cutoff REAL]",
&init_frame_common,
NULL,
&evaluate_distance,
- {"distance from POS [cutoff REAL]", asize(help_distance), help_distance},
+ {"distance from POS [cutoff REAL]",
+ helptitle_distance, asize(help_distance), help_distance},
};
/** Selection method data for the \p distance method. */
&init_frame_common,
NULL,
&evaluate_distance,
- {"mindistance from POS_EXPR [cutoff REAL]", asize(help_distance), help_distance},
+ {"mindistance from POS_EXPR [cutoff REAL]",
+ helptitle_distance, asize(help_distance), help_distance},
};
/** Selection method data for the \p within method. */
&init_frame_common,
NULL,
&evaluate_within,
- {"within REAL of POS_EXPR", asize(help_distance), help_distance},
+ {"within REAL of POS_EXPR",
+ helptitle_distance, asize(help_distance), help_distance},
};
static void *
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
};
/** Help text for the \p insolidangle selection method. */
-static const char *help_insolidangle[] = {
- "SELECTING ATOMS IN A SOLID ANGLE[PAR]",
-
- "[TT]insolidangle center POS span POS_EXPR [cutoff REAL][tt][PAR]",
-
+static const char *const help_insolidangle[] = {
+ "::",
+ "",
+ " insolidangle center POS span POS_EXPR [cutoff REAL]",
+ "",
"This keyword selects atoms that are within [TT]REAL[tt] degrees",
"(default=5) of any position in [TT]POS_EXPR[tt] as seen from [TT]POS[tt]",
"a position expression that evaluates to a single position), i.e., atoms",
NULL,
&evaluate_insolidangle,
{"insolidangle center POS span POS_EXPR [cutoff REAL]",
+ "Selecting atoms in a solid angle",
asize(help_insolidangle), help_insolidangle},
};
NULL,
&evaluate_keyword_int,
NULL,
- {NULL, 0, NULL},
+ {NULL, NULL, 0, NULL},
};
/** Selection method data for real keyword evaluation. */
NULL,
&evaluate_keyword_real,
NULL,
- {NULL, 0, NULL},
+ {NULL, NULL, 0, NULL},
};
/** Selection method data for string keyword evaluation. */
NULL,
&evaluate_keyword_str,
NULL,
- {NULL, 0, NULL},
+ {NULL, NULL, 0, NULL},
};
/*! \brief
{"stride", {INT_VALUE, 1, {NULL}}, NULL, SPAR_OPTIONAL},
};
-/** Help text for the merging selection modifiers. */
-static const char *help_merge[] = {
- "MERGING SELECTIONS[PAR]",
- "",
+//! Help title for the merging selection modifiers.
+static const char helptitle_merge[] = "Merging selections";
+//! Help text for the merging selection modifiers.
+static const char *const help_merge[] = {
"::",
"",
" POSEXPR merge POSEXPR [stride INT]",
NULL,
NULL,
&evaluate_merge,
- {"merge POSEXPR", asize(help_merge), help_merge},
+ {"merge POSEXPR", helptitle_merge, asize(help_merge), help_merge},
};
/** Selection method data for the \p plus modifier. */
NULL,
NULL,
&evaluate_plus,
- {"plus POSEXPR", asize(help_merge), help_merge},
+ {"plus POSEXPR", helptitle_merge, asize(help_merge), help_merge},
};
/*!
};
/** Help text for the \p permute selection modifier. */
-static const char *help_permute[] = {
- "PERMUTING SELECTIONS[PAR]",
-
- "[TT]permute P1 ... PN[tt][PAR]",
-
+static const char *const help_permute[] = {
+ "::",
+ "",
+ " permute P1 ... PN",
+ "",
"By default, all selections are evaluated such that the atom indices are",
"returned in ascending order. This can be changed by appending",
"[TT]permute P1 P2 ... PN[tt] to an expression.",
NULL,
NULL,
&evaluate_permute,
- {"permute P1 ... PN", asize(help_permute), help_permute},
+ {"POSEXPR permute P1 ... PN",
+ "Permuting selections", asize(help_permute), help_permute},
};
static void *
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
NULL,
&evaluate_pos,
NULL,
- {NULL, 0, NULL},
+ {NULL, NULL, 0, NULL},
};
/** Selection method data for the \p cog method. */
NULL,
&evaluate_pos,
NULL,
- {"cog of ATOM_EXPR [pbc]", 0, NULL},
+ {"cog of ATOM_EXPR [pbc]", NULL, 0, NULL},
};
/** Selection method data for the \p com method. */
NULL,
&evaluate_pos,
NULL,
- {"com of ATOM_EXPR [pbc]", 0, NULL},
+ {"com of ATOM_EXPR [pbc]", NULL, 0, NULL},
};
/*!
};
/** Help text for the \p same selection method. */
-static const char *help_same[] = {
- "EXTENDING SELECTIONS[PAR]",
-
- "[TT]same KEYWORD as ATOM_EXPR[tt][PAR]",
+static const char *const help_same[] = {
+ "::",
+ "",
+ " same KEYWORD as ATOM_EXPR",
+ "",
"The keyword [TT]same[tt] can be used to select all atoms for which",
"the given [TT]KEYWORD[tt] matches any of the atoms in [TT]ATOM_EXPR[tt].",
&init_frame_same_int,
&evaluate_same_int,
NULL,
- {"same KEYWORD as ATOM_EXPR", asize(help_same), help_same},
+ {"same KEYWORD as ATOM_EXPR",
+ "Extending selections", asize(help_same), help_same},
};
/*! \brief
&init_frame_same_str,
&evaluate_same_str,
NULL,
- {"same KEYWORD as ATOM_EXPR", asize(help_same), help_same},
+ {NULL, NULL, 0, NULL},
};
static void *
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
evaluate_z(t_topology *top, t_trxframe *fr, t_pbc *pbc,
gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data);
-/** Help text for atom name selection keywords. */
-static const char *help_atomname[] = {
- "ATOM NAME SELECTION KEYWORDS[PAR]",
-
- "[TT]name[tt] [TT]pdbname[tt] [TT]atomname[tt] [TT]pdbatomname[tt][PAR]",
-
+//! Help title for atom name selection keywords.
+static const char helptitle_atomname[] = "Selecting atoms by name";
+//! Help text for atom name selection keywords.
+static const char *const help_atomname[] = {
+ "::",
+ "",
+ " name",
+ " pdbname",
+ " atomname",
+ " pdbatomname",
+ "",
"These keywords select atoms by name. [TT]name[tt] selects atoms using",
- "the Gromacs atom naming convention.",
+ "the GROMACS atom naming convention.",
"For input formats other than PDB, the atom names are matched exactly",
"as they appear in the input file. For PDB files, 4 character atom names",
"that start with a digit are matched after moving the digit to the end",
NULL,
&evaluate_atomname,
NULL,
- {NULL, asize(help_atomname), help_atomname}
+ {NULL, helptitle_atomname, asize(help_atomname), help_atomname}
};
/** Selection method data for \p pdbatomname selection keyword. */
NULL,
&evaluate_pdbatomname,
NULL,
- {NULL, asize(help_atomname), help_atomname}
+ {NULL, helptitle_atomname, asize(help_atomname), help_atomname}
};
/** Selection method data for \p atomtype selection keyword. */