Skip to content

Commit

Permalink
feat(SourceParser): add url property (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
RealShadowNova committed Sep 2, 2022
1 parent 04ea9bf commit af2a828
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/lib/structures/misc/SourceParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ export class SourceParser {
*/
public readonly path: string;

/**
* The url of this source.
* @since 2.4.0
*/
public readonly url: string | null;

public constructor(data: SourceParser.Data, project: ProjectParser) {
const { line, file, path } = data;
const { line, file, path, url } = data;

this.line = line;
this.file = file;
this.path = path;
this.url = url;

this.project = project;
}
Expand All @@ -50,7 +57,8 @@ export class SourceParser {
return {
line: this.line,
file: this.file,
path: this.path
path: this.path,
url: this.url
};
}

Expand All @@ -62,26 +70,28 @@ export class SourceParser {
* @returns The generated parser.
*/
public static generateFromTypeDoc(reflection: JSONOutput.SourceReference, project: ProjectParser): SourceParser {
const { line, fileName } = reflection;
const { line, fileName, url } = reflection;

return new SourceParser(
{
line,
file: basename(fileName),
path: dirname(fileName)
path: dirname(fileName),
url: url ?? null
},
project
);
}

public static generateFromJSON(json: SourceParser.JSON, project: ProjectParser): SourceParser {
const { line, file, path } = json;
const { line, file, path, url } = json;

return new SourceParser(
{
line,
file,
path
path,
url
},
project
);
Expand All @@ -107,6 +117,12 @@ export namespace SourceParser {
* @since 1.0.0
*/
path: string;

/**
* The url of this source.
* @since 2.4.0
*/
url: string | null;
}

export interface JSON {
Expand All @@ -127,5 +143,11 @@ export namespace SourceParser {
* @since 1.0.0
*/
path: string;

/**
* The url of this source.
* @since 2.4.0
*/
url: string | null;
}
}

0 comments on commit af2a828

Please sign in to comment.