More docstring

8 more files docstringed. A bit from everywere...
This commit is contained in:
tajmone 2015-03-09 18:34:56 +01:00 committed by Griatch
parent 5256f4b7ad
commit a25ead9626
8 changed files with 154 additions and 145 deletions

View file

@ -13,9 +13,9 @@ class Command(BaseCommand):
"""
Inherit from this if you want to create your own
command styles. Note that Evennia's default commands
use MuxCommand instead (next in this module)
use MuxCommand instead (next in this module).
Note that the class's __doc__ string (this text) is
Note that the class's `__doc__` string (this text) is
used by Evennia to create the automatic help entry for
the command, so make sure to document consistently here.
@ -38,15 +38,15 @@ class Command(BaseCommand):
def at_pre_cmd(self):
"""
This hook is called before self.parse() on all commands
This hook is called before `self.parse()` on all commands.
"""
pass
def parse(self):
"""
This method is called by the cmdhandler once the command name
This method is called by the `cmdhandler` once the command name
has been identified. It creates a new set of member variables
that can be later accessed from self.func() (see below)
that can be later accessed from `self.func()` (see below).
The following variables are available to us:
# class variables:
@ -56,72 +56,72 @@ class Command(BaseCommand):
self.locks - lock string for this command ("cmd:all()")
self.help_category - overall category of command ("General")
# added at run-time by cmdhandler:
# added at run-time by `cmdhandler`:
self.caller - the object calling this command
self.cmdstring - the actual command name used to call this
(this allows you to know which alias was used,
for example)
self.args - the raw input; everything following self.cmdstring.
self.cmdset - the cmdset from which this command was picked. Not
often used (useful for commands like 'help' or to
list all available commands etc)
self.args - the raw input; everything following `self.cmdstring`.
self.cmdset - the `cmdset` from which this command was picked. Not
often used (useful for commands like `help` or to
list all available commands etc).
self.obj - the object on which this command was defined. It is often
the same as self.caller.
the same as `self.caller`.
"""
pass
def func(self):
"""
This is the hook function that actually does all the work. It is called
by the cmdhandler right after self.parser() finishes, and so has access
to all the variables defined therein.
by the `cmdhandler` right after `self.parser()` finishes, and so has access
to all the variables defined therein.
"""
self.caller.msg("Command called!")
def at_post_cmd(self):
"""
This hook is called after self.func().
This hook is called after `self.func()`.
"""
pass
class MuxCommand(default_cmds.MuxCommand):
"""
This sets up the basis for a Evennia's 'MUX-like' command
style. The idea is that most other Mux-related commands should
This sets up the basis for Evennia's 'MUX-like' command style.
The idea is that most other Mux-related commands should
just inherit from this and don't have to implement parsing of
their own unless they do something particularly advanced.
A MUXCommand command understands the following possible syntax:
name[ with several words][/switch[/switch..]] arg1[,arg2,...] [[=|,] arg[,..]]
name[ with several words][/switch[/switch..]] arg1[,arg2,...] [[=|,] arg[,..]]
The 'name[ with several words]' part is already dealt with by the
cmdhandler at this point, and stored in self.cmdname. The rest is stored
in self.args.
The `name[ with several words]` part is already dealt with by the
`cmdhandler` at this point, and stored in `self.cmdname`. The rest is stored
in `self.args`.
The MuxCommand parser breaks self.args into its constituents and stores them
The MuxCommand parser breaks `self.args` into its constituents and stores them
in the following variables:
self.switches = optional list of /switches (without the /)
self.raw = This is the raw argument input, including switches
self.args = This is re-defined to be everything *except* the switches
self.lhs = Everything to the left of = (lhs:'left-hand side'). If
no = is found, this is identical to self.args.
self.rhs: Everything to the right of = (rhs:'right-hand side').
If no '=' is found, this is None.
self.lhslist - self.lhs split into a list by comma
self.rhslist - list of self.rhs split into a list by comma
self.arglist = list of space-separated args (including '=' if it exists)
self.switches = optional list of /switches (without the /).
self.raw = This is the raw argument input, including switches.
self.args = This is re-defined to be everything *except* the switches.
self.lhs = Everything to the left of `=` (lhs:'left-hand side'). If
no `=` is found, this is identical to `self.args`.
self.rhs: Everything to the right of `=` (rhs:'right-hand side').
If no `=` is found, this is `None`.
self.lhslist - `self.lhs` split into a list by comma.
self.rhslist - list of `self.rhs` split into a list by comma.
self.arglist = list of space-separated args (including `=` if it exists).
All args and list members are stripped of excess whitespace around the
strings, but case is preserved.
"""
All args and list members are stripped of excess whitespace around the
strings, but case is preserved.
"""
def func(self):
"""
This is the hook function that actually does all the work. It is called
by the cmdhandler right after self.parser() finishes, and so has access
by the `cmdhandler` right after `self.parser()` finishes, and so has access
to all the variables defined therein.
"""
# this can be removed in your child class, it's just

View file

