Module mwbot::generators
source · Available on crate feature
generators
only.Expand description
§Page generators
Page generators are used to get lists of pages to operate on. For example, you could get a list of pages in a category or pages that use a specific template.
Most generators return a Page
, but others may return
other types, for example Revisions returns revision metadata.
§Basic usage
All generators follow the same basic structure:
- a
new()
constructor that takes mandatory parameters - optional functions to supply optional parameters
- a
generate()
function to start fetching pages
Rust has mediocre support for asynchronous iterators, so we take the approach of spawning a background task to fetch pages and use a channel to pass the results back. (This is why generators don’t work in WebAssembly.)
§Example
To fetch a list of pages in the category Free software programmed in Rust:
use mwbot::generators::{categories::CategoryMembers, Generator};
let bot = Bot::from_default_config().await.unwrap();
let mut generator = CategoryMembers::new("Category:Free software programmed in Rust");
let mut pages = generator.generate(&bot);
while let Some(page) = pages.recv().await {
let page = page?;
println!("{}", page.title());
}
Modules§
- Generator to get all pages
- Generators related to categories
- Generators related to file usage
- Get language links
- Generators related to wikilink usage
- lint
linter
Generators related to lint errors - Generators related to log events
- Generator for lonely pages (not linked by other pages)
- Generators related to page property usage
- Generator for QueryPage-based special pages
- Generator to get a random set of pages
- Generator for Special:RecentChanges
- Generators to get revisions (e.g. page history)
- Generator to search for pages
- Generator to get transcluded pages
- Generators related to uncategorized pages
- unconnected_
pages wikibase
Generator for pages not linked to a Wikibase item - Generators related to unused pages
- Generator for unwatched pages
- Generator to get user contributions
Structs§
- Get pages that transclude the given template
Enums§
Traits§
- Derivable trait that implements a straightforward builder to construct API parameters to generate a list of pages. Using the MediaWiki API’s generator feature, it preloads basic metadata about pages to speed up initial processing.
- Trait to represent a value that can be an API parameter value.
Functions§
- Recursively get pages that are in given category.
Derive Macros§
- macro to implement the
Generator
trait