Fixed some mistakes in the docstrings.
This commit is contained in:
parent
0a4c217b3e
commit
9092a29338
2 changed files with 30 additions and 14 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
"""
|
"""
|
||||||
Inlinefunc
|
Inlinefunc
|
||||||
|
|
||||||
|
**Note: This module is deprecated. Use evennia.utils.nested_inlinefuncs instead.**
|
||||||
|
|
||||||
This is a simple inline text language for use to custom-format text in
|
This is a simple inline text language for use to custom-format text in
|
||||||
Evennia. It is applied BEFORE ANSI/MUX parsing is applied.
|
Evennia. It is applied BEFORE ANSI/MUX parsing is applied.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,27 @@ This parser accepts nested inlinefunctions on the form
|
||||||
```
|
```
|
||||||
$funcname{arg, arg, ...}
|
$funcname{arg, arg, ...}
|
||||||
```
|
```
|
||||||
where any arg can be another $funcname{} call.
|
|
||||||
|
embedded in any text where any arg can be another $funcname{} call.
|
||||||
|
This functionality is turned off by default - to activate,
|
||||||
|
`settings.INLINEFUNC_ENABLED` must be set to `True`.
|
||||||
|
|
||||||
Each token starts with "$funcname(" where there must be no space
|
Each token starts with "$funcname(" where there must be no space
|
||||||
between the $funcname and (. It ends with a matched ending parentesis.
|
between the $funcname and (. It ends with a matched ending parentesis.
|
||||||
")".
|
")".
|
||||||
|
|
||||||
Inside the inlinefunc definition, one can use `\` to escape. Enclosing
|
Inside the inlinefunc definition, one can use `\` to escape. This is
|
||||||
text in `"` or `'` will also escape them - use this to include the
|
mainly needed for escaping commas in flowing text (which would
|
||||||
right parenthesis or commas in the argument, for example.
|
otherwise be interpreted as an argument separator), or to escape `}`
|
||||||
|
when not intended to close the function block. Enclosing text in
|
||||||
|
matched `\"\"\"` (triple quotes) or `'''` (triple single-quotes) will
|
||||||
|
also escape *everything* within without needing to escape individual
|
||||||
|
characters.
|
||||||
|
|
||||||
The inlinefuncs, defined as global-level functions in modules defined
|
The available inlinefuncs are defined as global-level functions in
|
||||||
by `settings.INLINEFUNC_MODULES`. They are identified by their
|
modules defined by `settings.INLINEFUNC_MODULES`. They are identified
|
||||||
function name (and ignored if this name starts with `_`. They should
|
by their function name (and ignored if this name starts with `_`). They
|
||||||
be on the following form:
|
should be on the following form:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def funcname (*args, **kwargs):
|
def funcname (*args, **kwargs):
|
||||||
|
|
@ -27,23 +34,30 @@ def funcname (*args, **kwargs):
|
||||||
```
|
```
|
||||||
|
|
||||||
Here, the arguments given to `$funcname(arg1,arg2)` will appear as the
|
Here, the arguments given to `$funcname(arg1,arg2)` will appear as the
|
||||||
`*args` tuple. The `**kwargs` is used only by Evennia to make details
|
`*args` tuple. This will be populated by the arguments given to the
|
||||||
about the caller available to the function. The kwarg passed to all
|
inlinefunc in-game - the only part that will be available from
|
||||||
functions is `session`, the Sessionobject for the object seeing the
|
in-game. `**kwargs` are not supported from in-game but are only used
|
||||||
string. This may be `None` if the string is sent to a non-puppetable
|
internally by Evennia to make details about the caller available to
|
||||||
object.
|
the function. The kwarg passed to all functions is `session`, the
|
||||||
|
Sessionobject for the object seeing the string. This may be `None` if
|
||||||
|
the string is sent to a non-puppetable object. The inlinefunc should
|
||||||
|
never raise an exception.
|
||||||
|
|
||||||
There are two reserved function names:
|
There are two reserved function names:
|
||||||
- "nomatch": This is called if the user uses a functionname that is
|
- "nomatch": This is called if the user uses a functionname that is
|
||||||
not registered. The nomatch function will get the name of the
|
not registered. The nomatch function will get the name of the
|
||||||
not-found function as its first argument followed by the normal
|
not-found function as its first argument followed by the normal
|
||||||
arguments to the given function. If not defined the default effect is
|
arguments to the given function. If not defined the default effect is
|
||||||
to print `<UNKNOWN: funcname(args)>` to replace the unknown function.
|
to print `<UNKNOWN>` to replace the unknown function.
|
||||||
- "stackfull": This is called when the maximum nested function stack is reached.
|
- "stackfull": This is called when the maximum nested function stack is reached.
|
||||||
When this happens, the original parsed string is returned and the result of
|
When this happens, the original parsed string is returned and the result of
|
||||||
the `stackfull` inlinefunc is appended to the end. By default this is an
|
the `stackfull` inlinefunc is appended to the end. By default this is an
|
||||||
error message.
|
error message.
|
||||||
|
|
||||||
|
Error handling:
|
||||||
|
Syntax errors, notably not completely closing all inlinefunc
|
||||||
|
blocks, will lead to the entire string remaining unparsed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue