From 0b5b89e91b07a9e86740f3742c8a2ba225821b56 Mon Sep 17 00:00:00 2001 From: Starcea Date: Fri, 28 Jun 2024 00:34:27 +0900 Subject: [PATCH] fix: add docstrings --- src/client.ts | 3 +++ src/constants.ts | 1 + src/models/Timetable.ts | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/src/client.ts b/src/client.ts index d74bc5f..11e1072 100644 --- a/src/client.ts +++ b/src/client.ts @@ -18,6 +18,7 @@ export default class Comcigan { private readonly dataManager = new DataManager(this.rest) + /** 학교를 검색합니다. */ async searchSchools(schoolName: string): Promise { const { mainRoute, searchRoute } = await this.dataManager.getData() const res = await this.rest.get( @@ -34,6 +35,7 @@ export default class Comcigan { })) } + /** 학교 코드를 이용해 학교 시간표를 불러옵니다. */ async getRawTimetable(schoolCode: number): Promise { const { mainRoute, timetableRoute, teacherCode, dayCode, subjectCode } = await this.dataManager.getData() @@ -62,6 +64,7 @@ export default class Comcigan { ) } + /** 학교 코드를 이용해 학교 시간표를 불러오고, `TimetableManager`로 변환해 사용할 수 있는 형태로 제공합니다. */ async getTimetable(schoolCode: number) { return new TimetableManager(await this.getRawTimetable(schoolCode)) } diff --git a/src/constants.ts b/src/constants.ts index 203b384..42cefb5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -13,6 +13,7 @@ export const RegExes = { WhiteSpace: /\0+$/, } +/** 요일 */ export enum Weekday { Monday = 1, Tuesday, diff --git a/src/models/Timetable.ts b/src/models/Timetable.ts index 473011e..5fb043e 100644 --- a/src/models/Timetable.ts +++ b/src/models/Timetable.ts @@ -1,23 +1,29 @@ export interface Timetable { + /** 과목 */ subject: string + /** 교사 */ teacher: string } export class TimetableManager { constructor(private readonly timetables: Timetable[][][][]) {} + /** 특정 학년의 시간표를 가져옵니다. */ getByGrade(grade: number) { return this.timetables[grade - 1] } + /** 특정 반의 시간표를 가져옵니다. */ getByClass(grade: number, cls: number) { return this.timetables[grade - 1][cls - 1] } + /** 특정 반의 특정 요일 시간표를 가져옵니다. */ getByDay(grade: number, cls: number, day: number) { return this.timetables[grade - 1][cls - 1][day - 1] } + /** 특정 반의 특정 요일의 특정 교시 시간표를 가져옵니다. */ getByPeriod(grade: number, cls: number, day: number, period: number) { return this.timetables[grade - 1][cls - 1][day - 1][period - 1] }