mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 13:56:30 +01:00
251 lines
No EOL
12 KiB
HTML
251 lines
No EOL
12 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>evennia.help.utils — Evennia latest documentation</title>
|
||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="evennia.locks" href="evennia.locks.html" />
|
||
<link rel="prev" title="evennia.help.models" href="evennia.help.models.html" />
|
||
</head><body>
|
||
|
||
|
||
<div class="admonition important">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">You are reading an old version of the Evennia documentation. <a href="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
|
||
</div>
|
||
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.locks.html" title="evennia.locks"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.help.models.html" title="evennia.help.models"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.help.html" accesskey="U">evennia.help</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.help.utils</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
|
||
<div class="documentwrapper">
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||
</a></p>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.help.models.html"
|
||
title="previous chapter">evennia.help.models</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.locks.html"
|
||
title="next chapter">evennia.locks</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.help.utils.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.help.utils">
|
||
<span id="evennia-help-utils"></span><h1>evennia.help.utils<a class="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>
|
||
<dl class="py function">
|
||
<dt id="evennia.help.utils.help_search_with_index">
|
||
<code class="sig-prename descclassname">evennia.help.utils.</code><code class="sig-name descname">help_search_with_index</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">query</span></em>, <em class="sig-param"><span class="n">candidate_entries</span></em>, <em class="sig-param"><span class="n">suggestion_maxnum</span><span class="o">=</span><span class="default_value">5</span></em>, <em class="sig-param"><span class="n">fields</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/help/utils.html#help_search_with_index"><span class="viewcode-link">[source]</span></a><a class="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 <a class="reference external" href="https://lunrjs.com/">https://lunrjs.com/</a>.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="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>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><p><em>tuple</em> –</p>
|
||
<dl class="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>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="evennia.help.utils.parse_entry_for_subcategories">
|
||
<code class="sig-prename descclassname">evennia.help.utils.</code><code class="sig-name descname">parse_entry_for_subcategories</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">entry</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/help/utils.html#parse_entry_for_subcategories"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>entry</strong> (<em>str</em>) – A help entry to parse</p>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><p><em>dict</em> –</p>
|
||
<dl class="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>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
<p>Example:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="sd">'''</span>
|
||
<span class="sd">Main topic text</span>
|
||
|
||
<span class="sd"># SUBTOPICS</span>
|
||
|
||
<span class="sd">## foo</span>
|
||
|
||
<span class="sd">A subcategory of the main entry, accessible as **help topic foo**</span>
|
||
<span class="sd">(or using /, like **help topic/foo**)</span>
|
||
|
||
<span class="sd">## bar</span>
|
||
|
||
<span class="sd">Another subcategory, accessed as **help topic bar**</span>
|
||
<span class="sd">(or **help topic/bar**)</span>
|
||
|
||
<span class="sd">### moo</span>
|
||
|
||
<span class="sd">A subcategory of bar, accessed as **help bar moo**</span>
|
||
<span class="sd">(or **help bar/moo**)</span>
|
||
|
||
<span class="sd">#### dum</span>
|
||
|
||
<span class="sd">A subcategory of moo, accessed **help bar moo dum**</span>
|
||
<span class="sd">(or **help bar/moo/dum**)</span>
|
||
|
||
<span class="sd">'''</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This will result in this returned entry structure:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
|
||
<span class="kc">None</span><span class="p">:</span> <span class="s2">"Main topic text"</span><span class="p">:</span>
|
||
<span class="s2">"foo"</span><span class="p">:</span> <span class="p">{</span>
|
||
<span class="kc">None</span><span class="p">:</span> <span class="s2">"main topic/foo text"</span>
|
||
<span class="p">},</span>
|
||
<span class="s2">"bar"</span><span class="p">:</span> <span class="p">{</span>
|
||
<span class="kc">None</span><span class="p">:</span> <span class="s2">"Main topic/bar text"</span><span class="p">,</span>
|
||
<span class="s2">"moo"</span><span class="p">:</span> <span class="p">{</span>
|
||
<span class="kc">None</span><span class="p">:</span> <span class="s2">"topic/bar/moo text"</span>
|
||
<span class="s2">"dum"</span><span class="p">:</span> <span class="p">{</span>
|
||
<span class="kc">None</span><span class="p">:</span> <span class="s2">"topic/bar/moo/dum text"</span>
|
||
<span class="p">}</span>
|
||
<span class="p">}</span>
|
||
<span class="p">}</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.locks.html" title="evennia.locks"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.help.models.html" title="evennia.help.models"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.help.html" >evennia.help</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.help.utils</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
<div class="admonition important">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">You are reading an old version of the Evennia documentation. <a href="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
|
||
</div>
|
||
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2023, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |