1

How can one force JsDoc to consider a parameter as a reference to a Class Constructor?

Hi! I am struggling to make JsDoc for my library, but there must be something I am missing here. I documented part of my library (in this example, the "Relation" class). The facade for the library is the "Rajs" class. It contains a parameter containing a reference to the Reference class. I would like to be able, when I require "Rajs" in another file, to be able to access the jsDoc documentation. But it just doesn't recognize this.

I am using WebStorm.

In this file, I define a Class named "Relation"

relation.js - The "documented" class

// File relation.js
//-----------------  
var Backbone = require('backbone');

var Relation = Backbone.Model.extend(
  /** @lends Relation.prototype*/
  {

    /**
     * @class Relation
     * @augments Backbone.Model
     * @constructor
     */
  initialize : function(){
    // Initialization ...
  }

});
module.exports = Relation;

Here, this is the facade for my library. Everything should be accessed through "Rajs", preventing the user to have to require every part of my library. Rajs will require everything and the user will simply have to require Rajs.

rajs.js -- the Facade

// File rajs.js
//--------------
var Backbone = require('backbone');
var Relation = require('./relation');

var Rajs = Backbone.Model.extend( /** @lends Rajs.prototype */
  {
    /**
     * @class Rajs
     * @augments Backbone.Model
     * @constructor
    */
    initialize : function(){
      // Initialization ...
      this.Relation = Relation;
    }
});
Module.exports = Rajs;

This would be the end-user. He would require('rajs') and should have access to the whole library without having to require('rajs-x'), ('rajs-y'), ('rajs-z')... It actually works, but I'd like to provide the user JsDoc for autocompletion.

Here, in app.js, the user required core but could not access the jsDoc for Relation.js. Why is that so?

app.js -- The end-user file

// File app.js
//------------
var Rajs = require('./rajs');
var rajs = new Rajs();
var relation = new rajs.Relation(); //Here, jsDoc does not recognize core.Relation as being of class Relation. Instead, it sees it like a property if Rajs

![Does not recognize Relation.js methods and properties][1]

Thank you for your help!

Ludovic C
  • 2,855
  • 20
  • 40
  • related ticket: http://youtrack.jetbrains.com/issue/WEB-10214 – lena Jan 20 '14 at 15:24
  • possible duplicate of [Documenting complex JavaScript Objects with custom Inheritance System](http://stackoverflow.com/questions/22246014/documenting-complex-javascript-objects-with-custom-inheritance-system) – Paul Sweatte Apr 14 '14 at 22:35

0 Answers0