chore(docs): improve docstrings (#18)

This commit is contained in:
Jérome Eertmans
2022-09-17 15:49:10 +02:00
committed by GitHub
parent 620bb30960
commit b9d2cd92b5
4 changed files with 10 additions and 6 deletions

View File

@ -1,9 +1,12 @@
from typing import Callable
import click import click
from .defaults import CONFIG_PATH from .defaults import CONFIG_PATH
def config_path_option(function): def config_path_option(function) -> Callable:
"""Wraps a function to add configuration path option."""
return click.option( return click.option(
"-c", "-c",
"--config", "--config",
@ -14,7 +17,8 @@ def config_path_option(function):
)(function) )(function)
def config_options(function): def config_options(function) -> Callable:
"""Wraps a function to add configuration options."""
function = config_path_option(function) function = config_path_option(function)
function = click.option( function = click.option(
"-f", "--force", is_flag=True, help="Overwrite any existing configuration file." "-f", "--force", is_flag=True, help="Overwrite any existing configuration file."

View File

@ -3,7 +3,6 @@ import platform
import cv2 import cv2
FONT_ARGS = (cv2.FONT_HERSHEY_SIMPLEX, 1, 255, 1, cv2.LINE_AA) FONT_ARGS = (cv2.FONT_HERSHEY_SIMPLEX, 1, 255, 1, cv2.LINE_AA)
PIXELS_PER_CHARACTER = 20
FOLDER_PATH: str = "./slides" FOLDER_PATH: str = "./slides"
CONFIG_PATH: str = ".manim-slides.json" CONFIG_PATH: str = ".manim-slides.json"

View File

@ -37,7 +37,7 @@ class State(IntEnum):
def now() -> int: def now() -> int:
"""Returns time.time() in seconds.""" """Returns time.time() in milliseconds."""
return round(time.time() * 1000) return round(time.time() * 1000)
@ -292,7 +292,7 @@ class Display:
) )
cv2.resizeWindow(WINDOW_NAME, *resolution) cv2.resizeWindow(WINDOW_NAME, *resolution)
def resize_frame_to_screen(self, frame: np.ndarray): def resize_frame_to_screen(self, frame: np.ndarray) -> np.ndarray:
""" """
Resizes a given frame to match screen dimensions. Resizes a given frame to match screen dimensions.

View File

@ -7,7 +7,7 @@ import numpy as np
from .commons import config_options from .commons import config_options
from .config import Config from .config import Config
from .defaults import CONFIG_PATH, FONT_ARGS, PIXELS_PER_CHARACTER from .defaults import CONFIG_PATH, FONT_ARGS
WINDOW_NAME = "Manim Slides Configuration Wizard" WINDOW_NAME = "Manim Slides Configuration Wizard"
WINDOW_SIZE = (120, 620) WINDOW_SIZE = (120, 620)
@ -51,6 +51,7 @@ def init(config_path, force, merge, skip_interactive=False):
def _init(config_path, force, merge, skip_interactive=False): def _init(config_path, force, merge, skip_interactive=False):
"""Actual initialization code for configuration file, with optional interactive mode."""
if os.path.exists(config_path): if os.path.exists(config_path):
click.secho(f"The `{CONFIG_PATH}` configuration file exists") click.secho(f"The `{CONFIG_PATH}` configuration file exists")