Mark Robbins
Mark Robbins

Reputation: 2457

EsDoc does not like to document plain objects at the member level - workaround?

Given the following construction:

BigBoss.specify({
  /**
   * EsDoc, will not show me
   */
  val:'val',
  /**
   * EsDoc, will not show me
   */
  fn:function(){
    return 'fn';
  }
  // lots more members I want to documenent in EsDoc
});

And this also fails:

const bigspec = {
  /**
   * EsDoc, will not show me
   */
  val:'val',
  /**
   * EsDoc, will not show me
   */
  fn:function(){
    return 'fn';
  }
  // lots more members I want to documenent in EsDoc
};

I am going to work around this with a module-level class:

class WantsToBePojoSomeday { // assume will never inherit
  // assume no constructor params
  /**
   * EsDoc now documents me
   */
  val='val';
  /**
   * EsDoc now documents me
   */
  fn(){
    return '';
  }
}

const AsPojo=function(klass){
  const inst=new klass;
  const o={};
  for (var i in inst) {
    o[i]=inst[i];
  }
  return o;
}

The call now becomes:

BigBoss.specify(AsPojo(WantsToBePojoSomeday));

What I would like is to 'safely' extend Function.prototype so that the call becomes:

BigBoss.specify(WantsToBePojoSomeday._Pojo);

Other suggestions welcome.

Upvotes: 1

Views: 67

Answers (0)

Related Questions