Skip to content

docs: Show directive selector in generated API docs #4139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2017
Merged

docs: Show directive selector in generated API docs #4139

merged 3 commits into from
Apr 21, 2017

Conversation

jbh
Copy link

@jbh jbh commented Apr 18, 2017

  • Adds method to get directive selectors to categorizor.js
  • Adds selectors to class.template.html

Takes care of #3983

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot googlebot added the cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla label Apr 18, 2017
@jbh
Copy link
Author

jbh commented Apr 18, 2017

I signed it!

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

// Categorize the current visited classDoc into its Angular type.
if (isDirective(classDoc)) {
classDoc.isDirective = true;
classDoc.directiveExportAs = getDirectiveExportAs(classDoc);
classDoc.selectors = getDirectoveSelectors(classDoc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directiveSelectors?

'textarea[md-autosize]',
'[overlay-origin]',
'[connected-overlay]',
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a constant at the top of the file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I had thought of that, but decided to go with this since it seemed specific to this function. I'll make these changes once I get the CLA figured out.

if (selectorMatches) {
selectorMatches = selectorMatches.split(/\s*,\s*/);
selectorMatches = selectorMatches
.filter(match => match !== '' && !match.includes('mat') && blacklist.indexOf(match) === -1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the following?

return selectorMatches.split(/\s*,\s*/)
     .filter(match => match && !match.includes('mat') && !blacklist.includes(match));

.filter(match => match !== '' && !match.includes('mat') && blacklist.indexOf(match) === -1);
}

return selectorMatches;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you immediately return (as with comment above) then you can just remove that.

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Apr 18, 2017
@@ -1,3 +1,11 @@
const DIRECTIVE_SELECTOR_BLACKLIST = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment like

/**
 * We want to avoid emitting selectors that are deprecated but don't have a way to mark
 * them as such in the source code. Thus, we maintain a separate blacklist of selectors
 * that should not be emitted in the documentation.
 */

'[portalHost]',
'textarea[md-autosize]',
'[overlay-origin]',
'[connected-overlay]',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this a Set instead of an array:

const SELECTOR_BLACKLIST = new Set([
  '[portal]',
  '[portalHost]',
  'textarea[md-autosize]',
  '[overlay-origin]',
  '[connected-overlay]',
]);

And then use SELECTOR_BLACKLIST.has(...) instead of includes

Copy link
Author

@jbh jbh Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken care of. Let me know if it's all up to par. Also, thanks for the tip.


return selectorMatches ? selectorMatches.split(/\s*,\s*/)
.filter(match => match !== '' && !match.includes('mat') && !DIRECTIVE_SELECTOR_BLACKLIST.includes(match))
: selectorMatches;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd shorten match to just s so that it's

return selectorMatches ? 
    selectorMatches.split(/\s*,\s*/)
        .filter(s => s && !s.includes('mat') && !SELECTOR_BLACKLIST.has(s))
   : selectorMatches;

@@ -3,14 +3,21 @@ <h4 class="docs-api-h4 docs-api-class-name">
</h4>
<p class="docs-api-class-description">{$ class.description $}</p>

{%- if class.directiveSelectors -%}
<span class="docs-api-h4 docs-api-class-selector-label">Selectors:</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selectors: -> selector:

I'd like it to match what's in the source

@@ -3,14 +3,21 @@ <h4 class="docs-api-h4 docs-api-class-name">
</h4>
<p class="docs-api-class-description">{$ class.description $}</p>

{%- if class.directiveSelectors -%}
<span class="docs-api-h4 docs-api-class-selector-label">Selectors:</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you wrap the inside of this if block in a `<div class="docs-api-directive-selectors>"?

@@ -3,14 +3,21 @@ <h4 class="docs-api-h4 docs-api-class-name">
</h4>
<p class="docs-api-class-description">{$ class.description $}</p>

{%- if class.directiveSelectors -%}
<span class="docs-api-h4 docs-api-class-selector-label">Selectors:</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an <h4> so you should omit docs-api-h4

@@ -3,14 +3,23 @@ <h4 class="docs-api-h4 docs-api-class-name">
</h4>
<p class="docs-api-class-description">{$ class.description $}</p>

{%- if class.directiveSelectors -%}
<span class="docs-api-class-selector-label">selector:</span>
<div class="docs-api-directive-selectors">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This div should be around the selector-label span as well

jbh added 2 commits April 20, 2017 14:02
* Adds method to get directive selectors to categorizor.js
* Adds selectors to class.template.html

Takes care of #3983

Conflicts:
	tools/dgeni/templates/class.template.html
@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Apr 20, 2017
@kara kara merged commit 740381c into angular:master Apr 21, 2017
@jbh jbh deleted the 3983/show-directive-selectors branch April 21, 2017 13:22
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants