0

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

1 Answer 1

1

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
};
Sign up to request clarification or add additional context in comments.

3 Comments

Yes, I'm trying to generate documentation with jsdoc. Please, take a look at my syntax maybe it's bad.
OK, I see you've updated the question with additional code. That makes more sense now.
I think you either need to move your jsdoc comments to the exports, as explained here: github.com/jsdoc3/jsdoc/issues/121 Or use the @lends tag: usejsdoc.org/tags-lends.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.