Skip to content

Commit

Permalink
use enum value for global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
hegemonic committed Oct 11, 2014
1 parent f77984d commit bb8a662
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/jsdoc/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ exports.resolve = function(doclet) {
doclet.setLongname(about.longname);
}

if (doclet.scope === 'global') { // via @global tag?
if (doclet.scope === SCOPE.NAMES.GLOBAL) { // via @global tag?
doclet.setLongname(doclet.name);
delete doclet.memberof;
}
else if (about.scope) {
if (about.memberof === LONGNAMES.GLOBAL) { // via @memberof <global> ?
doclet.scope = 'global';
doclet.scope = SCOPE.NAMES.GLOBAL;
}
else {
doclet.scope = puncToScope[about.scope];
Expand Down
7 changes: 4 additions & 3 deletions lib/jsdoc/src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var jsdoc = {
var util = require('util');

var currentModule = null;
var SCOPE_NAMES = jsdoc.name.SCOPE.NAMES;
var SCOPE_PUNC = jsdoc.name.SCOPE.PUNC;
var unresolvedName = /^((?:module.)?exports|this)(\.|$)/;

Expand Down Expand Up @@ -96,7 +97,7 @@ function setModuleScopeMemberOf(doclet) {

// if the doclet isn't a memberof anything yet, and it's not a global, it must be a memberof
// the current module
if (!doclet.memberof && doclet.scope !== 'global') {
if (!doclet.memberof && doclet.scope !== SCOPE_NAMES.GLOBAL) {
doclet.addTag('memberof', currentModule.longname);
}
}
Expand All @@ -105,7 +106,7 @@ function setModuleScopeMemberOf(doclet) {
function setDefaultScope(doclet) {
// module doclets don't get a default scope
if (!doclet.scope && doclet.kind !== 'module') {
doclet.setScope('global');
doclet.setScope(SCOPE_NAMES.GLOBAL);
}
}

Expand Down Expand Up @@ -266,7 +267,7 @@ function newSymbolDoclet(parser, docletSrc, e) {
// set the scope to global unless a) the doclet is a memberof something or b) we're in a module
// that exports only this symbol
if ( !newDoclet.memberof && (!currentModule || currentModule.longname !== newDoclet.name) ) {
newDoclet.scope = 'global';
newDoclet.scope = SCOPE_NAMES.GLOBAL;
}

addDoclet(parser, newDoclet);
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdoc/tag/dictionary/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ var baseTags = exports.baseTags = {
global: {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.scope = 'global';
doclet.scope = jsdoc.name.SCOPE.NAMES.GLOBAL;
delete doclet.memberof;
}
},
Expand Down
6 changes: 3 additions & 3 deletions lib/jsdoc/util/templateHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ exports.setTutorials = function(root) {
tutorials = root;
};

exports.globalName = 'global';
exports.globalName = name.SCOPE.NAMES.GLOBAL;
exports.fileExtension = '.html';
exports.scopeToPunc = require('jsdoc/name').scopeToPunc;
exports.scopeToPunc = name.scopeToPunc;

function getNamespace(kind) {
if (dictionary.isNamespace(kind)) {
Expand Down Expand Up @@ -554,7 +554,7 @@ exports.getAttribs = function(d) {
attribs.push(d.access);
}

if (d.scope && d.scope !== 'instance' && d.scope !== 'global') {
if (d.scope && d.scope !== 'instance' && d.scope !== name.SCOPE.NAMES.GLOBAL) {
if (d.kind === 'function' || d.kind === 'member' || d.kind === 'constant') {
attribs.push(d.scope);
}
Expand Down

0 comments on commit bb8a662

Please sign in to comment.