mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
New Parser
This commit is contained in:
parent
d852108154
commit
ca01ed332d
3 changed files with 37 additions and 19 deletions
|
@ -36,9 +36,9 @@ class Parser {
|
|||
return result;
|
||||
}
|
||||
parseObjects(docs) {
|
||||
console.log('Parse Objects');
|
||||
for (let i = 0; i < docs.length; i++) {
|
||||
let doclet = docs[i];
|
||||
// TODO: Custom temporary rules
|
||||
switch (doclet.longname) {
|
||||
case 'Phaser.GameObjects.Components.Alpha':
|
||||
case 'Phaser.GameObjects.Components.AlphaSingle':
|
||||
|
@ -61,7 +61,6 @@ class Parser {
|
|||
case 'Phaser.GameObjects.Components.ToJSON':
|
||||
case 'Phaser.GameObjects.Components.Transform':
|
||||
case 'Phaser.GameObjects.Components.Visible':
|
||||
case 'Phaser.Renderer.WebGL.Pipelines.ModelViewProjection':
|
||||
doclet.kind = 'mixin';
|
||||
break;
|
||||
// Because, sod you TypeScript
|
||||
|
@ -82,6 +81,7 @@ class Parser {
|
|||
if ((doclet.longname.indexOf('Phaser.Physics.Arcade.Components.') == 0 || doclet.longname.indexOf('Phaser.Physics.Impact.Components.') == 0 || doclet.longname.indexOf('Phaser.Physics.Matter.Components.') == 0) && doclet.longname.indexOf('#') == -1) {
|
||||
doclet.kind = 'mixin';
|
||||
}
|
||||
console.log(`Name: ${doclet.longname} - Kind: ${doclet.kind}`);
|
||||
let obj;
|
||||
let container = this.objects;
|
||||
switch (doclet.kind) {
|
||||
|
@ -131,11 +131,11 @@ class Parser {
|
|||
}
|
||||
}
|
||||
resolveObjects(docs) {
|
||||
console.log('Parse Objects');
|
||||
let allTypes = new Set();
|
||||
for (let doclet of docs) {
|
||||
let obj = doclet.kind === 'namespace' ? this.namespaces[doclet.longname] : this.objects[doclet.longname];
|
||||
if (!obj) {
|
||||
// TODO
|
||||
console.log(`Warning: Didn't find object for ${doclet.longname}`);
|
||||
continue;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class Parser {
|
|||
let parent = isNamespaceMember ? this.namespaces[doclet.memberof] : (this.objects[doclet.memberof] || this.namespaces[doclet.memberof]);
|
||||
//TODO: this whole section should be removed once stable
|
||||
if (!parent) {
|
||||
console.log(`${doclet.longname} in ${doclet.meta.filename}@${doclet.meta.lineno} has parent '${doclet.memberof}' that is not defined.`);
|
||||
console.log(`***-> ${doclet.longname} in ${doclet.meta.filename}@${doclet.meta.lineno} has parent '${doclet.memberof}' that is not defined.`);
|
||||
let parts = doclet.memberof.split('.');
|
||||
let newParts = [parts.pop()];
|
||||
while (parts.length > 0 && this.objects[parts.join('.')] == null)
|
||||
|
@ -351,7 +351,7 @@ class Parser {
|
|||
// TODO REMOVE TEMP FIX
|
||||
if (!paramDoc.name) {
|
||||
console.log(`Docs Error in '${doclet.longname}' in ${doclet.meta.filename}@${doclet.meta.lineno}`);
|
||||
console.log(paramDoc.description);
|
||||
console.info(paramDoc);
|
||||
}
|
||||
if (paramDoc.name.indexOf('.') != -1) {
|
||||
console.log(`Warning: ignoring param with '.' for '${doclet.longname}' in ${doclet.meta.filename}@${doclet.meta.lineno}`);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -31,7 +31,9 @@ export class Parser {
|
|||
|
||||
// add declare module
|
||||
const phaserPkgModuleDOM = dom.create.module('phaser');
|
||||
|
||||
phaserPkgModuleDOM.members.push(dom.create.exportEquals('Phaser'));
|
||||
|
||||
this.topLevel.push(phaserPkgModuleDOM);
|
||||
}
|
||||
|
||||
|
@ -55,11 +57,13 @@ export class Parser {
|
|||
}
|
||||
|
||||
private parseObjects(docs: any[]) {
|
||||
|
||||
console.log('Parse Objects');
|
||||
|
||||
for (let i = 0; i < docs.length; i++) {
|
||||
|
||||
let doclet = docs[i];
|
||||
|
||||
// TODO: Custom temporary rules
|
||||
switch (doclet.longname)
|
||||
{
|
||||
case 'Phaser.GameObjects.Components.Alpha':
|
||||
|
@ -83,7 +87,6 @@ export class Parser {
|
|||
case 'Phaser.GameObjects.Components.ToJSON':
|
||||
case 'Phaser.GameObjects.Components.Transform':
|
||||
case 'Phaser.GameObjects.Components.Visible':
|
||||
case 'Phaser.Renderer.WebGL.Pipelines.ModelViewProjection':
|
||||
doclet.kind = 'mixin';
|
||||
break;
|
||||
|
||||
|
@ -108,6 +111,8 @@ export class Parser {
|
|||
doclet.kind = 'mixin';
|
||||
}
|
||||
|
||||
console.log(`Name: ${doclet.longname} - Kind: ${doclet.kind}`);
|
||||
|
||||
let obj: dom.DeclarationBase;
|
||||
let container = this.objects;
|
||||
|
||||
|
@ -144,14 +149,19 @@ export class Parser {
|
|||
break;
|
||||
}
|
||||
|
||||
if (obj) {
|
||||
if (container[doclet.longname]) {
|
||||
if (obj)
|
||||
{
|
||||
if (container[doclet.longname])
|
||||
{
|
||||
console.log('Warning: ignoring duplicate doc name: ' + doclet.longname);
|
||||
docs.splice(i--, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
container[doclet.longname] = obj;
|
||||
if (doclet.description) {
|
||||
|
||||
if (doclet.description)
|
||||
{
|
||||
let otherDocs = obj.jsDocComment || '';
|
||||
obj.jsDocComment = doclet.description.replace(regexEndLine, '$1\n') + otherDocs;
|
||||
}
|
||||
|
@ -159,28 +169,36 @@ export class Parser {
|
|||
}
|
||||
}
|
||||
|
||||
private resolveObjects(docs: any[]) {
|
||||
private resolveObjects(docs: any[])
|
||||
{
|
||||
console.log('Parse Objects');
|
||||
|
||||
let allTypes = new Set<string>();
|
||||
for (let doclet of docs) {
|
||||
|
||||
for (let doclet of docs)
|
||||
{
|
||||
let obj = doclet.kind === 'namespace' ? this.namespaces[doclet.longname] : this.objects[doclet.longname];
|
||||
|
||||
if (!obj) {
|
||||
|
||||
// TODO
|
||||
if (!obj)
|
||||
{
|
||||
console.log(`Warning: Didn't find object for ${doclet.longname}`);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!doclet.memberof) {
|
||||
if (!doclet.memberof)
|
||||
{
|
||||
this.topLevel.push(obj as dom.TopLevelDeclaration);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
let isNamespaceMember = doclet.kind === 'class' || doclet.kind === 'typedef' || doclet.kind == 'namespace' || doclet.isEnum;
|
||||
|
||||
let parent = isNamespaceMember ? this.namespaces[doclet.memberof] : (this.objects[doclet.memberof] || this.namespaces[doclet.memberof]);
|
||||
|
||||
//TODO: this whole section should be removed once stable
|
||||
if (!parent) {
|
||||
console.log(`${doclet.longname} in ${doclet.meta.filename}@${doclet.meta.lineno} has parent '${doclet.memberof}' that is not defined.`);
|
||||
console.log(`***-> ${doclet.longname} in ${doclet.meta.filename}@${doclet.meta.lineno} has parent '${doclet.memberof}' that is not defined.`);
|
||||
let parts: string[] = doclet.memberof.split('.');
|
||||
let newParts = [parts.pop()];
|
||||
while (parts.length > 0 && this.objects[parts.join('.')] == null) newParts.unshift(parts.pop());
|
||||
|
|
Loading…
Reference in a new issue