Skip to content

Commit

Permalink
docs: add jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
doprz committed Feb 22, 2024
1 parent d5a04c7 commit 8c2ae92
Show file tree
Hide file tree
Showing 122 changed files with 711 additions and 452 deletions.
1 change: 1 addition & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineManifest } from '@crxjs/vite-plugin';

import packageJson from '../package.json';

// Convert from Semver (example: 0.1.0-beta6)
Expand Down
3 changes: 2 additions & 1 deletion src/pages/background/background.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BACKGROUND_MESSAGES } from '@shared/messages';
import type { BACKGROUND_MESSAGES } from '@shared/messages';
import { MessageListener } from 'chrome-extension-toolkit';

import onInstall from './events/onInstall';
import onServiceWorkerAlive from './events/onServiceWorkerAlive';
import onUpdate from './events/onUpdate';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/background/handler/browserActionHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BrowserActionMessages from '@shared/messages/BrowserActionMessages';
import { MessageHandler } from 'chrome-extension-toolkit';
import type BrowserActionMessages from '@shared/messages/BrowserActionMessages';
import type { MessageHandler } from 'chrome-extension-toolkit';

const browserActionHandler: MessageHandler<BrowserActionMessages> = {
disableBrowserAction({ sender, sendResponse }) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/background/handler/hotReloadingHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import HotReloadingMessages from '@shared/messages/HotReloadingMessages';
import type HotReloadingMessages from '@shared/messages/HotReloadingMessages';
import { DevStore } from '@shared/storage/DevStore';
import { MessageHandler } from 'chrome-extension-toolkit';
import type { MessageHandler } from 'chrome-extension-toolkit';

const hotReloadingHandler: MessageHandler<HotReloadingMessages> = {
async reloadExtension({ sendResponse }) {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/background/handler/tabManagementHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import TabManagementMessages from '@shared/messages/TabManagementMessages';
import { MessageHandler } from 'chrome-extension-toolkit';
import type TabManagementMessages from '@shared/messages/TabManagementMessages';
import type { MessageHandler } from 'chrome-extension-toolkit';

import openNewTab from '../util/openNewTab';

const tabManagementHandler: MessageHandler<TabManagementMessages> = {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/background/handler/userScheduleHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UserScheduleMessages } from '@shared/messages/UserScheduleMessages';
import type { UserScheduleMessages } from '@shared/messages/UserScheduleMessages';
import { Course } from '@shared/types/Course';
import { MessageHandler } from 'chrome-extension-toolkit';
import type { MessageHandler } from 'chrome-extension-toolkit';

import addCourse from '../lib/addCourse';
import clearCourses from '../lib/clearCourses';
import createSchedule from '../lib/createSchedule';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/background/lib/addCourse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
import { Course } from '@shared/types/Course';
import type { Course } from '@shared/types/Course';

/**
*
Expand Down
5 changes: 5 additions & 0 deletions src/pages/background/lib/clearCourses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';

/**
* Clears the courses for a given schedule.
* @param scheduleName - The name of the schedule.
* @throws Error if the schedule does not exist.
*/
export default async function clearCourses(scheduleName: string): Promise<void> {
const schedules = await UserScheduleStore.get('schedules');
const schedule = schedules.find(schedule => schedule.name === scheduleName);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/background/lib/createSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function createSchedule(scheduleName: string): Promise<stri
schedules.push({
name: scheduleName,
courses: [],
hours: 0
hours: 0,
});

await UserScheduleStore.set('schedules', schedules);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/background/lib/deleteSchedule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';

/**
* Deletes a schedule with the specified name.
*
* @param scheduleName - The name of the schedule to delete.
* @returns A promise that resolves to a string if there is an error, or undefined if the schedule is deleted successfully.
*/
export default async function deleteSchedule(scheduleName: string): Promise<string | undefined> {
const [schedules, activeIndex] = await Promise.all([
UserScheduleStore.get('schedules'),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/background/lib/removeCourse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
import { Course } from '@shared/types/Course';
import type { Course } from '@shared/types/Course';

/**
*
Expand Down
6 changes: 6 additions & 0 deletions src/pages/background/lib/renameSchedule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';

/**
* Renames a schedule with the specified name to a new name.
* @param scheduleName - The name of the schedule to be renamed.
* @param newName - The new name for the schedule.
* @returns A promise that resolves to a string if there is an error, or undefined if the schedule is renamed successfully.
*/
export default async function renameSchedule(scheduleName: string, newName: string): Promise<string | undefined> {
const schedules = await UserScheduleStore.get('schedules');
const scheduleIndex = schedules.findIndex(schedule => schedule.name === scheduleName);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/background/lib/switchSchedule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';

/**
* Switches the active schedule to the specified schedule name.
* Throws an error if the schedule does not exist.
* @param scheduleName - The name of the schedule to switch to.
* @returns A Promise that resolves when the active schedule is successfully switched.
*/
export default async function switchSchedule(scheduleName: string): Promise<void> {
const schedules = await UserScheduleStore.get('schedules');

Expand Down
2 changes: 1 addition & 1 deletion src/pages/calendar/CalendarMain.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
import React from 'react';
import { Calendar } from 'src/views/components/calendar/Calendar/Calendar';

/**
Expand Down
26 changes: 12 additions & 14 deletions src/pages/calendar/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Calendar</title>
</head>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Calendar</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
</html>
1 change: 1 addition & 0 deletions src/pages/calendar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { createRoot } from 'react-dom/client';

import CalendarMain from './CalendarMain';

createRoot(document.getElementById('root')).render(<CalendarMain />);
4 changes: 2 additions & 2 deletions src/pages/content/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import CourseCatalogMain from '@views/components/CourseCatalogMain';
import getSiteSupport, { SiteSupport } from '@views/lib/getSiteSupport';
import React from 'react';
import { createRoot } from 'react-dom/client';

const support = getSiteSupport(window.location.href);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/debug/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
import React from 'react';

/**
*
Expand Down
26 changes: 12 additions & 14 deletions src/pages/debug/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Debug</title>
</head>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Debug</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/pages/options/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
import React from 'react';

/**
*
Expand Down
26 changes: 12 additions & 14 deletions src/pages/options/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Popup</title>
</head>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Popup</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
</html>
1 change: 1 addition & 0 deletions src/pages/options/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { createRoot } from 'react-dom/client';

import App from './App';

createRoot(document.getElementById('root')).render(<App />);
26 changes: 12 additions & 14 deletions src/pages/popup/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Popup</title>
</head>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Popup</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="./index.tsx" type="module"></script>
</body>
</html>
1 change: 1 addition & 0 deletions src/pages/popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { createRoot } from 'react-dom/client';

import PopupMain from '../../views/components/PopupMain';

createRoot(document.getElementById('root')).render(<PopupMain />);
1 change: 1 addition & 0 deletions src/shared/messages/BrowserActionMessages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jsdoc/require-jsdoc */
export default interface BrowserActionMessages {
/** make it so that clicking the browser action will open the popup.html */
enableBrowserAction: () => void;
Expand Down
1 change: 1 addition & 0 deletions src/shared/messages/HotReloadingMessages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jsdoc/require-jsdoc */
export default interface HotReloadingMessages {
reloadExtension: () => void;
}
5 changes: 4 additions & 1 deletion src/shared/messages/UserScheduleMessages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Course } from '../types/Course';
import type { Course } from '@shared/types/Course';

/**
* Represents a collection of user schedule messages.
*/
export interface UserScheduleMessages {
/**
* Add a course to a schedule
Expand Down
9 changes: 5 additions & 4 deletions src/shared/messages/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { createMessenger } from 'chrome-extension-toolkit';
import BrowserActionMessages from './BrowserActionMessages';
import TabManagementMessages from './TabManagementMessages';
import TAB_MESSAGES from './TabMessages';
import { UserScheduleMessages } from './UserScheduleMessages';

import type BrowserActionMessages from './BrowserActionMessages';
import type TabManagementMessages from './TabManagementMessages';
import type TAB_MESSAGES from './TabMessages';
import type { UserScheduleMessages } from './UserScheduleMessages';

/**
* This is a type with all the message definitions that can be sent TO the background script
Expand Down
2 changes: 0 additions & 2 deletions src/shared/storage/ExtensionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ export const ExtensionStore = createLocalStore<IExtensionStore>({
lastUpdate: Date.now(),
});



debugStore({ ExtensionStore });
6 changes: 3 additions & 3 deletions src/shared/types/Course.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-classes-per-file */
import { Serialized } from 'chrome-extension-toolkit';
import { CourseMeeting } from './CourseMeeting';
import type { Serialized } from 'chrome-extension-toolkit';

import type { CourseMeeting } from './CourseMeeting';
import { CourseSchedule } from './CourseSchedule';
import Instructor from './Instructor';

Expand Down
2 changes: 1 addition & 1 deletion src/shared/types/CourseMeeting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Serialized } from 'chrome-extension-toolkit';
import type { Serialized } from 'chrome-extension-toolkit';

/**
* a map of the days of the week that a class is taught, and the corresponding abbreviation
Expand Down
6 changes: 4 additions & 2 deletions src/shared/types/CourseSchedule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Serialized } from 'chrome-extension-toolkit';
import { CourseMeeting, Day, DAY_MAP } from './CourseMeeting';
import type { Serialized } from 'chrome-extension-toolkit';

import type { Day } from './CourseMeeting';
import { CourseMeeting, DAY_MAP } from './CourseMeeting';

/**
* This represents the schedule for a course, which includes all the meeting times for the course, as well as helper functions for parsing, serializing, and deserializing the schedule
Expand Down
2 changes: 1 addition & 1 deletion src/shared/types/Distribution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-classes-per-file */
import { PointOptionsObject } from 'highcharts';

import { Semester } from './Course';
/**
* Each of the possible letter grades that can be given in a course
Expand Down
3 changes: 2 additions & 1 deletion src/shared/types/Instructor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Serialized } from 'chrome-extension-toolkit';
import type { Serialized } from 'chrome-extension-toolkit';

import { capitalize } from '../util/string';

/**
Expand Down
3 changes: 2 additions & 1 deletion src/shared/types/UserSchedule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Serialized } from 'chrome-extension-toolkit';
import type { Serialized } from 'chrome-extension-toolkit';

import { Course } from './Course';

/**
Expand Down
Loading

0 comments on commit 8c2ae92

Please sign in to comment.