This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All existing test decoupled and passing
- Loading branch information
1 parent
17d945a
commit 9957e95
Showing
26 changed files
with
349 additions
and
364 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { inject, injectable } from "inversify"; | ||
import { TYPES } from "../../types"; | ||
|
||
import * as fse from "fs-extra"; | ||
import * as path from "path"; | ||
|
||
import IProjectConfig from "../config/interfaces/IProjectConfig"; | ||
import DocScript from "../doc_models/DocScript"; | ||
import IGMProject from "../gm_project/interfaces/IGMProject"; | ||
import IGMScript from "../gm_project/interfaces/IGMScript"; | ||
import IDocumentationExtractor from "./interfaces/IDocumentationExtractor"; | ||
import IScriptLoader from "./interfaces/IScriptLoader"; | ||
|
||
/** | ||
* This class loads a GMScript and extracts the documentation for it | ||
*/ | ||
@injectable() | ||
export default class ScriptLoader implements IScriptLoader { | ||
|
||
/** | ||
* The documentationExtractor used to extract the documentation of the GMScripts | ||
*/ | ||
@inject(TYPES.IDocumentationExtractor) | ||
private _extractor: IDocumentationExtractor; | ||
|
||
/** | ||
* Loads a single GMScript with all the subscripts from disk and extracts | ||
* the documentation from it. It can return an empty array if the gmScript is not included in the | ||
* glob pattern inside the project config. | ||
*/ | ||
public async load(gmScript: IGMScript, config: IProjectConfig, gmProject: IGMProject): Promise<DocScript[]> { | ||
if (!gmScript.match(config.output.pattern)) { | ||
return []; | ||
} | ||
const pathStr = path.resolve(gmProject.path, gmScript.filepath); | ||
let str; | ||
try { | ||
str = await fse.readFile(pathStr, "utf8"); | ||
} catch (e) { | ||
throw new Error(`Error loading file ${pathStr}`); | ||
} | ||
const it = gmScript.subScripts(str); | ||
return this._extractor.extractDocScripts(it, config.scripts, config.warnUnrecognizedTags); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import IGMScript from "../../gm_project/interfaces/IGMScript"; | ||
import IProjectConfig from "../../config/interfaces/IProjectConfig"; | ||
import IGMProject from "../../gm_project/interfaces/IGMProject"; | ||
import DocScript from "../../doc_models/DocScript"; | ||
|
||
export default interface IScriptLoader { | ||
load(gmScript: IGMScript, config: IProjectConfig, gmProject: IGMProject): Promise<DocScript[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* This class represents a subscript | ||
*/ | ||
export default class GMSubscript { | ||
/** | ||
* The subscript name | ||
*/ | ||
public readonly name: string; | ||
|
||
/** | ||
* The subscript gml text | ||
*/ | ||
public readonly text: string; | ||
|
||
/** | ||
* Creates an instance of GMSubscript. | ||
* @param {string} name The subscript name | ||
* @param {string} text The subscript gml text | ||
* @memberof GMSubscript | ||
*/ | ||
constructor(name: string, text: string) { | ||
this.name = name; | ||
this.text = text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.