-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9a7567
commit 552a969
Showing
8 changed files
with
127 additions
and
71 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
define(function (require) { | ||
|
||
var assert = require("assert"); | ||
var traverse = require("./traverse"); | ||
|
||
var visitDecl = function visitDecl(decl) { | ||
assert.ok(decl.doclet, "expected doclet"); | ||
/* Decls that are mentioned but never documented, e.g. a class | ||
* prototype, will have no location information. */ | ||
var file = decl.doclet.loc.file; | ||
if (file) file.decls.push(decl); | ||
}; | ||
|
||
var copyToFileVisitor = { | ||
visitDecl : visitDecl, | ||
visitScope : visitDecl | ||
}; | ||
|
||
var copyDeclsToFiles = function copyDeclsToFiles(symtab) { | ||
traverse(symtab.globalScope, copyToFileVisitor); | ||
}; | ||
|
||
return copyDeclsToFiles; | ||
|
||
}); | ||
|
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,24 @@ | ||
define(function (require) { | ||
|
||
var assert = require("assert"); | ||
var traverse = require("./traverse"); | ||
|
||
var markConstructorVisitor = { | ||
visitScope : function (scope) { | ||
/** Any scope with a prototype must be a constructor. */ | ||
if (scope.decls.hasOwnProperty("prototype") || scope.classDoclet) { | ||
scope.doclet.setKind("constructor"); | ||
} | ||
} | ||
}; | ||
|
||
var markConstructors = function markConstructors(symtab) { | ||
assert.ok(!symtab.globalScope.decls.prototype, | ||
"do not change the prototype of the global object"); | ||
traverse(symtab.globalScope, markConstructorVisitor); | ||
}; | ||
|
||
return markConstructors; | ||
|
||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
define(function (require) { | ||
|
||
var markdown = require("markdown").markdown; | ||
var traverse = require("./traverse"); | ||
|
||
var markdownifyDoclet = function markdownifyDoclet(doclet) { | ||
/* TODO: Resolve references. */ | ||
doclet.markdown = markdown.toHTML(doclet.description); | ||
}; | ||
|
||
var markdownifyVisitor = { | ||
visitDecl : function visitDecl(decl) { | ||
markdownifyDoclet(decl.doclet); | ||
}, | ||
visitScope : function visitScope(scope) { | ||
this.visitDecl(scope); | ||
if (scope.classDoclet) markdownifyDoclet(scope.classDoclet); | ||
} | ||
}; | ||
|
||
var markdownify = function markdownify(symtab) { | ||
/* TODO: Files. */ | ||
traverse(symtab.globalScope, markdownifyVisitor); | ||
}; | ||
|
||
return markdownify; | ||
|
||
}); | ||
|
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,36 @@ | ||
define(function (require) { | ||
|
||
var assert = require("assert"); | ||
var Scope = require("../ast/scope"); | ||
|
||
var defaultVisitor = { | ||
visitDecl : function () {}, | ||
visitScope : function () {} | ||
}; | ||
|
||
var traverse = function traverse(scope, visitor) { | ||
Object.keys(defaultVisitor).forEach(function (key) { | ||
if (!visitor[key]) visitor[key] = defaultVisitor[key]; | ||
}); | ||
|
||
traverseScope(scope, visitor); | ||
}; | ||
|
||
var traverseScope = function traverseScope(scope, visitor) { | ||
visitor.visitScope(scope); | ||
|
||
Object.keys(scope.decls).forEach(function (name) { | ||
var decl = scope.decls[name]; | ||
if (decl instanceof Scope) { | ||
traverseScope(decl, visitor); | ||
} else { | ||
assert.ok(decl instanceof Decl, "expected only declarations"); | ||
visitor.visitDecl(decl); | ||
} | ||
}); | ||
}; | ||
|
||
return traverse; | ||
|
||
}); | ||
|
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