Skip to content
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

aio: autolinking fixes #20512

Closed

Conversation

petebacondarwin
Copy link
Member

Closes #20466

@petebacondarwin petebacondarwin added comp: aio action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 17, 2017
@petebacondarwin petebacondarwin added this to REVIEW in docs-infra Nov 17, 2017
@mary-poppins
Copy link

You can preview c4d5b29 at https://pr20512-c4d5b29.ngbuilds.io/.

@@ -1,3 +1,5 @@
const CssSelectorParser = require('css-selector-parser').CssSelectorParser;
Copy link
Member

Choose a reason for hiding this comment

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

OMG, extra whitespace after const 😱

const selectorAST = cssParser.parse(stripQuotes(selectors));
const rules = selectorAST.selectors ? selectorAST.selectors.map(ruleSet => ruleSet.rule) : [selectorAST.rule];
return rules.reduce((aliases, rule) => {
const tagAliases = rule.tagName? [rule.tagName] : [];
Copy link
Member

Choose a reason for hiding this comment

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

Missing whitespace before ? 😢

expect(filterAmbiguousDirectiveAliases(docs, words, 2)).toEqual(filteredDocs);
});

it('should filter out docs that do not match (case-insensitively) their class name to the matching word', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This description seems a little off.

if (docs.length > 1) {

// Capture the first doc's docType
const docType = docs[0].docType;
Copy link
Member

Choose a reason for hiding this comment

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

What is the reasoning for caring only about the first doc?

Copy link
Member Author

Choose a reason for hiding this comment

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

because we don't try to do any filtering if the docs are not all of the same type.

Copy link
Member

Choose a reason for hiding this comment

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

And what is the reasoning for not trying to do any filtering if the docs are not all of the same type? 😁


if (docs.every(doc =>
// if all the matched docs are of the same type (directives or components)
doc.docType === docType &&
Copy link
Member

Choose a reason for hiding this comment

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

So, if the first one is of type component we don't filter if any of the rest is of type directive?
Why is that?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the core docs there are not really many components (if any) so I don't think that this really matters either way. I guess we can be more relaxed and allow any collection of directives and components (just nothing else).

// if all the matched docs are of the same type (directives or components)
doc.docType === docType &&
// and the matching word is in the selector for all of them
doc[docType + 'Options'].selector.indexOf(word) != -1
Copy link
Member

Choose a reason for hiding this comment

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

Should we take word boundaries into account. E.g. ['ngModelStatus'].indexOf('ngModel') !== -1, but should that count as a match?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess you are saying that you think it should not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if this is likely to be a problem...?
For a doc to appear in the original docs list that is passed to the filter function, the matching word must appear as an alias of the doc. So I think that it is unlikely that the matching word does not appear in the selector at all.

@mary-poppins
Copy link

You can preview dad6f35 at https://pr20512-dad6f35.ngbuilds.io/.

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 20, 2017
@gkalpak
Copy link
Member

gkalpak commented Nov 20, 2017

The Travis failures are unrelated to the PR.

@gkalpak gkalpak moved this from REVIEW to MERGE in docs-infra Nov 20, 2017
@IgorMinar
Copy link
Contributor

@petebacondarwin please add target label in the future. in general for docs, bug fixes and infrastructure changes we should always try to cherrypick the commit to the stable branch

@IgorMinar IgorMinar added the target: patch This PR is targeted for the next patch release label Nov 21, 2017
@gkalpak
Copy link
Member

gkalpak commented Nov 21, 2017

Ooops! I added the merge label without checking for target 😳

@petebacondarwin
Copy link
Member Author

@IgorMinar yes, I normally add the target to my own PRs when I add the merge label. I didn't realise that @gkalpak had added the merge label when he approved it.

mhevery pushed a commit that referenced this pull request Nov 22, 2017
Having duplicates was causing the code auto-linking
to ignore `ngForm` directives.

PR Close #20512
@mhevery mhevery closed this in ecce907 Nov 22, 2017
mhevery pushed a commit that referenced this pull request Nov 22, 2017
mhevery pushed a commit that referenced this pull request Nov 22, 2017
Having duplicates was causing the code auto-linking
to ignore `ngForm` directives.

PR Close #20512
@petebacondarwin petebacondarwin removed this from MERGE in docs-infra Nov 22, 2017
@petebacondarwin petebacondarwin deleted the aio-autolinking-fixes branch November 22, 2017 17:12
wKoza pushed a commit to wKoza/angular that referenced this pull request Dec 2, 2017
wKoza pushed a commit to wKoza/angular that referenced this pull request Dec 2, 2017
Having duplicates was causing the code auto-linking
to ignore `ngForm` directives.

PR Close angular#20512
@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 12, 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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aio: auto code linking of ngModel is not working
5 participants