Question

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...

Was it helpful?

Solution

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?

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top