From a7367856ee26b4a35c244ea139307bbf67c97dd0 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 6 Aug 2011 16:34:54 -0400 Subject: [PATCH] Finished docstrings in wikitools. --- wiki/tools/category.py | 16 ++++++++++++++-- wiki/tools/site.py | 14 +++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/wiki/tools/category.py b/wiki/tools/category.py index 588956a..7ebe342 100644 --- a/wiki/tools/category.py +++ b/wiki/tools/category.py @@ -5,11 +5,23 @@ from wiki.tools.page import Page class Category(Page): """ EarwigBot's Wiki Toolset: Category Class + + Represents a Category on a given Site, a subclass of Page. Provides + additional methods, but Page's own methods should work fine on Category + objects. Site.get_page() will return a Category instead of a Page if the + given title is in the category namespace; get_category() is shorthand, + because it accepts category names without the namespace prefix. + + Public methods: + members -- returns a list of titles in the category """ def members(self, limit=50): - """ - Docstring needed + """Returns a list of titles in the category. + + If `limit` is provided, we will provide this many titles, or less if + the category is too small. `limit` defaults to 50; normal users can go + up to 500, and bots can go up to 5,000 on a single API query. """ params = {"action": "query", "list": "categorymembers", "cmlimit": limit, "cmtitle": self.title} diff --git a/wiki/tools/site.py b/wiki/tools/site.py index 933bc43..57b890d 100644 --- a/wiki/tools/site.py +++ b/wiki/tools/site.py @@ -24,6 +24,18 @@ class Site(object): won't need to call it directly, rather tools.get_site() for returning Site instances, tools.add_site() for adding new ones to config, and tools.del_site() for removing old ones from config, should suffice. + + Public methods: + name -- returns our name (or "wikiid"), like "enwiki" + project -- returns our project name, like "wikipedia" + lang -- returns our language code, like "en" + domain -- returns our web domain, like "en.wikipedia.org" + api_query -- does an API query with the given kwargs as params + namespace_id_to_name -- given a namespace ID, returns associated name(s) + namespace_name_to_id -- given a namespace name, returns associated id + get_page -- returns a Page object for the given title + get_category -- returns a Category object for the given title + get_user -- returns a User object for the given username """ def __init__(self, name=None, project=None, lang=None, base_url=None, @@ -351,7 +363,7 @@ class Site(object): return self._project def lang(self): - """Returns the Site's language, like "en" or "es".""" + """Returns the Site's language code, like "en" or "es".""" return self._lang def domain(self):