@ -6,11 +6,11 @@ can be part of any number of cmdsets and cmdsets can be added/removed
and merged onto entities at runtime.
To create new commands to populate the cmdset, see
commands/command.py.
`commands/command.py`.
This module wrap the default command sets of Evennia; overload them
This module wraps the default command sets of Evennia; overloads them
to add/remove commands from the default lineup. You can create your
own cmdsets by inheriting from them or directly from evennia.CmdSet.
own cmdsets by inheriting from them or directly from `evennia.CmdSet`.
"""
@ -18,9 +18,9 @@ from evennia import default_cmds
class CharacterCmdSet(default_cmds.CharacterCmdSet):
"""
The CharacterCmdSet contains general in-game commands like look,
get etc available on in-game Character objects. It is merged with
the PlayerCmdSet when a Player puppets a Character.
The `CharacterCmdSet` contains general in-game commands like `look`,
`get`, etc available on in-game Character objects. It is merged with
the `PlayerCmdSet` when a Player puppets a Character.
"""
key = "DefaultCharacter"
@ -37,9 +37,9 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
class PlayerCmdSet(default_cmds.PlayerCmdSet):
"""
This is the cmdset available to the Player at all times. It is
combined with the CharacterCmdSet when the Player puppets a
combined with the `CharacterCmdSet` when the Player puppets a
Character. It holds game-account-specific commands, channel
commands etc.
commands, etc.
"""
key = "DefaultPlayer"
@ -56,7 +56,7 @@ class PlayerCmdSet(default_cmds.PlayerCmdSet):
class UnloggedinCmdSet(default_cmds.UnloggedinCmdSet):
"""
Command set available to the Session before being logged in. This
holds commands like creating a new account, logging in etc.
holds commands like creating a new account, logging in, etc.
"""
key = "DefaultUnloggedin"
@ -82,7 +82,7 @@ class SessionCmdSet(default_cmds.SessionCmdSet):
This is the only method defined in a cmdset, called during
its creation. It should populate the set with command instances.
As and example we just add the empty base Command object.
As and example we just add the empty base `Command` object.
It prints some info.
"""
super(SessionCmdSet, self).at_cmdset_creation()

View file

@ -11,24 +11,24 @@ from evennia import DefaultExit
class Exit(DefaultExit):
"""
Exits are connectors between rooms. Exits are normal Objects except
they defines the 'destination' property. It also does work in the
they defines the `destination` property. It also does work in the
following methods:
basetype_setup() - sets default exit locks (to change, use at_object_creation instead)
basetype_setup() - sets default exit locks (to change, use `at_object_creation` instead).
at_cmdset_get(**kwargs) - this is called when the cmdset is accessed and should
rebuild the Exit cmdset along with a command matching the name
of the Exit object. Conventionally, a kwarg 'force_init'
of the Exit object. Conventionally, a kwarg `force_init`
should force a rebuild of the cmdset, this is triggered
by the @alias command when aliases are changed.
by the `@alias` command when aliases are changed.
at_failed_traverse() - gives a default error message ("You cannot
go there") if exit traversal fails and an
attribute err_traverse is not defined.
attribute `err_traverse` is not defined.
Relevant hooks to overload (compared to other types of Objects):
at_before_traverse(traveller) - called just before traversing
at_after_traverse(traveller, source_loc) - called just after traversing
at_failed_traverse(traveller) - called if traversal failed for some reason. Will
not be called if the attribute 'err_traverse' is
defined, in which case that will simply be echoed.
at_before_traverse(traveller) - called just before traversing.
at_after_traverse(traveller, source_loc) - called just after traversing.
at_failed_traverse(traveller) - called if traversal failed for some reason. Will
not be called if the attribute `err_traverse` is
defined, in which case that will simply be echoed.
"""
pass

View file

@ -14,13 +14,13 @@
# - every command must be separated by at least one line of comment.
#
# All supplied commands are given as normal, on their own line
# and accepts arguments in any format up until the first next
# comment line begins. Extra whitespace is removed; an empty
# and accept arguments in any format up until the first next
# comment line begins. Extra whitespace is removed; an empty
# line in a command definition translates into a newline.
#
# See evennia/contrib/tutorial_examples/batch_cmds.ev for
# See `evennia/contrib/tutorial_examples/batch_cmds.ev` for
# an example of a batch-command code. See also the batch-code
# system for loading python-code in this way.
# system for loading python-code this way.
#

View file

@ -2,7 +2,7 @@
Prototypes
A prototype is a simple way to create individualized instances of a
given Typeclass. For example, you might have a Sword typeclass that
given `Typeclass`. For example, you might have a Sword typeclass that
implements everything a Sword would need to do. The only difference
between different individual Swords would be their key, description
and some Attributes. The Prototype system allows to create a range of
@ -12,27 +12,27 @@ Sabres and all Broadswords some common properties). Note that bigger
variations, such as custom commands or functionality belong in a
hierarchy of typeclasses instead.
Example prototypes are read by the @spawn command but is also easily
available to use from code via evennia.spawn or evennia.utils.spawner.
Example prototypes are read by the `@spawn` command but is also easily
available to use from code via `evennia.spawn` or `evennia.utils.spawner`.
Each prototype should be a dictionary. Use the same name as the
variable to refer to other prototypes.
Possible keywords are:
prototype - string pointing to parent prototype of this structure
key - string, the main object identifier
typeclass - string, if not set, will use settings.BASE_OBJECT_TYPECLASS
location - this should be a valid object or #dbref
home - valid object or #dbref
destination - only valid for exits (object or dbref)
prototype - string pointing to parent prototype of this structure.
key - string, the main object identifier.
typeclass - string, if not set, will use `settings.BASE_OBJECT_TYPECLASS`.
location - this should be a valid object or #dbref.
home - valid object or #dbref.
destination - only valid for exits (object or dbref).
permissions - string or list of permission strings
locks - a lock-string
aliases - string or list of strings
permissions - string or list of permission strings.
locks - a lock-string.
aliases - string or list of strings.
ndb_<name> - value of a nattribute (the "ndb_" part is ignored)
ndb_<name> - value of a nattribute (the "ndb_" part is ignored).
any other keywords are interpreted as Attributes and their values.
See the @spawn command and evennia.utils.spawner for more info.
See the `@spawn` command and `evennia.utils.spawner` for more info.
"""