2023-12-20 18:49:25 +01:00
<!DOCTYPE html>
2025-08-15 16:53:30 +00:00
< html lang = "en" data-content_root = "../" >
2023-12-20 18:49:25 +01:00
< head >
< meta charset = "utf-8" / >
2025-08-15 16:53:30 +00:00
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / > < meta name = "viewport" content = "width=device-width, initial-scale=1" / >
2023-12-20 18:49:25 +01:00
< title > evennia.help.utils — Evennia latest documentation< / title >
2025-08-15 16:53:30 +00:00
< link rel = "stylesheet" type = "text/css" href = "../_static/pygments.css?v=d75fae25" / >
< link rel = "stylesheet" type = "text/css" href = "../_static/nature.css?v=279e0f84" / >
< link rel = "stylesheet" type = "text/css" href = "../_static/custom.css?v=e4a91a55" / >
< script src = "../_static/documentation_options.js?v=c6e86fd7" > < / script >
< script src = "../_static/doctools.js?v=9bcbadda" > < / script >
< script src = "../_static/sphinx_highlight.js?v=dc90522c" > < / script >
< link rel = "icon" href = "../_static/favicon.ico" / >
2023-12-20 18:49:25 +01:00
< 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 >
2025-08-15 16:53:30 +00:00
< div class = "related" role = "navigation" aria-label = "Related" >
2023-12-20 18:49:25 +01:00
< 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 >
2025-08-15 16:53:30 +00:00
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Evennia< / a > » < / li >
2023-12-20 18:49:25 +01:00
< 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 = "bodywrapper" >
< div class = "body" role = "main" >
< section id = "module-evennia.help.utils" >
2025-08-15 16:53:30 +00:00
< span id = "evennia-help-utils" > < / span > < h1 > evennia.help.utils< a class = "headerlink" href = "#module-evennia.help.utils" title = "Link to this heading" > ¶< / a > < / h1 >
2023-12-20 18:49:25 +01:00
< 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 >
2024-12-15 14:59:59 +00:00
< dl class = "py function" >
2025-08-15 16:53:30 +00:00
< dt class = "sig sig-object py" id = "evennia.help.utils.wildcard_stemmer" >
< span class = "sig-prename descclassname" > < span class = "pre" > evennia.help.utils.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > wildcard_stemmer< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > token< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > i< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > tokens< / span > < / span > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../_modules/evennia/help/utils.html#wildcard_stemmer" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#evennia.help.utils.wildcard_stemmer" title = "Link to this definition" > ¶< / a > < / dt >
2024-12-15 14:59:59 +00:00
< dd > < p > Custom LUNR stemmer that returns both the original and stemmed token
if the token contains a leading wildcard (*).< / p >
< dl class = "field-list simple" >
2025-08-15 16:53:30 +00:00
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
2024-12-15 14:59:59 +00:00
< dd class = "field-odd" > < ul class = "simple" >
< li > < p > < strong > token< / strong > (< em > str< / em > ) – The input token to be stemmed< / p > < / li >
< li > < p > < strong > i< / strong > (< em > int< / em > ) – Index of current token. Unused here but required by LUNR.< / p > < / li >
< li > < p > < strong > tokens< / strong > (< em > list< / em > ) – List of tokens being processed. Unused here but required by LUNR.< / p > < / li >
< / ul >
< / dd >
2025-08-15 16:53:30 +00:00
< dt class = "field-even" > Returns< span class = "colon" > :< / span > < / dt >
2024-12-15 14:59:59 +00:00
< dd class = "field-even" > < p > < em > list< / em > – A list containing the stemmed tokens and original token if it has leading ‘ *’ .< / p >
< / dd >
< / dl >
< / dd > < / dl >
< dl class = "py class" >
2025-08-15 16:53:30 +00:00
< dt class = "sig sig-object py" id = "evennia.help.utils.LunrSearch" >
< em class = "property" > < span class = "k" > < span class = "pre" > class< / span > < / span > < span class = "w" > < / span > < / em > < span class = "sig-prename descclassname" > < span class = "pre" > evennia.help.utils.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > LunrSearch< / span > < / span > < a class = "reference internal" href = "../_modules/evennia/help/utils.html#LunrSearch" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#evennia.help.utils.LunrSearch" title = "Link to this definition" > ¶< / a > < / dt >
2024-12-15 14:59:59 +00:00
< dd > < p > Bases: < code class = "xref py py-class docutils literal notranslate" > < span class = "pre" > object< / span > < / code > < / p >
< p > Singleton class for managing Lunr search index configuration and initialization.< / p >
< dl class = "py method" >
2025-08-15 16:53:30 +00:00
< dt class = "sig sig-object py" id = "evennia.help.utils.LunrSearch.index" >
< span class = "sig-name descname" > < span class = "pre" > index< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > ref< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > fields< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > documents< / span > < / span > < / em > < span class = "sig-paren" > )< / span > < a class = "reference internal" href = "../_modules/evennia/help/utils.html#LunrSearch.index" > < span class = "viewcode-link" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#evennia.help.utils.LunrSearch.index" title = "Link to this definition" > ¶< / a > < / dt >
2024-12-15 14:59:59 +00:00
< dd > < p > Creates a Lunr searchable index.< / p >
< dl class = "field-list simple" >
2025-08-15 16:53:30 +00:00
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
2024-12-15 14:59:59 +00:00
< dd class = "field-odd" > < ul class = "simple" >
< li > < p > < strong > ref< / strong > (< em > str< / em > ) – Unique identifier field within a document< / p > < / li >
< li > < p > < strong > fields< / strong > (< em > list< / em > ) – A list of Lunr field mappings
< strong > **{“field_name”: str, “boost”: int}**< / strong > . See the Lunr documentation
for more details.< / p > < / li >
< li > < p > < strong > documents< / strong > (< em > list< / em > < em > [< / em > < em > dict< / em > < em > ]< / em > ) – This is the body of possible entities to search.
Each dict should have all keys in the < strong > fields< / strong > arg.< / p > < / li >
< / ul >
< / dd >
< / dl >
< p > Returns: A lunr.Index object< / p >
< / dd > < / dl >
< / dd > < / dl >
2023-12-20 18:49:25 +01:00
< dl class = "py function" >
2025-08-15 16:53:30 +00:00
< dt class = "sig sig-object py" id = "evennia.help.utils.help_search_with_index" >
< span class = "sig-prename descclassname" > < span class = "pre" > evennia.help.utils.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > help_search_with_index< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > query< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > candidate_entries< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > suggestion_maxnum< / span > < / span > < span class = "o" > < span class = "pre" > =< / span > < / span > < span class = "default_value" > < span class = "pre" > 5< / span > < / span > < / em > , < em class = "sig-param" > < span class = "n" > < span class = "pre" > fields< / span > < / span > < span class = "o" > < span class = "pre" > =< / span > < / span > < span class = "default_value" > < span class = "pre" > None< / span > < / 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" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#evennia.help.utils.help_search_with_index" title = "Link to this definition" > ¶< / a > < / dt >
2023-12-20 18:49:25 +01:00
< 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" >
2025-08-15 16:53:30 +00:00
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
2023-12-20 18:49:25 +01:00
< 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 >
2025-08-15 16:53:30 +00:00
< dt class = "field-even" > Returns< span class = "colon" > :< / span > < / dt >
2023-12-20 18:49:25 +01:00
< 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" >
2025-08-15 16:53:30 +00:00
< dt class = "sig sig-object py" id = "evennia.help.utils.parse_entry_for_subcategories" >
< span class = "sig-prename descclassname" > < span class = "pre" > evennia.help.utils.< / span > < / span > < span class = "sig-name descname" > < span class = "pre" > parse_entry_for_subcategories< / span > < / span > < span class = "sig-paren" > (< / span > < em class = "sig-param" > < span class = "n" > < span class = "pre" > entry< / span > < / 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" > < span class = "pre" > [source]< / span > < / span > < / a > < a class = "headerlink" href = "#evennia.help.utils.parse_entry_for_subcategories" title = "Link to this definition" > ¶< / a > < / dt >
2023-12-20 18:49:25 +01:00
< dd > < p > Parse a command docstring for special sub-category blocks:< / p >
< dl class = "field-list simple" >
2025-08-15 16:53:30 +00:00
< dt class = "field-odd" > Parameters< span class = "colon" > :< / span > < / dt >
2023-12-20 18:49:25 +01:00
< dd class = "field-odd" > < p > < strong > entry< / strong > (< em > str< / em > ) – A help entry to parse< / p >
< / dd >
2025-08-15 16:53:30 +00:00
< dt class = "field-even" > Returns< span class = "colon" > :< / span > < / dt >
2023-12-20 18:49:25 +01:00
< 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 >
2025-08-15 16:53:30 +00:00
< div class = "clearer" > < / div >
2023-12-20 18:49:25 +01:00
< / div >
< / div >
< / div >
2025-08-15 16:53:30 +00:00
< div class = "sphinxsidebar" role = "navigation" aria-label = "Main" >
< div class = "sphinxsidebarwrapper" >
< p class = "logo" > < a href = "../index.html" >
< img class = "logo" src = "../_static/evennia_logo.png" alt = "Logo of Evennia" / >
< / a > < / p >
< search 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" autocomplete = "off" autocorrect = "off" autocapitalize = "off" spellcheck = "false" / >
< input type = "submit" value = "Go" / >
< / form >
< / div >
< / search >
< script > document . getElementById ( 'searchbox' ) . style . display = "block" < / script >
< h3 > < a href = "../index.html" > Table of Contents< / a > < / h3 >
< ul >
< li > < a class = "reference internal" href = "#" > evennia.help.utils< / a > < ul >
< li > < a class = "reference internal" href = "#evennia.help.utils.wildcard_stemmer" > < code class = "docutils literal notranslate" > < span class = "pre" > wildcard_stemmer()< / span > < / code > < / a > < / li >
< li > < a class = "reference internal" href = "#evennia.help.utils.LunrSearch" > < code class = "docutils literal notranslate" > < span class = "pre" > LunrSearch< / span > < / code > < / a > < ul >
< li > < a class = "reference internal" href = "#evennia.help.utils.LunrSearch.index" > < code class = "docutils literal notranslate" > < span class = "pre" > LunrSearch.index()< / span > < / code > < / a > < / li >
< / ul >
< / li >
< li > < a class = "reference internal" href = "#evennia.help.utils.help_search_with_index" > < code class = "docutils literal notranslate" > < span class = "pre" > help_search_with_index()< / span > < / code > < / a > < / li >
< li > < a class = "reference internal" href = "#evennia.help.utils.parse_entry_for_subcategories" > < code class = "docutils literal notranslate" > < span class = "pre" > parse_entry_for_subcategories()< / span > < / code > < / a > < / li >
< / ul >
< / li >
< / ul >
2023-12-20 18:49:25 +01:00
2025-08-15 16:53:30 +00:00
< div >
< h4 > Previous topic< / h4 >
< p class = "topless" > < a href = "evennia.help.models.html"
title="previous chapter">evennia.help.models< / a > < / p >
< / div >
< div >
< h4 > Next topic< / h4 >
< p class = "topless" > < a href = "evennia.locks.html"
title="next chapter">evennia.locks< / a > < / p >
< / div >
< 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 >
< h3 > Doc Versions< / h3 >
< ul >
< li >
< a href = "https://www.evennia.com/docs/latest/index.html" > latest (main branch)< / a >
< / li >
< li >
< a href = "https://www.evennia.com/docs/5.x/index.html" > v5.0.0 branch (outdated)< / a >
< / li >
< li >
< a href = "https://www.evennia.com/docs/4.x/index.html" > v4.0.0 branch (outdated)< / a >
< / li >
< li >
< a href = "https://www.evennia.com/docs/3.x/index.html" > v3.0.0 branch (outdated)< / a >
< / li >
< li >
< a href = "https://www.evennia.com/docs/2.x/index.html" > v2.0.0 branch (outdated)< / a >
< / li >
< li >
< a href = "https://www.evennia.com/docs/1.x/index.html" > v1.0.0 branch (outdated)< / a >
< / li >
< li >
< a href = "https://www.evennia.com/docs/0.x/index.html" > v0.9.5 branch (outdated)< / a >
< / li >
< / ul >
< / div >
< / div >
< div class = "clearer" > < / div >
2023-12-20 18:49:25 +01:00
< / div >
2025-08-15 16:53:30 +00:00
< div class = "related" role = "navigation" aria-label = "Related" >
2023-12-20 18:49:25 +01:00
< 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 >
2025-08-15 16:53:30 +00:00
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Evennia< / a > » < / li >
2023-12-20 18:49:25 +01:00
< 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 = "footer" role = "contentinfo" >
2025-08-15 16:53:30 +00:00
© Copyright 2024, The Evennia developer community.
Created using < a href = "https://www.sphinx-doc.org/" > Sphinx< / a > 8.2.3.
2023-12-20 18:49:25 +01:00
< / div >
< / body >
< / html >