Question

I have the following code:

       /**
     * @fileOverview Various tool functions.
     * @version 3.1.2
     */


define(function (require, exports, module) {
    "use strict";

    /**
     * A module that handles file
     * @module fileHandler
     */

       /// Form to open a new set of files
       var newFileForm = require("pvsioweb/forms/newFileForm");   

       var formEvents = require("pvsioweb/forms/events");

       /// Reference to current project, main.js passes it by using fileHandler_setProject
       var currentProject;


/**
 * this is a function
 * @param p1 First parameter
 * @param p2 Second parameter
 * @return {String} some value
 */
function setProject(project)
{
    currentProject = project;

}


/** 
 * Create a new file, it is going to be shown in the listview: #pvsFiles  
 *  
 *  @param  name:    name of the file
 *  @param  content:   textual content of the file 
 *
 *  @returns void 
 *        
 */

function new_file(name, content )
{
    var default_name = "MyTheory.pvs";
    var default_content = "MyTheory" + " THEORY BEGIN \nEND MyTheory" ;

    if( ! name ) { name = default_name; }

    if( ! content ) { content = default_content; }

        currentProject.addSpecFile(default_name, default_content);
    renderSourceFileList(currentProject.pvsFiles());    
}


/** 
 *  Display new file form, invoke function open_file (see below)  
 *
 *  @returns void 
 *        
 */
function open_file_form()
{
    newFileForm.create().addListener(formEvents.FormCancelled, function (e) {
            console.log(e);
            e.form.remove();
    }).addListener(formEvents.FormSubmitted, function (e) {
            console.log(e);
            e.form.remove();
            open(e.formJSON);
    });

}

/** 
 *  Open file specified in data, data must have this structure: ????  FIXME
 * 
 *  @param  data: ??? FIXME
 *
 *  @returns void 
 *        
 */
function open_file(data)
{
    var q = queue(), i;


        for (i = 0; i < data.pvsSpec.length; i++) {
            q.defer(createFileLoadFunction(data.pvsSpec[i]));
        }



            q.awaitAll(function (err, res) {
                currentProject.saveNew(function (err, res) {
                    console.log({err: err, res: res});

                        renderSourceFileList(currentProject.pvsFiles());

                });
            });

    }

/********* Exported Function ******************/


module.exports = {
    new_file: function (name, content) {
        return new_file(name, content);
    },
    open_file_form: function () {
        return open_file_form();
    },
    open_file: function () {
        return open_file();
    },
    setProject: function (project) {
        return setProject(project);
    }   

};

/***********************************************/


});

I tried to make some output by using jsdoc, but it seems to recognize just the word module and the header at the beginning of the file.

How can I fix to see also the documentation about the functions?

Thanks

Was it helpful?

Solution

I'm not sure I understand the question. Are you trying to generate documentation with jsdoc? If so, you'll need to add the jsdoc comments to each function. Also, your exports could be greatly simplified:

module.exports = {
    new_file: new_file,
    open_file_form: open_file_form,
    open_file: open_file,
    setProject: setProject
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top