Подтвердить что ты не робот

Не удается создать файл angularjs (не знаю, как форматировать метод @ngdoc:)

У меня есть служба с некоторой документацией, но когда я пытаюсь создать документы с помощью grunt-ngdocs, это не с помощью:

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

Вот что я пытаюсь сделать

(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));

Я уверен, что мне не хватает чего-то простого...

4b9b3361

Ответ 1

Вот что я закончил делать

(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));

Это, кажется, делает то, что я хочу... возможно, есть менее верный способ сделать, хотя?

Ответ 2

Проблема возникает, потому что вам нужно дать вашему методу правильный родительский (сервис, объект и т.д.). Поскольку вы пытались установить родительский services.base64.Base64 в оператор return функции, он не был правильно установлен. После того как вы переместили блок комментариев в функцию, он был правильно интерпретирован как родитель метода и впоследствии работал.