Skip to content

Commit

Permalink
added proper docstrings for python scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Dec 15, 2023
1 parent d9af9a9 commit 59dd86f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 115 deletions.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: MIT

{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
Expand Down
64 changes: 27 additions & 37 deletions mcsrvstat/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,20 @@ class ServerPlatform(Enum):

# Classes.
class Icon:
"""
Represents the icon of a server.
"""Represents the icon of a server.
Methods:
`save()` - Saves the icon locally.
save(): Saves the icon locally.
"""

def __init__(self, data: bytes):
self.data = data

def save(self, name: str = 'result') -> str:
"""
Saves the icon on the local machine.
Parameters:
name (`str`): The name to use for the new file (doesn't change the format of the image).
Defaults to `result`.
"""Saves the icon locally.
Returns:
The full name (with extension) of the file.
Args:
name (str): The name to use for the image file. Defaults to "result".
"""

im = Image.open(BytesIO(self.data))
Expand All @@ -50,12 +44,11 @@ def save(self, name: str = 'result') -> str:
# Data classes.
@dataclass(frozen=True)
class Player:
"""
Represents a player from the server.
"""Represents a player from the server.
Attributes:
`name` - The friendly name of the player.\n
`uuid` - The UUID of the player.
name (str): The friendly name of the player.
uuid (str): The UUID of the player.
"""

name: str
Expand All @@ -64,13 +57,12 @@ class Player:

@dataclass(frozen=True)
class ServerMOTD:
"""
Represents the 'Message of the Day' or 'MOTD' of the server.
"""Represents the 'Message of the Day' or 'MOTD' of the server.
Attributes:
`raw` - No formatting, get the raw one.\n
`clean` - Retrieve the MOTD in an already formatted way.\n
`html` - Retrieve the MOTD in HTML.
raw (str): No formatting, get the raw one.
clean (str): Retrieve the MOTD in an already formatted way.
html (str): Retrieve the MOTD in HTML.
"""

raw: str
Expand All @@ -80,13 +72,12 @@ class ServerMOTD:

@dataclass(frozen=True)
class ServerInfo:
"""
The default class for accessing base server information in different formats.
"""The default class for accessing base server information in different formats.
Attributes:
`raw` - No formatting, get the raw one.\n
`clean` - Retrieve the info in an already formatted way.\n
`html` - Retrieve the info in HTML.
raw (list): No formatting, get the raw one.
cleaw (list): Retrieve the info in an already formatted way.
htmw (list): Retrieve the info in HTML.
"""

raw: list
Expand All @@ -96,12 +87,11 @@ class ServerInfo:

@dataclass(frozen=True)
class ServerPlugin:
"""
Represents a server plugin.
"""Represents a server plugin.
Attributes:
`name` - The name of the plugin.\n
`version` - The version of the plugin.
name (str): The name of the plugin.
version (str): The version of the plugin.
"""

name: str
Expand All @@ -110,12 +100,11 @@ class ServerPlugin:

@dataclass(frozen=True)
class ServerMod:
"""
Represents a server mod.
"""Represents a mod installed on the server.
Attributes:
`name` - The name of the mod.\n
`version` - The version of the mod.
name (str): The name of the mod.
version (str): The version of the mod.
"""

name: str
Expand All @@ -124,13 +113,14 @@ class ServerMod:

@dataclass(frozen=True)
class ServerDebugInfo:
"""
The default class for accessing server debug values.
"""The default class for accessing server debug values.
Attributes:
Get information on different debug values from the official [documentation](https://api.mcsrvstat.us).
"""

# TODO: Add detailed explanation on the debug values instead of refering to external links

ping: bool
query: bool
srv: bool
Expand All @@ -150,8 +140,8 @@ class PlayerCount:
Represents the current player count of the server.
Attributes:
`online` - The amount of players currently online.\n
`max` - The maximum amount of players the server can hold at a time.
online (int): The amount of players currently online.\n
max (int): The maximum amount of players the server can hold at a time.
"""

online: int
Expand Down
Loading

0 comments on commit 59dd86f

Please sign in to comment.