11

I have such code but can not turn on outline of function if it defined in anonymous function - there is not problem with class.

How can I outline something2 - please share some hints?

I can mark all function as constructors but it is invalid approach.

screenshot of bad outline

// --- start of track event ---
// required debug.js
(function (window) {

/**
 * @memberof erest.track_event
 */ 
function something2() {
}

/**
 * @memberof erest.track_event
 * @constructor
 */
function something3() {
}
}(window));
//--- end of track event ---

function something1() {
}

I was tested all filtering options, jsdoc and study Eclipse preferences but has no idea what to do to make something2 visible in outline view?

second attempt

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Chameleon
  • 9,722
  • 16
  • 65
  • 127
  • I am running Eclipse Luna (latest available) and am still suffering this puzzle. – Kolban Nov 25 '14 at 00:13
  • Note that only the first level is shown in the outline ([by design](https://bugs.eclipse.org/bugs/show_bug.cgi?id=472855)), so it won't work if you have your JS code wrapped in a self-executing anonymous function. – thdoan Nov 27 '18 at 22:43

1 Answers1

4

You have a small typo in the @memberOf annotation. Change to a capital O and it should work just fine:

(function(window) {

  /**
   * @memberOf erest.track_event
   */
   function something2() {
   }

  /**
   * @memberOf erest.track_event
   * @constructor
   */
   function something3() {
   }

}(window));

function something1() {
}

Outline Screenshot

Remove the @constructor annotation, if appropriate, to get something3() in the outline and not the constructor function.

Here is a similar question asked. Follow the link in the answer to get some more information.

Community
  • 1
  • 1
rene
  • 1,618
  • 21
  • 26
  • 1
    From my perspective, your recipe seems to work. I find it interesting that the tag needs to be `@memberOf` as opposed to `@memberof` (see ... http://usejsdoc.org/tags-memberof.html) – Kolban Dec 01 '14 at 14:40
  • Indeed, you are right. I found the issue of this question while reading [this post](http://www.kajabity.com/2012/02/how-i-introduced-jsdoc-into-a-javascript-project-and-found-my-eclipse-outline/). It seems to be an odd behavior of the outline view. But I don't have any details about the implementation. – rene Dec 01 '14 at 17:34