Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngPluralize / ngView Documentation bug #14045

Closed
litera opened this issue Feb 15, 2016 · 6 comments
Closed

ngPluralize / ngView Documentation bug #14045

litera opened this issue Feb 15, 2016 · 6 comments

Comments

@litera
Copy link

litera commented Feb 15, 2016

On the website if you look at ngPluralize and check usage, you can see that when you use this directive as an attribute it's actually missing the n-pluralize attribute.

This is what is written now

<ANY
  count=""
  when="string"
  [offset="number"]>
...
</ANY>

This is what it should be

<ANY
  ng-pluralize
  count=""
  when="string"
  [offset="number"]>
...
</ANY>

Note: I wanted to improve this doc, but this text is not part of ngdoc and I'm not really sure how to contribute this change hence this issue.

@Narretz
Copy link
Contributor

Narretz commented Feb 15, 2016

This is a bug in angular/dgeni-packages. the usage section uses the params, but it can't handle directives whose attribute selector doesn't take a value (ng-pluralize is a void attribute, and it's not listed in the params). I think this should be handled as a special case in /dgeni-packages/ngdoc/templates/api/directive.template.html

@Narretz Narretz added this to the Backlog milestone Feb 15, 2016
@Narretz Narretz changed the title Documentation bug ngPluralize Documentation bug Feb 15, 2016
@litera
Copy link
Author

litera commented Feb 15, 2016

@Narretz Where is this Usage part even documented as it's not part of the ngDoc?

And BTW, you're right about this selector bug as ngView has the same problem. This means that you should likely rename this iise to Boolean attribute documentation bug or something similar. I believe that these attributes as you're calling void attributes are called boolean attributes

@Narretz
Copy link
Contributor

Narretz commented Feb 15, 2016

The usage template part is defined in this template: https://github.com/angular/dgeni-packages/blob/master/ngdoc/templates/api/directive.template.html and it takes the information from the @restrict and @param tags

@Narretz Narretz changed the title ngPluralize Documentation bug ngPluralize / ngView Documentation bug Feb 15, 2016
@Narretz
Copy link
Contributor

Narretz commented Feb 15, 2016

I've opened angular/dgeni-packages#158 to track this on the dgeni-packages site. It's kind of low priority. Do you want to give this a shot?

@litera
Copy link
Author

litera commented Feb 16, 2016

@Narretz I don't think I'd be up for it as I don't know anything about how dgeni works nor do I have the time at the moment to learn about it. If you may provide some sort of info how this template is being processed I may see where to look and maybe come up with a solution.

@Narretz
Copy link
Contributor

Narretz commented Feb 16, 2016

In the template, there is this block, which renders the usage section.

  {% block usage %}
  <h2 id="usage">Usage</h2>
  <div class="usage">
  {% if doc.usage %}
    {$ doc.usage | marked $}
  {% else %}
    <ul>
    {% if doc.restrict.element %}
      <li>as element:
      {% if doc.name.indexOf('ng') == 0 -%}
      (This directive can be used as custom element, but be aware of <a href="guide/ie">IE restrictions</a>).
      {%- endif %}
      {% code %}
      <{$ doc.name | dashCase $}
        {%- for param in doc.params %}
        {$ directiveParam(param.alias or param.name, param.type, '="', '"') $}
        {%- endfor %}>
      ...
      </{$ doc.name | dashCase $}>
      {% endcode %}
      </li>
    {% endif -%}

    {%- if doc.restrict.attribute -%}
      <li>as attribute:
        {% code %}
        <{$ doc.element $}
          {%- for param in doc.params %}
          {$ directiveParam(param.name, param.type, '="', '"') $}
          {%- endfor %}>
        ...
        </{$ doc.element $}>
        {% endcode %}
      </li>
    {% endif -%}

    {%- if doc.restrict.cssClass -%}
      <li>as CSS class:
        {% code %}
        {% set sep = joiner(' ') %}
        <{$ doc.element $} class="
        {%- for param in doc.params -%}
          {$ sep() $}{$ directiveParam(param.name, param.type, ': ', ';') $}
        {%- endfor %}"> ... </{$ doc.element $}>
        {% endcode %}
      </li>
    {% endif -%}

  {%- endif %}
  </div>
  {% endblock -%}

For elements that can be used as attributes, it renders an element with the directive name and all of its params as attributes. What we should do: when the directive name is not in the params, add it as an attribute

@Narretz Narretz self-assigned this Oct 9, 2017
Narretz added a commit to Narretz/angular.js that referenced this issue Oct 11, 2017
When a directive doesn't take a value, its name is not included
in the parameters, which previously meant that the directive name
was missing from the Usage section of the docs.

This commit adds the name to the Usage section when it is missing
from the parameters.

Closes angular#14045
Narretz added a commit to Narretz/angular.js that referenced this issue Oct 11, 2017
When a directive doesn't take a value, its name is not included
in the parameters, which previously meant that the directive name
was missing from the Usage section of the docs.

This commit adds the name to the Usage section when it is missing
from the parameters.

Closes angular#14045
Narretz added a commit to Narretz/angular.js that referenced this issue Oct 13, 2017
When a directive doesn't take a value, its name is not included
in the parameters, which previously meant that the directive name
was missing from the Attribute / CSS Class usage section of the docs.

This commit adds the name to the Usage section when it is missing
from the parameters.

Closes angular#14045
Narretz added a commit that referenced this issue Oct 19, 2017
When a directive can be used as an attribute or CSS class, but doesn't take 
a value, its name is not included in the parameters, which previously meant 
that the directive name was missing from the Attribute / CSS Class usage 
section of the docs.

This commit adds the name to the Usage section when it is missing
from the parameters.

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

No branches or pull requests

2 participants