bitovi / documentjs

The sophisticated documentation engine
https://documentjs.com/
MIT License
598 stars 381 forks source link

`@alias` tag generates malformed signature #222

Open rjgotten opened 9 years ago

rjgotten commented 9 years ago

When using the @alias tag to swap the presented name for a type, the generator fails to add a period in the aliased portion of the display name generated for @signature.

E.g.

/** @alias Buggy */
var foo = {
  /** @signature */
  bar : function() { }
}

will generate a signature buggyname() instead of buggy.name().


The problem originates from lines 788-794 of make_default_helpers, where a trailing period is appended to the original name as part of the lastPartOfName fix-up. That fix-up is erroneously skipped in its entirety for document objects that carry an alias:

if(parent.type == "prototype"){
  var parentParent = docMap[parent.parent];
  sig += (parentParent.alias || (lastPartOfName( parentParent.name) +".")  ).toLowerCase();

} else {
  sig += (parent.alias || lastPartOfName( parent.name)+"." );
}

That code should, I am almost sure, read:

if(parent.type == "prototype"){
  var parentParent = docMap[parent.parent];
  sig += ( lastPartOfName( parentParent.alias || parentParent.name ) + "." ).toLowerCase();

} else {
  sig += lastPartOfName( parent.alias || parent.name ) + ".";
}
justinbmeyer commented 8 years ago

@rjgotten Awesome catch. Can you submit a pull request?