jsdoc2md / dmd

The default output template for jsdoc2md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Class function documentation?

ambischof opened this issue · comments

I want my class instance static functions to show up in the output, but even though they are parsed correctly, they aren't output.

Is there something I'm missing or is this expected?

can you show me your source code please, with the jsdoc comments

define(["jquery", "lodash", "backbone", "marionette", "jwt_decode"],
    function($, _, Backbone, Marionette, jwtDecode){
/**
 * @class SessionManager
 * @classdesc the controller that handles the logged in state
 * @param {object} options
 * @param {Marionette.app} options.app - the app. Specified this way to avoid circular dependencies
 * @description
 * Contains the logic for maintaining the session.
 * An instance of this class is placed on the app object where it can be accessed
 */
        return  Marionette.Object.extend({
            initialize: function(options){
                this.app = options.app;
            },
            /**
             * @memberof SessionMananger.prototype
             * @summary attempt to resume session from previous token.
             * @returns {boolean} true if successfull or false if not.
             */
            resumeSession: function(){
                //try to get token
                var token = this.retrieveToken(),
                    expiration;
                if (!token) return false;

                //check token expiration
                try {expiration = jwtDecode(token).exp} //if token malformed, will throw err
                catch (err) {return false}

                //if token expired, login
                if (expiration < _.now()){
                    return false
                }
                else {
                    this.app.radio.trigger('logged:in');
                    return true
                }
            },
            /**
             * get a new token. Intended for when token is about to expire.
             * @memberof SessionMananger.prototype
             */
            renewToken: function(){
                console.log('rewing token'); //DEBUG
                return $.ajax(this.app.apiPath + "renew-token", {
                    data: {'token': this.retrieveToken()},
                    method: 'post'
                })
            },
            /**
             * @memberof SessionMananger.prototype
             * @param {JWTToken} token - token (recieved from login typically)
             * @summary save token in local storage for future use
             */
            saveToken: function(token){
                window.localStorage.setItem('accessToken', token);
                this.app.radio.trigger('logged:in');
                return token;
            },
            /**
             * retrieve token from local storage
             * @memberof SessionMananger.prototype
             * @returns {JWTToken} the token
             */
            retrieveToken: function(){
                return window.localStorage.getItem('accessToken');
            },
            /**
             * Call to end the current session.
             * @memberof SessionMananger.prototype
             * @param  {string} message - if there's a message to send with logout, e.g. reason logout ended/expired
             */
            logout: function(message){
                window.localStorage.removeItem('accessToken');
                this.app.radio.trigger('logged:out', message);
            }
        });
})

I'm sorry, I read those documents but they don't seem to answer my issue.

Sure I'm using a requirejs module, but I'm trying to document a class, not the module that returns it.

As for the issue you pointed me to, I am not using an IIFE.

I ran it through jsdoc-parse and got what seemed like valid output:


  {
    "id": "SessionManager()",
    "longname": "SessionManager",
    "name": "SessionManager",
    "kind": "constructor",
    "description": "Contains the logic for maintaining the session.\nAn instance of this class is placed on the app object where it can be accessed",
    "memberof": "SessionManager",
    "params": [
      {
        "type": {
          "names": [
            "object"
          ]
        },
        "name": "options"
      },
      {
        "type": {
          "names": [
            "Marionette.app"
          ]
        },
        "description": "the app. Specified this way to avoid circular dependencies",
        "name": "options.app"
      }
    ],
    "order": 1
  },
  {
    "id": "SessionManager",
    "longname": "SessionManager",
    "name": "SessionManager",
    "scope": "global",
    "kind": "class",
    "description": "the controller that handles the logged in state",
    "order": 0
  },
  {
    "id": "SessionMananger#resumeSession",
    "longname": "SessionMananger#resumeSession",
    "name": "resumeSession",
    "scope": "instance",
    "kind": "function",
    "summary": "attempt to resume session from previous token.",
    "memberof": "SessionMananger",
    "returns": [
      {
        "type": {
          "names": [
            "boolean"
          ]
        },
        "description": "true if successfull or false if not."
      }
    ],
    "order": 2
  },
  {
    "id": "SessionMananger#renewToken",
    "longname": "SessionMananger#renewToken",
    "name": "renewToken",
    "scope": "instance",
    "kind": "function",
    "description": "get a new token. Intended for when token is about to expire.",
    "memberof": "SessionMananger",
    "order": 3
  },
  {
    "id": "SessionMananger#saveToken",
    "longname": "SessionMananger#saveToken",
    "name": "saveToken",
    "scope": "instance",
    "kind": "function",
    "summary": "save token in local storage for future use",
    "memberof": "SessionMananger",
    "params": [
      {
        "type": {
          "names": [
            "JWTToken"
          ]
        },
        "description": "token (recieved from login typically)",
        "name": "token"
      }
    ],
    "order": 4
  },
  {
    "id": "SessionMananger#retrieveToken",
    "longname": "SessionMananger#retrieveToken",
    "name": "retrieveToken",
    "scope": "instance",
    "kind": "function",
    "description": "retrieve token from local storage",
    "memberof": "SessionMananger",
    "returns": [
      {
        "type": {
          "names": [
            "JWTToken"
          ]
        },
        "description": "the token"
      }
    ],
    "order": 5
  },
  {
    "id": "SessionMananger#logout",
    "longname": "SessionMananger#logout",
    "name": "logout",
    "scope": "instance",
    "kind": "function",
    "description": "Call to end the current session.",
    "memberof": "SessionMananger",
    "params": [
      {
        "type": {
          "names": [
            "string"
          ]
        },
        "description": "if there's a message to send with logout, e.g. reason logout ended/expired",
        "name": "message"
      }
    ],
    "order": 6
  }
]

however, in the generated markdown, it ignores the functions.

<a name="SessionManager"></a>
## SessionManager
the controller that handles the logged in state

**Kind**: global class  
<a name="new_SessionManager_new"></a>
### new SessionManager(options)
Contains the logic for maintaining the session.
An instance of this class is placed on the app object where it can be accessed


| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> |  |
| options.app | <code>Marionette.app</code> | the app. Specified this way to avoid circular dependencies |

in your @memberof tags you have written SessionMananger instead of SessionManager

Well don't I feel silly. Sorry about that.

i forgive you ;)

don't be shy to raise issues 👍