@@ -121,14 +121,16 @@ def url(self):
121121 def _beautiful_soup (content ):
122122 """
123123 Parses HTML content into a BeautifulSoup object.
124+
124125 Parameters
125126 ----------
126127 content: :class:`str`
127128 The HTML content.
128129
129130 Returns
130131 -------
131- :class:`bs4.BeautifulSoup`: The parsed content.
132+ :class:`bs4.BeautifulSoup`
133+ The parsed content.
132134 """
133135 return bs4 .BeautifulSoup (content .replace ('ISO-8859-1' , 'utf-8' ), 'lxml' ,
134136 parse_only = bs4 .SoupStrainer ("div" , class_ = "BoxContent" ))
@@ -177,12 +179,10 @@ def _parse_current_member(guild, previous_rank, values):
177179 ----------
178180 guild: :class:`dict`[str, Any]
179181 Dictionary where information will be stored.
180- previous_rank
181- values
182-
183- Returns
184- -------
185-
182+ previous_rank: :class:`dict`[int, str]
183+ The last rank present in the rows.
184+ values: tuple[:class:`str`]
185+ A list of row contents.
186186 """
187187 rank , name , vocation , level , joined , status = values
188188 rank = previous_rank [1 ] if rank == " " else rank
@@ -205,12 +205,32 @@ def _parse_current_member(guild, previous_rank, values):
205205
206206 @staticmethod
207207 def _parse_guild_applications (guild , info_container ):
208+ """
209+ Parses the guild's application info.
210+
211+ Parameters
212+ ----------
213+ guild: :class:`dict`[str, Any]
214+ Dictionary where information will be stored.
215+ info_container: :class:`bs4.Tag`
216+ The parsed content of the information container.
217+ """
208218 m = applications_regex .search (info_container .text )
209219 if m :
210220 guild ["open_applications" ] = m .group (1 ) == "opened"
211221
212222 @staticmethod
213223 def _parse_guild_disband_info (guild , info_container ):
224+ """
225+ Parses the guild's disband info, if available.
226+
227+ Parameters
228+ ----------
229+ guild: :class:`dict`[str, Any]
230+ Dictionary where information will be stored.
231+ info_container: :class:`bs4.Tag`
232+ The parsed content of the information container.
233+ """
214234 m = disband_regex .search (info_container .text )
215235 if m :
216236 guild ["disband_condition" ] = m .group (2 )
@@ -221,6 +241,16 @@ def _parse_guild_disband_info(guild, info_container):
221241
222242 @staticmethod
223243 def _parse_guild_guildhall (guild , info_container ):
244+ """
245+ Parses the guild's guildhall info.
246+
247+ Parameters
248+ ----------
249+ guild: :class:`dict`[str, Any]
250+ Dictionary where information will be stored.
251+ info_container: :class:`bs4.Tag`
252+ The parsed content of the information container.
253+ """
224254 m = guildhall_regex .search (info_container .text )
225255 if m :
226256 guild ["guildhall" ] = {"name" : m .group ("name" ), "paid_until" : m .group ("date" ).replace ("\xa0 " , " " )}
@@ -229,6 +259,16 @@ def _parse_guild_guildhall(guild, info_container):
229259
230260 @staticmethod
231261 def _parse_guild_homepage (guild , info_container ):
262+ """
263+ Parses the guild's homepage info.
264+
265+ Parameters
266+ ----------
267+ guild: :class:`dict`[str, Any]
268+ Dictionary where information will be stored.
269+ info_container: :class:`bs4.Tag`
270+ The parsed content of the information container.
271+ """
232272 m = homepage_regex .search (info_container .text )
233273 if m :
234274 guild ["homepage" ] = m .group (1 )
@@ -237,6 +277,16 @@ def _parse_guild_homepage(guild, info_container):
237277
238278 @staticmethod
239279 def _parse_guild_info (guild , info_container ):
280+ """
281+ Parses the guild's general information.
282+
283+ Parameters
284+ ----------
285+ guild: :class:`dict`[str, Any]
286+ Dictionary where information will be stored.
287+ info_container: :class:`bs4.Tag`
288+ The parsed content of the information container.
289+ """
240290 m = founded_regex .search (info_container .text )
241291 if m :
242292 description = m .group ("desc" ).strip ()
@@ -247,6 +297,21 @@ def _parse_guild_info(guild, info_container):
247297
248298 @staticmethod
249299 def _parse_guild_list (content , active_only = False ):
300+ """
301+ Parses the contents of a world's guild list page.
302+
303+ Parameters
304+ ----------
305+ content: :class:`str`
306+ The HTML content of the page.
307+ active_only: :class:`bool`
308+ Whether to only show active guilds.
309+
310+ Returns
311+ -------
312+ List[:class:`dict`[str, Any]]
313+ A list of guild dictionaries.
314+ """
250315 parsed_content = Guild ._beautiful_soup (content )
251316 selected_world = parsed_content .find ('option' , selected = True )
252317 try :
@@ -284,6 +349,21 @@ def _parse_guild_list(content, active_only=False):
284349
285350 @staticmethod
286351 def _parse_guild_logo (guild , parsed_content ):
352+ """
353+ Parses the guild's logo.
354+
355+ Parameters
356+ ----------
357+ guild: :class:`dict`[str, Any]
358+ Dictionary where information will be stored.
359+ parsed_content: :class:`bs4.Tag`
360+ The parsed content of the page.
361+
362+ Returns
363+ -------
364+ :class:`bool`
365+ Whether the logo was found or not.
366+ """
287367 logo_img = parsed_content .find ('img' , {'height' : '64' })
288368 if logo_img is None :
289369 return False
@@ -293,25 +373,55 @@ def _parse_guild_logo(guild, parsed_content):
293373
294374 @staticmethod
295375 def _parse_guild_members (guild , parsed_content ):
376+ """
377+ Parses the guild's member and invited list.
378+
379+ Parameters
380+ ----------
381+ guild: :class:`dict`[str, Any]
382+ Dictionary where information will be stored.
383+ parsed_content: :class:`bs4.Tag`
384+ The parsed content of the guild's page
385+ """
296386 member_rows = parsed_content .find_all ("tr" , {'bgcolor' : ["#D4C0A1" , "#F1E0C6" ]})
297387 guild ["members" ] = []
298388 guild ["invites" ] = []
299389 previous_rank = {}
300390 for row in member_rows :
301391 columns = row .find_all ('td' )
302- values = (c .text .replace ("\u00a0 " , " " ) for c in columns )
392+ values = tuple (c .text .replace ("\u00a0 " , " " ) for c in columns )
303393 if len (columns ) == COLS_GUILD_MEMBER :
304394 Guild ._parse_current_member (guild , previous_rank , values )
305395 if len (columns ) == COLS_INVITED_MEMBER :
306396 Guild ._parse_invited_member (guild , values )
307397
308398 @staticmethod
309399 def _parse_guild_name (guild , parsed_content ):
400+ """
401+ Parses the guild's name.
402+
403+ Parameters
404+ ----------
405+ guild: :class:`dict`[str, Any]
406+ Dictionary where information will be stored.
407+ parsed_content: :class:`bs4.Tag`
408+ The parsed content of guild's page.
409+ """
310410 header = parsed_content .find ('h1' )
311411 guild ["name" ] = header .text
312412
313413 @staticmethod
314414 def _parse_invited_member (guild , values ):
415+ """
416+ Parses the column texts of an invited row into a invited dictionary.
417+
418+ Parameters
419+ ----------
420+ guild: :class:`dict`[str, Any]
421+ Dictionary where information will be stored.
422+ values: tuple[:class:`str`]
423+ A list of row contents.
424+ """
315425 name , date = values
316426 if date != "Invitation Date" :
317427 guild ["invites" ].append ({
@@ -329,9 +439,9 @@ def list_from_content(content, active_only=False):
329439
330440 Parameters
331441 ----------
332- content: str
442+ content: :class:` str`
333443 The html content of the page.
334- active_only: bool
444+ active_only: :class:` bool`
335445 Whether to only show active guilds or not.
336446
337447 Returns
@@ -346,10 +456,9 @@ def list_from_content(content, active_only=False):
346456 def from_content (content ) -> Optional ['Guild' ]:
347457 """Creates an instance of the class from the html content of the guild's page.
348458
349-
350459 Parameters
351460 -----------
352- content: str
461+ content: :class:` str`
353462 The HTML content of the page.
354463
355464 Returns
@@ -378,12 +487,12 @@ def get_url(name):
378487
379488 Parameters
380489 ------------
381- name: str
490+ name: :class:` str`
382491 The name of the guild
383492
384493 Returns
385494 --------
386- str
495+ :class:` str`
387496 The URL to the guild's page"""
388497 return GUILD_URL + urllib .parse .quote (name .encode ('iso-8859-1' ))
389498
@@ -393,12 +502,12 @@ def get_world_list_url(world):
393502
394503 Parameters
395504 ----------
396- world: str
505+ world: :class:` str`
397506 The name of the world
398507
399508 Returns
400509 -------
401- str
510+ :class:` str`
402511 The URL to the guild's page
403512 """
404513 return GUILD_LIST_URL + urllib .parse .quote (world .title ().encode ('iso-8859-1' ))
@@ -410,11 +519,11 @@ def json_list_from_content(content, active_only=False, indent=None):
410519
411520 Parameters
412521 ----------
413- content: str
522+ content: :class:` str`
414523 The html content of the page.
415- active_only: bool
524+ active_only: :class:` bool`
416525 Whether to only show active guilds or not.
417- indent: int
526+ indent: :class:` int`
418527 The number of spaces to indent the output with.
419528
420529 Returns
@@ -431,15 +540,16 @@ def parse_to_json(content, indent=None):
431540
432541 Parameters
433542 -------------
434- content: str
543+ content: :class:` str`
435544 The HTML content of the page.
436- indent: int
545+ indent: :class:` int`
437546 The number of spaces to indent the output with.
438547
439548 Returns
440549 ------------
441550 :class:`str`
442- A string in JSON format."""
551+ A string in JSON format.
552+ """
443553 char_dict = Guild ._parse (content )
444554 return json .dumps (char_dict , indent = indent )
445555
@@ -500,8 +610,8 @@ class GuildInvite(abc.Character):
500610 The name of the character
501611
502612 date: :class:`datetime.date`
503- The day when the character was invited."""
504-
613+ The day when the character was invited.
614+ """
505615 __slots__ = ("date" , )
506616
507617 def __init__ (self , name = None , date = None ):
0 commit comments