User:AnomieBOT/source/d/Sections.pm/doc

NAME edit

d::Sections - AnomieBOT section manipulation decorator

SYNOPSIS edit

 use AnomieBOT::API;
 
 $api = new AnomieBOT::API('conf.ini', 1);
 $api->decorators(qw/d::Sections/);

DESCRIPTION edit

d::Sections contains functions to manage sections in wikitext for use by an AnomieBOT task. When "d::Sections" is used as a decorator on the API object, the following methods are available.

Also, all the methods provided by d::Templates, d::Redirects, and d::IWNS are available, as they are used internally.

METHODS PROVIDED edit

$api->split_sections( $wikitext )
$api->split_sections( $wikitext, $levels )
Splits the wikitext into an array of section object. If $levels is provided, it should contain the digits 1-6 representing the heading levels to consider. For example, "24" would split on "==" and "====" sections, but ignore "===" and all others.
A section object has the following properties:
level
The level of the section, i.e. a number 1-6. If there is any text before the first section heading, that section will have undef here.
title
The title of the section. If there is any text before the first section heading, that section will have an empty string here.
titlespaced
A boolean, indicating whether there are spaces between the =s and the title.
titlecomment
If there is a comment after the title, it is contained here.
body
The body text of the section. Depending on the $levels used, this may contain other section headers.
$api->join_sections( @sections )
Joins an array of section objects back together.
$api->extract_end_content( $text )
Extracts the "end content" from the passed article text. This consists of the lines containing only whitespace, categories, interlanguage links, comments, and templates (with some exceptions) from the end of the article. In a list context, returns a 2-element list consisting of the portion of $text that is not end content and the portion that is; in a scalar context, returns just the portion that is.
The list of exceptions can be set using $api->set_non_end_templates().
$api->non_end_templates
$api->non_end_templates( @templates )
Get or set the list of non-end templates.

COPYRIGHT edit

Copyright 2008–2013 Anomie

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.