Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create api documents with grunt-ngdocs

I'm trying to create API documents through grunt-ngdocs. The partials are created but the index.html doesn't have the correct links to it.

I have in my gruntfile.js:

module.exports = function (grunt) {

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    karma: {
        unit: {
            configFile: 'karma.conf.js'
        }
    },
    uglify: {
        options: {
            // the banner is inserted at the top of the output
            banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
        },
        dist: {
            files: {
                'web/js/app.min.js': ['web/js/app.js']
            }
        }
    },
    ngdocs: {
        options: {
            dest: 'docs',
            scripts: ['web/js/app.js'],
            title: 'My Documentation'
        },
        api: {
            src: ['web/**/*.js'],
            title: 'API Documentation'
        }
    },
    clean:['docs','testResult']


});

grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-ngdocs');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('default', ['clean','uglify', 'ngdocs', 'karma']);
};

and my js file like this

 /**
  * @ngdoc overview
  * @ngdoc directive
  * @name myApp.maincontroller:controller
  * @description
  *
  * # myApp
  * The factoryName is my favorite service in the world.
  *
  */


 var myApp = angular.module('myApp',[]);


 myApp.controller("MainController", function($scope) {
    $scope.model = {
        myValue: "Run you fools!"
    };
   });


 /**
          * @ngdoc function
          * @name mySuperFunction
          * @returns {int} The int representing a Firebase resource
          */

 function mySuperFunction() {
    var i = 5;
    var j = 5;
    i += j;
    return i;
 } 

but when I run

grunt 

in the command line, the result is this

 C:\Users\Lino Simões\Documents\bitbucket\test>grunt -d --force
 Running "clean:0" (clean) task
 [D] Task source: C:\Users\Lino Simões\Documents\bitbucket\test\node_modules\grun
 t-contrib-clean\tasks\clean.js
 Cleaning docs...OK

 Running "clean:1" (clean) task
 [D] Task source: C:\Users\Lino Simões\Documents\bitbucket\test\node_modules\grun
 t-contrib-clean\tasks\clean.js
 Cleaning testResult...OK

 Running "uglify:dist" (uglify) task
 [D] Task source: C:\Users\Lino Simões\Documents\bitbucket\test\node_modules\grun
 t-contrib-uglify\tasks\uglify.js
 File web/js/app.min.js created: 796 B → 210 B

 Running "ngdocs:api" (ngdocs) task
 [D] Task source: C:\Users\Lino Simões\Documents\bitbucket\test\node_modules\grun
 t-ngdocs\tasks\grunt-ngdocs.js
 Generating Documentation...
 DONE. Generated 2 pages in 256ms.

 Running "karma:unit" (karma) task
 [D] Task source: C:\Users\Lino Simões\Documents\bitbucket\test\node_modules\grun
 t-karma\tasks\grunt-karma.js
 INFO [karma]: Karma v0.12.17 server started at http://localhost:9876/
 INFO [launcher]: Starting browser PhantomJS
 INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket dFX-dKGVINA6PBjB5Gu9 wit
 h id 91061839
 PhantomJS 1.9.7 (Windows 7): Executed 8 of 8 SUCCESS (0.008 secs / 0.004 secs)

 Done, without errors.

so, this generates 2 files, but when I go to the index.html under docs I have this:

enter image description here

but in my docs/partials/api/ I have the partials created by the ngdocs.

my project tree is like this:

enter image description here

like image 485
Lino Avatar asked Jul 22 '14 16:07

Lino


1 Answers

Did you have angular.js and angular-animate.js in your web/js/app.js? Check it. And add to "options" html5Mode: false

like image 153
Anatoli Avatar answered Oct 12 '22 09:10

Anatoli