Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

@attr support with optional and default value syntax #73

Closed
reloaded opened this issue Apr 20, 2016 · 5 comments
Closed

@attr support with optional and default value syntax #73

reloaded opened this issue Apr 20, 2016 · 5 comments

Comments

@reloaded
Copy link
Contributor

Most Angular JS directives have optional parameters with default values. JSDOC3 appears to support this detection so the templates should be updated so the directive "Attributes" table has two additional columns that specify optionality and default values.

* @attr {string} [type=select] The type of form widget to render, default value is "select". Supported values are: "select", "radio".
@Zemke
Copy link
Collaborator

Zemke commented Apr 21, 2016

This has been introduced with 1.4.0.

Example:

(function () {
  'use strict';

  /**
   * @ngdoc directive
   * @name appExampleDirective
   * @memberof app
   *
   * @restrict AEC
   * @scope {}
   *
   * @description
   * Test
   *
   * @param {string} [x]
   * @param {string} [y="nice"]
   * @param {string} z
   * 
   * @attr {string} [x]
   * @attr {string} [y="nice"]
   * @attr {string} z
   */
  angular
    .module('app')
    .directive('appExampleDirective', appExampleDirective);

  function appExampleDirective($timeout, ExampleDirective, ExampleDirectiveService, DATES) {
    return {
      restrict: 'AEC',
      scope: {
        filterColumn: '=',
        valueType: '@',
        pickerValue: '@',
        initialValue: '=?',
        physicalUnit: '=?'
      },
      link: linkFn
    };

    function linkFn(scope, elem, attr) {

      /**
       *
       * @memberof app.appExampleDirective
       * @param {string} [x]
       * @param {string} [y="nice"]
       * @param {string} z
       * @returns {null}
       */
      function test(x, y, z) {
        return null;
      }
    }
  }
})();

screen shot 2016-04-21 at 10 32 01 pm

@Zemke Zemke closed this as completed Apr 21, 2016
@reloaded
Copy link
Contributor Author

reloaded commented Apr 22, 2016

@Zemke I did notice that adding [x] and [x=string] did "work" in the sense that the attribute name was outputed to the "name" column.

However, this issue (lack of details on my part) was meant to be an enhancement request to provide two additional columns and one change to the table.

The additional columns would be:

  • Required: The possible column values would be Yes or No
  • Default: The possible column values would be the default value or a blank column. The default value should support either a default string or a default {@link myObject} or [], etc.

The additional change would be to show the attribute/parameter name without brackets and the default value. Using the sample screenshots you provided above it would be nice if the "Name" columns said "x" and "y" instead of "[x]" and "[y='nice']", respectively.

The end result I am envisioning for this request would be:

| Name | Type | Required | Default | Description |
--------------------------------------------------------------------
| x        | string| Yes        | my default | Something required and defaulted |

@allenhwkim
Copy link
Owner

I do not have official plan to support extra column do the table. Please use description for that purpose; optional/required

@reloaded
Copy link
Contributor Author

Are you open to accepting a PR for this, assuming it's not on your road map due to time constraints?

@allenhwkim
Copy link
Owner

I want to keep all table to have the same structure; name, type, and description, unless provided a good reason to make an exception.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants