Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to document anonymous objects and functions with jsdoc
    primarykey
    data
    text
    <p>Edit: This is technically a 2 part question. I've chosen the best answer that covers the question in general and linked to the answer that handles the specific question.</p> <p>What is the best way to document anonymous objects and functions with jsdoc?</p> <pre><code>/** * @class {Page} Page Class specification */ var Page = function() { /** * Get a page from the server * @param {PageRequest} pageRequest Info on the page you want to request * @param {function} callback Function executed when page is retrieved */ this.getPage = function(pageRequest, callback) { }; }; </code></pre> <p>Neither the <code>PageRequest</code> object or the <code>callback</code> exist in code. They will be provided to <code>getPage()</code> at runtime. But I would like to be able to define what the object and function are.</p> <p>I can get away with creating the <code>PageRequest</code> object to document that:</p> <pre><code>/** * @namespace {PageRequest} Object specification * @property {String} pageId ID of the page you want. * @property {String} pageName Name of the page you want. */ var PageRequest = { pageId : null, pageName : null }; </code></pre> <p>And that's fine (though I'm open to better ways to do this).</p> <p>What is the best way to document the <code>callback</code> function? I want to make it know in the document that, for example, the callback function is in the form of:</p> <pre><code>callback: function({PageResponse} pageResponse, {PageRequestStatus} pageRequestStatus) </code></pre> <p>Any ideas how to do this? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload