Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build angularjs doc (Don't know how to format @ngdoc: method)

I have a service with some documentation, but when I try to build the docs using grunt-ngdocs it fails with:

Warning: Don't know how to format @ngdoc: method Use --force to continue.

Here is what I am trying to do

(function(angular) {
    'use strict';

    angular.module('services.base64', [])
    .factory(
            'Base64',
            [function() {

                /**
                 * @ngdoc service
                 * @name Base64
                 * @module services.base64
                 * @description Provides encoding a string into base64, and decode base64 to a string
                 */
                return {
                    /**
                     * @ngdoc method
                     * @name Base64#encode
                     * @param {string}
                     *            input the string you want to encode as base64
                     * @returns {string} the base64 encoded string
                     */
                    encode : function(input) {
                        //...
                    },

                    /**
                     * @ngdoc method
                     * @name Base64#decode
                     * @param {string}
                     *            input the base64 encoded string
                     * @returns {string} the decoded string
                     */
                    decode : function(input) {
                        //...
                    }
                };
            }]);
}(angular));

I'm sure I am missing something simple...

like image 399
niltz Avatar asked May 12 '14 20:05

niltz


2 Answers

Here is what I ended up doing

(function(angular) {
    'use strict';

    /**
     * @ngdoc overview
     * @name services.base64
     */
    angular.module('services.base64', [])
    .factory(
            'Base64',
            [function() {

                /**
                 * @ngdoc service
                 * @name services.base64.Base64
                 * @description Provides encoding a string into base64, and decode base64 to a string
                 */
                return {
                    /**
                     * @ngdoc method
                     * @name encode
                     * @methodOf services.base64.Base64
                     * @param {string}
                     *            input the string you want to encode as base64
                     * @returns {string} the base64 encoded string
                     */
                    encode : function(input) {
                        //...
                    },

                    /**
                     * @ngdoc method
                     * @name decode
                     * @methodOf services.base64.Base64
                     * @param {string}
                     *            input the base64 encoded string
                     * @returns {string} the decoded string
                     */
                    decode : function(input) {
                        //...
                    }
                };
            }]);
}(angular));

This appears to do what I want...perhaps there is a less verbose way of doing though?

like image 114
niltz Avatar answered Oct 26 '22 07:10

niltz


The problem is occurring because you need to give your method a proper parent (service, object, etc.). Because you were trying to set the parent services.base64.Base64 on a function return statement it wasn't being properly set. Once you moved the comment block over to a function it was able to be properly interpreted as a method parent and subsequently worked.

like image 29
Scott Sword Avatar answered Oct 26 '22 06:10

Scott Sword