Perlwikibot/Contributing

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Introduction[edit | edit source]

Perlwikibot is an open-source project which aims to create a complete framework for rapidly creating and deploying computer programs which can perform common repetitive tasks on MediaWiki wikis. These clients are typically called 'bots' - hence the project name.

You can help fix bugs or add new functionality to the framework. The code is licensed under the GNU General Public License. In short, this means anyone may use the code for any purpose, including commercial use, and including making and distributing modified versions so long as they provide attribution and all derivative versions are also licensed under the GPL.

Code style[edit | edit source]

Perl code is hard enough to read already, so try to make an effort to write readable code.

Comments[edit | edit source]

Comments should be included wherever the code does something that isn't obvious.

bad
sub foo {
    my $param = shift; # Take the first param
    my @args = @_;     # Take the remaining elements, if any
}
good
sub bar {
    my $param = shift; # The page to edit
    my @args  = @_;    # Contains any other settings (for example, whether to mark the edit as minor)
}

Perltidy[edit | edit source]

Perltidy is a code indenter and formatter. You can use it to help clean up your Perl code. For perlwikibot, use:

-syn    # Syntax check input and output
-b      # Backup and modify in-place
-l=78   # Max line width is 78 cols
-i=4    # Indent level is 4 cols
-ci=4   # Continuation indent is 4 cols
-vt=0   # Minimum vertical tightness
-vtc=0  # Minimum vertical tightness closing
-cti=0  # No extra indentation for closing brackets
-pt=2   # Maximum parenthesis tightness
-sbt=2  # Maximum square bracket tightness
-bt=1   # Medium brace tightness
-nsfs   # No space before semicolons
-nolq   # Don't outdent long quoted strings
-boc    # Break at old comma breakpoints
-bbs    # Blank line before subs
-sot    # Stack opening tokens
-sct    # Stack closing tokens
-bbao   # Break before all operators

You can put this in .perltidyrc, and they'll be used every time you use perltidy. Put the file in your working directory to apply only to that directory, or in your $HOME to use the settings for everything.

Alternatively, set each option as a command line option to perltidy:

user@host:~$ perltidy -syn -b -l=78 ...

Committing[edit | edit source]

Mike pushes his git repo to github; to contribute, make a fork, make your changes, and make a new pull request.