Skip to content

Commit

Permalink
Improve and fill out the inline documentation.
Browse files Browse the repository at this point in the history
We also just refer to the global names for objects in ast-types.
  • Loading branch information
eventualbuddha committed Aug 27, 2014
1 parent e56c469 commit 2821b68
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 115 deletions.
18 changes: 18 additions & 0 deletions lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,22 @@ Container.prototype.getCachedModule = function(resolvedPath) {
return this.modules[resolvedPath];
};

/**
* Writes the contents of this container to the given path.
*
* @param {string} target
*/
Container.prototype.write = function(target) {
var files = this.convert();
var writer = new Writer(target);
writer.write(files);
};

/**
* Converts the contents of this container using the current formatter.
*
* @returns {File[]}
*/
Container.prototype.convert = function() {
if (this.formatter.beforeConvert) {
this.formatter.beforeConvert(this);
Expand All @@ -149,6 +159,9 @@ Container.prototype.convert = function() {
return formatter.build(modules);
};

/**
* Follows all imports/exports looking for new modules to add to this container.
*/
Container.prototype.findImportedModules = function() {
var knownModules;
var lastModuleCount = 0;
Expand All @@ -164,6 +177,11 @@ Container.prototype.findImportedModules = function() {
}
};

/**
* Gets the modules in this container in no particular order.
*
* @returns {Module[]}
*/
Container.prototype.getModules = function() {
var modules = this.modules;
return Object.keys(modules).map(function(key) {
Expand Down
10 changes: 5 additions & 5 deletions lib/declaration_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ var n = types.namedTypes;
* Then `identifier` references the `add` node, the declaration's `id`.
*
* @constructor
* @param {ast-types.Node} declaration
* @param {ast-types.Identifier} identifier
* @param {Node} declaration
* @param {Identifier} identifier
*/
function DeclarationInfo(declaration, identifier) {
/**
* @type {ast-types.Node}
* @type {Node}
* @property declaration
*/
this.declaration = declaration;
/**
* @type {ast-types.Identifier}
* @type {Identifier}
* @property identifier
*/
this.identifier = identifier;
Expand All @@ -40,7 +40,7 @@ function DeclarationInfo(declaration, identifier) {
* Get the declaration info for the given identifier path, if the identifier is
* actually part of a declaration.
*
* @param {ast-types.NodePath} identifierPath
* @param {NodePath} identifierPath
* @return {?DeclarationInfo}
*/
DeclarationInfo.forIdentifierPath = function(identifierPath) {
Expand Down
26 changes: 13 additions & 13 deletions lib/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extend(ExportDeclarationList, ModuleBindingList);

/**
* @private
* @param {ast-types.Node} node
* @param {Node} node
* @return {boolean}
*/
ExportDeclarationList.prototype.isMatchingBinding = function(node) {
Expand All @@ -40,7 +40,7 @@ ExportDeclarationList.prototype.isMatchingBinding = function(node) {
* Gets an export declaration for the given `node`.
*
* @private
* @param {ast-types.ExportDeclaration} node
* @param {ExportDeclaration} node
* @return {Import}
*/
ExportDeclarationList.prototype.declarationForNode = function(node) {
Expand All @@ -61,7 +61,7 @@ ExportDeclarationList.prototype.declarationForNode = function(node) {
};

/**
* @param {ast-types.NodePath} referencePath
* @param {NodePath} referencePath
* @return {?ExportSpecifier}
*/
ExportDeclarationList.prototype.findSpecifierForReference = function(referencePath) {
Expand Down Expand Up @@ -91,7 +91,7 @@ ExportDeclarationList.prototype.findSpecifierForReference = function(referencePa
* @abstract
* @extends ModuleBindingDeclaration
* @param {Module} mod
* @param {ast-types.ExportDeclaration} node
* @param {ExportDeclaration} node
*/
function ExportDeclaration(mod, node) {
assert.ok(
Expand Down Expand Up @@ -125,7 +125,7 @@ ExportDeclaration.prototype.toString = ExportDeclaration.prototype.inspect;
* @constructor
* @extends ExportDeclaration
* @param {Module} mod
* @param {ast-types.ExportDeclaration} node
* @param {ExportDeclaration} node
*/
function DefaultExportDeclaration(mod, node) {
ExportDeclaration.call(this, mod, node);
Expand All @@ -135,7 +135,7 @@ extend(DefaultExportDeclaration, ExportDeclaration);
/**
* Contains a list of specifier name information for this export.
*
* @type {Array.<ExportSpecifier>}
* @type {ExportSpecifier[]}
* @property specifiers
*/
memo(DefaultExportDeclaration.prototype, 'specifiers', function() {
Expand All @@ -151,7 +151,7 @@ memo(DefaultExportDeclaration.prototype, 'specifiers', function() {
* @constructor
* @extends ExportDeclaration
* @param {Module} mod
* @param {ast-types.ExportDeclaration} node
* @param {ExportDeclaration} node
*/
function NamedExportDeclaration(mod, node) {
ExportDeclaration.call(this, mod, node);
Expand All @@ -161,7 +161,7 @@ extend(NamedExportDeclaration, ExportDeclaration);
/**
* Contains a list of specifier name information for this export.
*
* @type {Array.<ExportSpecifier>}
* @type {ExportSpecifier[]}
* @property specifiers
*/
memo(NamedExportDeclaration.prototype, 'specifiers', function() {
Expand All @@ -179,7 +179,7 @@ memo(NamedExportDeclaration.prototype, 'specifiers', function() {
* @constructor
* @extends ExportDeclaration
* @param {Module} mod
* @param {ast-types.ExportDeclaration} node
* @param {ExportDeclaration} node
*/
function VariableExportDeclaration(mod, node) {
ExportDeclaration.call(this, mod, node);
Expand All @@ -203,7 +203,7 @@ memo(VariableExportDeclaration.prototype, 'specifiers', function() {
* @constructor
* @extends ExportDeclaration
* @param {Module} mod
* @param {ast-types.ExportDeclaration} node
* @param {ExportDeclaration} node
*/
function FunctionExportDeclaration(mod, node) {
ExportDeclaration.call(this, mod, node);
Expand All @@ -222,7 +222,7 @@ memo(FunctionExportDeclaration.prototype, 'specifiers', function() {
* @constructor
* @extends ModuleBindingSpecifier
* @param {ExportDeclaration} declaration
* @param {ast-types.ExportSpecifier} node
* @param {ExportSpecifier} node
*/
function ExportSpecifier(declaration, node) {
ModuleBindingSpecifier.call(this, declaration, node);
Expand Down Expand Up @@ -277,7 +277,7 @@ memo(ExportSpecifier.prototype, 'moduleDeclaration', function() {
* @constructor
* @extends ExportSpecifier
* @param {ExportDeclaration} declaration
* @param {ast-types.ExportSpecifier} node
* @param {ExportSpecifier} node
*/
function DefaultExportSpecifier(declaration, node) {
ExportSpecifier.call(this, declaration, node);
Expand All @@ -295,7 +295,7 @@ DefaultExportSpecifier.prototype.name = 'default';
/**
* Default export specifiers do not bind to a local identifier.
*
* @type {?ast-types.Identifier}
* @type {?Identifier}
* @property identifier
*/
DefaultExportSpecifier.prototype.identifier = null;
Expand Down
Loading

0 comments on commit 2821b68

Please sign in to comment.