Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instance member in menu #112

Open
vthierry opened this issue Nov 24, 2022 · 6 comments
Open

instance member in menu #112

vthierry opened this issue Nov 24, 2022 · 6 comments

Comments

@vthierry
Copy link

Dear dacdosh developers,
This is beautiful tool, thank you !

My question: when i document an instance member, e.g.,
/**
* @member {double} tau
* @memberof Belief
* @instance
* @description The degree of belief between -1 (false), 0 (unknown) and true (1), 0 by default.
*/
it does appear in the doc page but not in the menu, whereas a static (i.e., replacing @instance by @static) make it appears in the menu with a # prefix (which is fine). Is there something i miss ?
Best regards.

@ar2rsawseen
Copy link
Collaborator

Hello
@instance defines its own scope, so most probably you need to define where that scope should appear, like global
other than that instance is not related to class (so it is not a method or property, etc)
so it would not appear in the class definitions

@vthierry
Copy link
Author

Thanks for your prompt and helpful comment, yes i must define the scope, which i expect to have done with the @memberof tag, for instance :
/**
* @function asString
* @memberof Belief
* @instance
* @description Returns the value as a wJSON string.
*/
appears both in the doc page and in the left menu whereas a member variable does appear in the doc page only unless i tag it as @global or @static which then appears in the menu but not at the right place or not with the proper documentation tag, because it is not the case here. I also tried @inner which has the same behavior as @instance (adding (inner) in the doc of course), i also tried to replace @member with @var which are synonyms thus same effect.

Best regards.

@ar2rsawseen
Copy link
Collaborator

Hmm, that is true
if I use example from JSDoc:
https://jsdoc.app/tags-memberof.html

/** @class Observable */
create(
    'Observable',
    {
        /**
         * This will be a static member, Observable.cache.
         * @memberof Observable
         */
        cache: [],

        /**
         * This will be an instance member, Observable#publish.
         * @memberof Observable.prototype
         */
        publish: function(msg) {},

        /**
         * This will also be an instance member, Observable#save.
         * @memberof Observable#
         */
        save: function() {},

        /**
         * This will also be an instance member, Observable#end.
         * @memberof Observable
         * @instance
         */
        end: function() {}
    }
);

It correctly adds method end:
image

@vthierry
Copy link
Author

Oh yes as static members it works, i also confirm.

The caveat id for an instance member.

Nevertheless thanks a lot i will further investigate …

Best regards_._

@Mr-ziqiang
Copy link

you can try this:
1.set docdash in your jsdoc.json

"docdash": {
    "search": true,
    "collapse": false,
    "sort":false,
    "static":true
  }
  1. open the node_modules/docdash/publish.js, find the line No.362, and change the code。
if (docdash.static && members.find(function (m) { return (m.scope === 'static'||m.scope==='instance'); } )) {
  itemsNav += "<ul class='members'>";

  itemsNav+="<span style='font-weight:bold;font-size:12px'>└ Members</span>"

  members.forEach(function (member) {
      // if (!member.scope === 'static') return;
      itemsNav += "<li data-type='member'";
      if(docdash.collapse)
          itemsNav += " style='display: none;'";
      itemsNav += ">";
      if(member.scope==='static'){
          itemsNav += linkto(member.longname, '[static] '+member.name);
      }else{
          itemsNav += linkto(member.longname, member.name);
      }
      
      itemsNav += "</li>";
  });

  itemsNav += "</ul>";
}

if (methods.length) {
  itemsNav += "<ul class='methods'>";

  itemsNav+="<span style='font-weight:bold;font-size:12px'>└ Methods</span>"

  methods.forEach(function (method) {
      if (docdash.static === false && method.scope === 'static') return;
      if (docdash.private === false && method.access === 'private') return;
      var navItem = '';
      var navItemLink
      if(method.scope==='static'){
          navItemLink=linkto(method.longname, '[static] '+method.name);
      }else{
          navItemLink=linkto(method.longname, method.name);
      }

      navItem += "<li data-type='method'";
      if(docdash.collapse)
          navItem += " style='display: none;'";
      navItem += ">";
      navItem += navItemLink;
      navItem += "</li>";

      itemsNav += navItem;
  });

  itemsNav += "</ul>";
}

001

002

@vthierry
Copy link
Author

vthierry commented Jan 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants