-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
build(aio): tighten up code autolinking #20468
build(aio): tighten up code autolinking #20468
Conversation
You can preview 2b9148d at https://pr20468-2b9148d.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments. LGTM (as soon as CIs are happy - rebasing on master should fix one of the issues) 👍
@@ -41,7 +41,7 @@ module.exports = function postProcessHtml(log, createDocMessage) { | |||
}); | |||
doc.vFile = vFile; | |||
} catch(e) { | |||
throw new Error(createDocMessage(e.message, doc)); | |||
throw new Error(createDocMessage(e.stack, doc)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require changes in specs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess so. I might drop ditch this change for now. It just made debugging the failures easier.
}); | ||
|
||
it('should ignore docs that are pipes, match the pipe name and are preceded by a pipe character', () => { | ||
const docs = [{ docType: 'pipe', name: 'B', pipeOptions: { name: 'b' } }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for the pipe name to match it should be name: "'b'"
.
|
||
describe('filterPipes', () => { | ||
it('should ignore docs that are not pipes', () => { | ||
const docs = [{ docType: 'class', name: 'B', pipeOptions: { name: 'b' } }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to have matching pipe name, to demonstrate that it is the docType
that makes the difference.
@@ -51,6 +52,26 @@ describe('autoLinkCode post-processor', () => { | |||
expect(doc.renderedContent).toEqual('<code>MyClass</code>'); | |||
}); | |||
|
|||
it('should ignore code items match an API doc but are attached to other text via a dash', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
match --> that match
@@ -38,12 +45,13 @@ module.exports = function autoLinkCode(getDocFromAlias) { | |||
parent.children.splice(index, 1, createLinkNode(docs[0], node.value)); | |||
} else { | |||
// Parse the text for words that we can convert to links | |||
const nodes = textContent(node).split(/([A-Za-z0-9_]+)/) | |||
const nodes = textContent(node).split(/([A-Za-z0-9_-]+)/) | |||
.filter(word => word.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this PR, but filter(word => word.trim())
would avoid processing whitespace only tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this does not work. We need the whitespace tokens because as we rebuild the text after adding in the links. Without these tokens some of the whitespace gets lost.
2b9148d
to
66152fb
Compare
You can preview 66152fb at https://pr20468-66152fb.ngbuilds.io/. |
Do not match code "words" that are part of a hyphenated string of characters: e.g. `platform-browser-dynamic` should not auto-link `browser`. Do not match code "words" that correspond to pipe names but are not preceded by a pipe `|` character. E.g. `package.json` should not auto link `json` to the `JsonPipe`. Closes angular#20187
66152fb
to
1491b43
Compare
You can preview 1491b43 at https://pr20468-1491b43.ngbuilds.io/. |
Do not match code "words" that are part of a hyphenated string of characters: e.g. `platform-browser-dynamic` should not auto-link `browser`. Do not match code "words" that correspond to pipe names but are not preceded by a pipe `|` character. E.g. `package.json` should not auto link `json` to the `JsonPipe`. Closes #20187 PR Close #20468
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Do not match code "words" that are part of a hyphenated
string of characters: e.g.
platform-browser-dynamic
shouldnot auto-link
browser
.Do not match code "words" that correspond to pipe names
but are not preceded by a pipe
|
character. E.g.package.json
should not auto linkjson
to theJsonPipe
.Closes #20187