From 2b7e8c7a2f932d995d5c6c7d430a9f9165445088 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 25 Mar 2003 08:06:04 +0000 Subject: [PATCH] Some documenation updates --- docs/EXAMPLE | 5 ++--- docs/OVERVIEW | 5 ++--- docs/STYLE | 39 +++++++++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/docs/EXAMPLE b/docs/EXAMPLE index a766f40c9..9c0caeab3 100644 --- a/docs/EXAMPLE +++ b/docs/EXAMPLE @@ -15,9 +15,8 @@ class hierarchy. irclib.IrcCallback does a lot of the basic stuff that call- backs have to do, and inheriting from it relieves the programmer from such pedantries. All you have to do to start writing callbacks inheriting from irclib.IrcCallback is write functions of the form "doCommand", where "Command" -is a valid ircCommand. The "ChannelJoiner" function in the callbacks module -is a good illustrative example of a callback being called on different -commands. +is a valid ircCommand. The "ChannelLogger" plugin is a good illustrative +example of a callback being called on different commands. The "irc" argument there is the irc object that is calling the callback. To see what kind of interface it provides, read the class definition in irclib. diff --git a/docs/OVERVIEW b/docs/OVERVIEW index 5dd4fed56..01d9cf7c0 100644 --- a/docs/OVERVIEW +++ b/docs/OVERVIEW @@ -30,9 +30,8 @@ privmsgs.py: The privmsg commands that are included by default in the bot. It's probably most useful from a programming standpoint simply so a new programmer can see what commands look like. -callbacks.py: A few basic callbacks used by default in the bot. You'll likely - be inheriting from Privmsg quite a bit, and using the reply - function a bit as well. +callbacks.py: A few basic callbacks providing significant functionality. + You'll likely be inheriting from Privmsg quite a bit. ircdb.py: The users and channels databases are here, as well as the IrcUser and IrcChannel classes. Look here when you want to diff --git a/docs/STYLE b/docs/STYLE index ae63f2999..4b55a34ee 100644 --- a/docs/STYLE +++ b/docs/STYLE @@ -1,13 +1,14 @@ -Maximum line length is 79 characters. +Read PEP 8 (Guido's Style Guide) and know that we use almost all the same style +guidelines. + +Maximum line length is 79 characters. 78 is a safer bet, though. Identation is 4 spaces per level. No tabs. Single quotes are used for all string literals that aren't docstrings. They're just easier to type. -Triple double quotes (""") are always used for docstrings, except for the -docstrings on callbacks deriving from callbacks.Privmsg, which use just -double quotes ("). +Triple double quotes (""") are always used for docstrings. Spaces go around all operators (except around '=' in default arguments to functions) and after all commas (unless doing so keeps a line within the 79 @@ -16,7 +17,8 @@ character limit). Class names are StudlyCaps. Method and function names are camelCaps (StudlyCaps with an initial lowercase letter). If variable and attribute names can maintain readability without being camelCaps, then they should be -entirely in lowercase, otherwise they should also use camelCaps. +entirely in lowercase, otherwise they should also use camelCaps. Plugin names +are StudlyCaps. Imports should always happen at the top of the module, one import per line (so if imports need to be added or removed later, it can be done easily). @@ -26,7 +28,28 @@ class definition. Two blank lines should be between all consecutive class definitions in a file. Comments are even better than blank lines for separating classes. -Code should pass PyChecker with no warnings. +Code should pass PyChecker with no warnings. The PyChecker config file is +included in the tools/ subdirectory. -Read PEP 8 (Guido's Style Guide) and know that we use almost all the same style -guidelines. +Database filenames should generally begin with the name of the plugin and the +extension should be 'db'. baseplugin.DBHandler does this already. + +Whenever creating a file descriptor or socket, keep a reference around and be +sure to close it. There should be no code like this: + s = urllib2.urlopen('url').read() +Instead, do this: + fd = urllib2.urlopen('url') + s = fd.read() + fd.close() +This is to be sure the bot doesn't leak file descriptors. + +All plugins should include a docstring decsribing what the plugin does. After +the decsription, the plugin should have a blank line followed by the line +'Commands include:' followed by a list of commands, one per line, indented two +spaces. The setup script will depend on this format. + +Method docstrings in classes deriving from callbacks.Privmsg should include an +argument list as their first line, and (if necessary) a blank line followed by +a longer description of what the command does. The argument list is used by +the 'help' command, and the longer description is used by the 'morehelp' +command.