Translated help system to use Google-style docstrings, as per #709.

This commit is contained in:
Griatch 2015-05-17 12:54:10 +02:00
parent 3e9263e207
commit aff6f8c4b4

View file

@ -26,6 +26,16 @@ class HelpEntryManager(models.Manager):
def find_topicmatch(self, topicstr, exact=False): def find_topicmatch(self, topicstr, exact=False):
""" """
Searches for matching topics based on player's input. Searches for matching topics based on player's input.
Args:
topcistr (str): Help topic to search for.
exact (bool, optional): Require exact match
(non-case-sensitive). If `False` (default), match
sub-parts of the string.
Returns:
matches (HelpEntries): Query results.
""" """
dbref = utils.dbref(topicstr) dbref = utils.dbref(topicstr)
if dbref: if dbref:
@ -41,6 +51,13 @@ class HelpEntryManager(models.Manager):
""" """
Do a very loose search, returning all help entries containing Do a very loose search, returning all help entries containing
the search criterion in their titles. the search criterion in their titles.
Args:
topicstr (str): Search criterion.
Returns:
matches (HelpEntries): Query results.
""" """
return self.filter(db_key__icontains=topicstr) return self.filter(db_key__icontains=topicstr)
@ -48,34 +65,61 @@ class HelpEntryManager(models.Manager):
""" """
Do a fuzzy match, preferably within the category of the Do a fuzzy match, preferably within the category of the
current topic. current topic.
Args:
topicstr (str): Search criterion.
Returns:
matches (Helpentries): Query results.
""" """
return self.filter(db_key__icontains=topicstr).exclude(db_key__iexact=topicstr) return self.filter(db_key__icontains=topicstr).exclude(db_key__iexact=topicstr)
def find_topics_with_category(self, help_category): def find_topics_with_category(self, help_category):
""" """
Search topics having a particular category Search topics having a particular category.
Args:
help_category (str): Category query criterion.
Returns:
matches (HelpEntries): Query results.
""" """
return self.filter(db_help_category__iexact=help_category) return self.filter(db_help_category__iexact=help_category)
def get_all_topics(self): def get_all_topics(self):
""" """
Return all topics. Get all topics.
Returns:
all (HelpEntries): All topics.
""" """
return self.all() return self.all()
def get_all_categories(self, pobject): def get_all_categories(self):
""" """
Return all defined category names with at least one Return all defined category names with at least one topic in
topic in them. them.
Returns:
matches (list): Unique list of category names across all
topics.
""" """
return list(set(topic.help_category for topic in self.all())) return list(set(topic.help_category for topic in self.all()))
def all_to_category(self, default_category): def all_to_category(self, default_category):
""" """
Shifts all help entries in database to default_category. Shifts all help entries in database to default_category. This
This action cannot be reverted. It is used primarily by action cannot be reverted. It is used primarily by the engine
the engine when importing a default help database, making when importing a default help database, making sure this ends
sure this ends up in one easily separated category. up in one easily separated category.
Args:
default_category (str): Category to move entries to.
""" """
topics = self.all() topics = self.all()
for topic in topics: for topic in topics:
@ -88,8 +132,10 @@ class HelpEntryManager(models.Manager):
""" """
Retrieve a search entry object. Retrieve a search entry object.
ostring - the help topic to look for Args:
category - limit the search to a particular help topic ostring (str): The help topic to look for.
category (str): Limit the search to a particular help topic
""" """
ostring = ostring.strip().lower() ostring = ostring.strip().lower()
if help_category: if help_category: