Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge 2a51d31 into 19cd491
Browse files Browse the repository at this point in the history
  • Loading branch information
jhm-ciberman committed Jan 4, 2019
2 parents 19cd491 + 2a51d31 commit 450a9aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 47 deletions.
30 changes: 0 additions & 30 deletions src/_definitions/comment-parser.d.ts

This file was deleted.

35 changes: 18 additions & 17 deletions src/parser/JSDocParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import { TYPES } from "../types";
import DocScriptFactory from "./DocScriptFactory";
import IJSDocParser from "./interfaces/IJSDocParser";

interface ICommentParserTag {
tag: string;
name: string;
optional: boolean;
type: string;
description: string;
line: number;
source: string;
}

/**
* Class for parsing the GML scripts and JSDocs comments inside those scripts
*/
Expand Down Expand Up @@ -36,33 +46,24 @@ export default class JSDocParser implements IJSDocParser {
const factory = new DocScriptFactory(name, parsingConfig.mergeDuplicateParams);

for (const comment of comments) {
this._parseComment(name, factory, comment, parsingConfig.warnUnrecognizedTags);
if (comment.description) {
factory.setDescription(comment.description);
}
for (const tag of comment.tags) {
this._parseTag(factory, tag, name, parsingConfig.warnUnrecognizedTags);
}
}

return factory.make();
}

private _parseComment(
name: string,
factory: DocScriptFactory,
comment: CommentParser.Comment,
warnUnrecognizedTags: boolean,
) {
if (comment.description) {
factory.setDescription(comment.description);
}
for (const tag of comment.tags) {
this._parseTag(factory, tag, name, warnUnrecognizedTags);
}
}

/**
* Parse a single tag and add the tag to the DocScriptFactory
* @param factory The factory to add the tag to
* @param tag The tag to add
* @param name The name of the script to add the tag to
*/
private _parseTag(factory: DocScriptFactory, tag: CommentParser.Tag, name: string, warnUnrecognizedTags: boolean) {
private _parseTag(factory: DocScriptFactory, tag: ICommentParserTag, name: string, warnUnrecognizedTags: boolean) {
switch (tag.tag.toLowerCase()) {
case "param":
case "arg":
Expand Down Expand Up @@ -113,7 +114,7 @@ export default class JSDocParser implements IJSDocParser {
* tag.
* @param tag The tag to reconstruct
*/
private _reconstructTag(tag: CommentParser.Tag): string {
private _reconstructTag(tag: ICommentParserTag): string {
// TODO: reconstruct tag from tag.source.
const strArr = [];
if (tag.type) {
Expand Down

0 comments on commit 450a9aa

Please sign in to comment.