Skip to content

Commit 12ec2d4

Browse files
committed
add missing jsdocs
1 parent 268a1a6 commit 12ec2d4

File tree

5 files changed

+291
-45
lines changed

5 files changed

+291
-45
lines changed

src/command/init.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import inquirer from 'inquirer';
66
import { join } from 'path';
77
import { log } from '../log.js';
88

9+
/**
10+
* An interface containing data collected from init command inquiry.
11+
* @author efekos
12+
* @version 1.0.0
13+
* @since 0.0.1-alpha
14+
*/
915
export interface InitContext {
1016
name: string;
1117
description: string;

src/compiler/compiler.ts

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,42 @@ export class SyntaxScriptCompiler {
1919

2020
public readonly exportData: Record<string, AnyExportable[]> = {};
2121

22+
/**
23+
* Constructs a new compiler.
24+
* @param rootDir Root dir to search for source files.
25+
* @param outDir Out dir to write compiled files.
26+
* @param format File format to compile.
27+
* @param watch Whether is it watch mode or not. Will affect how errors are handled.
28+
* @author efekos
29+
* @version 1.0.0
30+
* @since 0.0.1-alpha
31+
*/
2232
constructor(rootDir: string, outDir: string, format: string, watch: boolean = false) {
2333
this.rootDir = join(process.cwd(), rootDir);
2434
this.outDir = join(process.cwd(), outDir);
2535
this.mainFileFormat = format;
2636
this.watchMode = watch;
2737
}
2838

39+
/**
40+
* Parses .syx files and compiles .sys files using them.
41+
* @author efekos
42+
* @since 0.0.1-alpha
43+
* @version 1.0.0
44+
*/
2945
public async compile() {
30-
3146
await this.compileSyxFiles(this.rootDir);
3247
await this.compileSysFiles(this.rootDir);
3348
return Promise.resolve();
3449
}
3550

51+
/**
52+
* Compiles every .syx file found in the path.
53+
* @param folderPath A folder path to search for .syx files.
54+
* @author efekos
55+
* @version 1.0.0
56+
* @since 0.0.1-alpha
57+
*/
3658
public compileSyxFiles(folderPath: string) {
3759

3860
const files = readdirSync(folderPath);
@@ -44,6 +66,13 @@ export class SyntaxScriptCompiler {
4466
});
4567
}
4668

69+
/**
70+
* Compiles one .syx file from the path given.
71+
* @param file Path to a file to compile.
72+
* @author efekos
73+
* @version 1.0.0
74+
* @since 0.0.1-alpha
75+
*/
4776
public compileSyx(file: string) {
4877
const ast = syxparser.parseTokens(tokenizeSyx(readFileSync(file).toString(), this.watchMode), this.watchMode);
4978
const out: AnyExportable[] = [];
@@ -151,6 +180,13 @@ export class SyntaxScriptCompiler {
151180
this.exportData[file] = out;
152181
}
153182

183+
/**
184+
* Compiles every .sys file found in the given folder.
185+
* @param folderPath Folder path to search for .sys files.
186+
* @author efekos
187+
* @version 1.0.0
188+
* @since 0.0.1-alpha
189+
*/
154190
public compileSysFiles(folderPath: string) {
155191
const files = readdirSync(folderPath);
156192
log.debug('HEREHEREHERE', folderPath, files);
@@ -161,6 +197,13 @@ export class SyntaxScriptCompiler {
161197
});
162198
}
163199

200+
/**
201+
* Compiles a .sys file at the path given.
202+
* @param file Path to the .sys file to compile.
203+
* @author efekos
204+
* @since 0.0.1-alpha
205+
* @version 1.0.0
206+
*/
164207
public compileSys(file: string) {
165208
const ast = sysparser.parseTokens(tokenizeSys(readFileSync(file).toString()), this.watchMode);
166209

@@ -216,23 +259,60 @@ export class SyntaxScriptCompiler {
216259

217260
}
218261

262+
/**
263+
* Type of something that can be exported.
264+
* @version 1.0.0
265+
* @since 0.0.1-alpha
266+
* @author efekos
267+
*/
219268
export enum ExportType {
269+
270+
/**
271+
* Used for exported operators.
272+
*/
220273
Operator,
274+
275+
/**
276+
* Used for exported functions.
277+
*/
221278
Function,
279+
280+
/**
281+
* Used for exported keyword.
282+
*/
222283
Keyword
284+
223285
}
224286

287+
/**
288+
* Base exportable interface.
289+
* @author efekos
290+
* @version 1.0.0
291+
* @since 0.0.1-alpha
292+
*/
225293
export interface Export {
226294
type: ExportType;
227295
}
228296

297+
/**
298+
* Represents an exported operator. Uses type {@link ExportType.Operator}.
299+
* @author efekos
300+
* @version 1.0.0
301+
* @since 0.0.1-alpha
302+
*/
229303
export interface Operator extends Export {
230304
type: ExportType.Operator,
231305
regexMatcher: RegExp;
232306
outputGenerators: Record<string, OneParameterMethod<string, string>>;
233307
imports: Record<string, string>;
234308
}
235309

310+
/**
311+
* Represents an exported function. Uses type {@link ExportType.Function}.
312+
* @author efekos
313+
* @version 1.0.0
314+
* @since 0.0.1-alpha
315+
*/
236316
export interface Function extends Export {
237317
type: ExportType.Function;
238318
name: string;
@@ -241,14 +321,36 @@ export interface Function extends Export {
241321
imports: Record<string, string>;
242322
}
243323

324+
/**
325+
* Represents an exported keyword. Uses type {@link ExportType.Keyword}.
326+
* @author efekos
327+
* @version 1.0.0
328+
* @since 0.0.1-alpha
329+
*/
244330
export interface Keyword extends Export {
245331
type: ExportType.Keyword;
246332
word: string;
247333
}
248334

335+
/**
336+
* A method that has one parameter with the type {@link V} and returns {@link R}.
337+
* @author efekos
338+
* @version 1.0.0
339+
* @since 0.0.1-alpha
340+
*/
249341
export type OneParameterMethod<V, R> = (v: V) => R;
342+
343+
/**
344+
* A method that takes no parameters and returns an {@link R}.
345+
* @author efekos
346+
* @version 1.0.0
347+
* @since 0.0.1-alpha
348+
*/
250349
export type ReturnerMethod<R> = () => R;
251350

351+
/**
352+
* Any interface that represents something exportable.
353+
*/
252354
export type AnyExportable = Operator | Function | Keyword;
253355

254356
export const regexes: Record<string, RegExp> = {

0 commit comments

Comments
 (0)