2

I'm new to Sails.js and Node.js and I have problems with creating documentation for my application.

Here's my steps:

  • installed apidoc by: npm install apidoc -g
  • installed grunt module: npm install grunt-apidoc --save-dev
  • added grunt.loadNpmTasks('grunt-apidoc'); to Gruntfile.js at the bottom
  • created grunt.initConfig file and put:

apidoc: { myapp: { src: "api/controllers/", dest: "apidoc/" } }

Then I'm trying to run multiple things, and none of them produces my api documentation:

  • sails lift
  • grunt
  • grunt default
  • node app.js

If I run it manually by apidoc -i api/controllers/ -o apidoc/ it's working properly.

What am I doing wrong? How to do it?

Tomasz
  • 2,051
  • 3
  • 31
  • 64
  • Have you registered the task. Something like `grunt.registerTask('apidoc', ['apidoc']);` – bhb Jul 07 '15 at 11:59

1 Answers1

2

Super late answer!

From my experience modifying the asset pipeline you'd be better off:

  1. Install apidoc and the Grunt module as in the Question

  2. Create a new file in `tasks/config/apidoc.js:

    module.exports = function (grunt) {
        grunt.config.set('apidoc', {
        myapp: {
          src: "api/controllers/",
          dest: "apidoc/"
        }
      });
      grunt.loadNpmTasks('grunt-apidoc');
    };
    
  3. Edit tasks/register/compileAssets.js (or wherever you want the task to be run):

    module.exports = function (grunt) {
      grunt.registerTask('compileAssets', [
        'clean:dev',
        'jst:dev',
        'less:dev',
        'copy:dev',
        'coffee:dev',
        'apidoc:myapp' // <-- This will now run every time your assets are compiled
      ]);
    };
    

Hope this helps someone

coagmano
  • 5,542
  • 1
  • 28
  • 41