<spanid="evennia-help-utils"></span><h1>evennia.help.utils<aclass="headerlink"href="#module-evennia.help.utils"title="Permalink to this headline">¶</a></h1>
<p>Resources for indexing help entries and for splitting help entries into
sub-categories.</p>
<p>This is used primarily by the default <strong>help</strong> command.</p>
<codeclass="sig-prename descclassname">evennia.help.utils.</code><codeclass="sig-name descname">help_search_with_index</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">query</span></em>, <emclass="sig-param"><spanclass="n">candidate_entries</span></em>, <emclass="sig-param"><spanclass="n">suggestion_maxnum</span><spanclass="o">=</span><spanclass="default_value">5</span></em>, <emclass="sig-param"><spanclass="n">fields</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/help/utils.html#help_search_with_index"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.help.utils.help_search_with_index"title="Permalink to this definition">¶</a></dt>
<dd><p>Lunr-powered fast index search and suggestion wrapper. See <aclass="reference external"href="https://lunrjs.com/">https://lunrjs.com/</a>.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>query</strong> (<em>str</em>) – The query to search for.</p></li>
<li><p><strong>candidate_entries</strong> (<em>list</em>) – This is the body of possible entities to search. Each
must have a property <strong>.search_index_entry</strong> that returns a dict with all
keys in the <strong>fields</strong> arg.</p></li>
<li><p><strong>suggestion_maxnum</strong> (<em>int</em>) – How many matches to allow at most in a multi-match.</p></li>
<li><p><strong>fields</strong> (<em>list</em><em>, </em><em>optional</em>) – A list of Lunr field mappings
<strong>**{“field_name”: str, “boost”: int}**</strong>. See the Lunr documentation
for more details. The field name must exist in the dicts returned
by <strong>.search_index_entry</strong> of the candidates. If not given, a default setup
is used, prefering keys > aliases > category > tags.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>tuple</em>–</p>
<dlclass="simple">
<dt>A tuple (matches, suggestions), each a list, where the <strong>suggestion_maxnum</strong> limits</dt><dd><p>how many suggestions are included.</p>
<codeclass="sig-prename descclassname">evennia.help.utils.</code><codeclass="sig-name descname">parse_entry_for_subcategories</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">entry</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/help/utils.html#parse_entry_for_subcategories"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.help.utils.parse_entry_for_subcategories"title="Permalink to this definition">¶</a></dt>
<dd><p>Parse a command docstring for special sub-category blocks:</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>entry</strong> (<em>str</em>) – A help entry to parse</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>dict</em>–</p>
<dlclass="simple">
<dt>The dict is a mapping that splits the entry into subcategories. This</dt><dd><p>will always hold a key <strong>None</strong> for the main help entry and
zero or more keys holding the subcategories. Each is itself
a dict with a key <strong>None</strong> for the main text of that subcategory
followed by any sub-sub-categories down to a max-depth of 5.</p>