Skip to content

Commit

Permalink
docs: Document all functions in app, settings modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Jul 11, 2023
1 parent 0bda861 commit 5a070e5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
5 changes: 4 additions & 1 deletion biscuit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
__version__ = '2.5.0'
__version_info__ = tuple([ int(num) for num in __version__.split('.')])

# For tests to run successfully
import sys
from os.path import abspath, dirname, join
sys.path.append(abspath(join(dirname(__file__), '.')))

from .app import App

from .app import App
7 changes: 7 additions & 0 deletions biscuit/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Entry point for the main app.
To run the app, do:
>>> python biscuit
"""

import sys
from app import App

Expand Down
53 changes: 42 additions & 11 deletions biscuit/core/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@


class Settings:
"""
The Settings class is responsible for managing the configuration settings of the application.
It initializes the Config, Style, and Resources classes, and sets up properties such as bindings and fonts.
It also generates an action set that allows the user to run commands and access various settings
related to the editor theme, bindings, and font.
"""
def __init__(self, base):
self.base = base

Expand All @@ -26,10 +32,20 @@ def __init__(self, base):
self.gen_actionset()

def register_command(self, name, command):
"""
Registers a new command to the action set.
Args:
name (str): The name of the command.
command (function): The function to be executed when the command is triggered.
"""
self.commands.append((name, command))
self.gen_actionset()

def gen_actionset(self):
"""
Generates the action set with predefined commands and registered commands.
"""
from core.components import ActionSet
self._actionset = ActionSet(
"Show and run commands", ">",
Expand All @@ -39,23 +55,38 @@ def gen_actionset(self):
("Editor Font", lambda e=None: print("Font", e)),
] + self.commands + get_games(self.base)
)

@property
def actionset(self):
return self._actionset

def setup_properties(self):
"""
Sets up properties such as bindings and fonts.
"""
self.setup_bindings()
self.setup_font()

def setup_bindings(self):
"""
Sets up the Bindings class.
"""
self.bindings = Bindings(self)

def setup_font(self):

self.iconfont = extra.Font(file=os.path.join(self.base.resdir, "fonts/firacode/firacode.ttf"), family="firacode")
self.iconfont = extra.Font(file=os.path.join(self.base.resdir, "fonts/fixedsys/FSEX302.ttf"), family="fixedsys")
"""
Sets up the font and icon fonts.
"""
self.firacodefont = extra.Font(file=os.path.join(self.base.resdir, "fonts/firacode/firacode.ttf"), family="firacode")
self.fixedsysfont = extra.Font(file=os.path.join(self.base.resdir, "fonts/fixedsys/FSEX302.ttf"), family="fixedsys")
self.iconfont = extra.Font(file=os.path.join(self.base.resdir, "fonts/codicon/codicon.ttf"), family="codicon")
self.font = tk.font.Font(
family=self.config.font[0],
size=self.config.font[1])
family=self.config.font[0],
size=self.config.font[1]
)

@property
def actionset(self):
"""
Returns the generated action set.
Returns:
ActionSet: The generated action set.
"""
return self._actionset

0 comments on commit 5a070e5

Please sign in to comment.