clenemt / docdash

:zap: Lodash inspired JSDoc 3 template/theme
http://clenemt.github.io/docdash/
Other
824 stars 201 forks source link

instance member in menu #112

Open vthierry opened 1 year ago

vthierry commented 1 year ago

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

My question: when i document an instance member, e.g., /**

ar2rsawseen commented 1 year ago

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 commented 1 year ago

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 : /**

ar2rsawseen commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 += "

"; }


![001](https://user-images.githubusercontent.com/16486126/211549777-874db128-a0cd-4a36-aae3-052a6f386604.png)

![002](https://user-images.githubusercontent.com/16486126/211549814-97a5d096-7ad1-4552-9307-8653fabfb235.png)
vthierry commented 1 year ago

Dear, Oh thank you very much this is very kind, I'll do that Huge thanks.

-- Thierry Viéville http://www-sop.inria.fr/members/Thierry.Vieville Tel: +(33)613286459

De: "闪刀浪子" @.> À: "clenemt/docdash" @.> Cc: "Thierry Vieville" @.>, "Author" @.> Envoyé: Mardi 10 Janvier 2023 13:21:10 Objet: Re: [clenemt/docdash] instance member in menu (Issue #112)

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 += "

      ";

      itemsNav+="└ Members"

      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 += "";

      });

      itemsNav += "

    ";

}

if (methods.length) {

itemsNav += "

    ";

    itemsNav+="└ Methods"

    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 += "

";

}

[ https://user-images.githubusercontent.com/16486126/211549777-874db128-a0cd-4a36-aae3-052a6f386604.png ]

[ https://user-images.githubusercontent.com/16486126/211549814-97a5d096-7ad1-4552-9307-8653fabfb235.png ]

— Reply to this email directly, [ https://github.com/clenemt/docdash/issues/112#issuecomment-1377180993 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/AAOVM2YALDHEIOEWHB6YP6LWRVH3NANCNFSM6AAAAAASKQF4FI | unsubscribe ] . You are receiving this because you authored the thread. Message ID: @.***>