More commenting

This commit is contained in:
Skylar Grant 2026-01-05 15:37:35 -05:00
parent c8d679d6a9
commit a6cc742fa0

View File

@ -45,6 +45,13 @@ const strings = {
// ############################################################# // #############################################################
// Classes // Classes
// ############################################################# // #############################################################
/**
* Represents a line item with text, font information, and spacing options.
* @param {String} text The contents of the line
* @param {FontInfo} fontInfo Font details to use for the line
* @param {Boolean} moveDownAfter Provide extra spacing after this line?
* @returns LineItem
*/
class LineItem { class LineItem {
constructor(text, fontInfo, moveDownAfter) { constructor(text, fontInfo, moveDownAfter) {
this.text = text; this.text = text;
@ -54,6 +61,11 @@ class LineItem {
return this; return this;
} }
/**
* Set the contents of the line
* @param {String} text The contents of the line
* @returns LineItem
*/
setText(text) { setText(text) {
if (typeof text !== 'string') { if (typeof text !== 'string') {
throw new Error('Text must be a string'); throw new Error('Text must be a string');
@ -62,6 +74,11 @@ class LineItem {
return this; return this;
} }
/**
* Set the font information for the line
* @param {FontInfo} fontInfo Font details to use for the line
* @returns LineItem
*/
setFontInfo(fontInfo) { setFontInfo(fontInfo) {
if (!(fontInfo instanceof FontInfo)) { if (!(fontInfo instanceof FontInfo)) {
throw new Error('fontInfo must be an instance of FontInfo'); throw new Error('fontInfo must be an instance of FontInfo');
@ -70,6 +87,11 @@ class LineItem {
return this; return this;
} }
/**
* Set whether to provide extra spacing after this line
* @param {Boolean} moveDownAfter Provide extra spacing after this line?
* @returns LineItem
*/
setMoveDownAfter(moveDownAfter) { setMoveDownAfter(moveDownAfter) {
if (typeof moveDownAfter !== 'boolean') { if (typeof moveDownAfter !== 'boolean') {
throw new Error('moveDownAfter must be a boolean'); throw new Error('moveDownAfter must be a boolean');
@ -79,6 +101,13 @@ class LineItem {
} }
} }
/**
* Represents font information including name, size, and style.
* @param {String} name The font name
* @param {Number} size The font size
* @param {String} style The font style
* @returns FontInfo
*/
class FontInfo { class FontInfo {
constructor(name, size, style) { constructor(name, size, style) {
this.name = name || 'Helvetica'; this.name = name || 'Helvetica';
@ -87,6 +116,11 @@ class FontInfo {
return this; return this;
} }
/**
* Set the font name
* @param {String} name The font name
* @returns FontInfo
*/
setName(name) { setName(name) {
if (typeof name !== 'string') { if (typeof name !== 'string') {
throw new Error('Font name must be a string'); throw new Error('Font name must be a string');
@ -95,6 +129,11 @@ class FontInfo {
return this; return this;
} }
/**
* Set the font size
* @param {Number} size The font size
* @returns FontInfo
*/
setSize(size) { setSize(size) {
if (typeof size !== 'number' || size <= 0) { if (typeof size !== 'number' || size <= 0) {
throw new Error('Font size must be a positive number'); throw new Error('Font size must be a positive number');
@ -103,6 +142,11 @@ class FontInfo {
return this; return this;
} }
/**
* Set the font style
* @param {String} style The font style
* @returns FontInfo
*/
setStyle(style) { setStyle(style) {
if (typeof style !== 'string') { if (typeof style !== 'string') {
throw new Error('Font style must be a string'); throw new Error('Font style must be a string');
@ -115,8 +159,11 @@ class FontInfo {
// ############################################################# // #############################################################
// Fonts // Fonts
// ############################################################# // #############################################################
/** @type {FontInfo} */
const standard = new FontInfo('Helvetica', 12); const standard = new FontInfo('Helvetica', 12);
/** @type {FontInfo} */
const standardBold = new FontInfo('Helvetica', 12, 'Bold'); const standardBold = new FontInfo('Helvetica', 12, 'Bold');
/** @type {FontInfo} */
const monospace = new FontInfo('Courier', 16, 'Bold'); const monospace = new FontInfo('Courier', 16, 'Bold');
// ############################################################# // #############################################################