-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Add line/code renderer to deprecations audit #2145
Conversation
ebidel
commented
May 4, 2017
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.
looking good
* @typedef {{ | ||
* type: string, | ||
* text: string, | ||
* header: (!DetailsRenderer.DetailsJSON|undefined), |
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.
to avoid circular typedefs, can do header: {type: string, text: (string|undefined)}
like ListDetailsJSON
does with its items
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.
done
const pre = this._dom.createElement('pre', 'lh-code'); | ||
pre.textContent = details.text; | ||
|
||
if (details.header) { |
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.
header
seems like it's overloading the term since it's per-item here, maybe there's something better to call it (based on the screenshot, at least?). I don't have any good suggestions, though
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.
I was using label
but decided to keep it consistent with the rest of the details renderers. And it's more or less a "header" for the code snippet.
@@ -59,6 +59,19 @@ class Deprecations extends Audit { | |||
}, log.entry); | |||
}); | |||
|
|||
function makeDepractionsV2(entries) { |
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.
jsdoc would be nice here just to not require looking through the impl to see the return type
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.
done. note this does go away when we ditch extendedInfo
PTAL |
My understanding is that the deprecation system only warns on first use. So we won't see a bunch of |
@@ -47,6 +49,16 @@ class DetailsRenderer { | |||
* @param {!DetailsRenderer.DetailsJSON} text | |||
* @return {!Element} | |||
*/ | |||
_renderURL(text) { |
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.
stole this from #2019
nice! can we have the warning icon not mess with where the text starts and shift it to the left? maybe just beneath the X basically? |
@patrickhulce the debug text was aligned with "Open" and this just drops an icon in front of that text. We could align it with the audit X/check but that might be confusing? I'm ok with ditching it too. Maybe the red it enough . |
yeah just feels a bit weird, maybe I only actually want the text on the second line to be aligned with the first line instead :) |
I was hand-editing those screenshots but it started from the console of https://chromedevtools.github.io/devtools-protocol/ |
new look generally lgtm. plenty to bikeshed but nothing big. |
Oh snap. Didn't realize the viewer was Polymer. |
yeah no the original indent feels a bit better, if we just have the icon stand on its own with some margin before the text sgtm |
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.
mostly nits/code style stuff
we're going to need some docs to use some of these renderers :) This one is somewhat non-obvious how each field corresponds to where it ends up in the report
@@ -59,6 +60,23 @@ class Deprecations extends Audit { | |||
}, log.entry); | |||
}); | |||
|
|||
/** | |||
* @return {!DetailsRenderer.CodeDetailsJSON} details |
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.
{!Array<!DetailsRenderer.CodeDetailsJSON>}
?
also needs entries
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.
done
/** | ||
* @return {!DetailsRenderer.CodeDetailsJSON} details | ||
*/ | ||
function makeDepractionsV2(entries) { |
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.
any reason this declaration is nested in audit()
? Move it out?
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.
Didn't think it was worth elevating to the class. This func is going away when we ditch extended info.
@@ -36,6 +36,8 @@ class DetailsRenderer { | |||
return this._renderText(details); | |||
case 'cards': | |||
return this._renderCards(/** @type {!DetailsRenderer.CardsDetailsJSON} */ (details)); | |||
case 'code': |
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.
how do you feel about calling this something like codeSnippet
? It feels like code
will be a more primitive renderer more similar to url
or text
...just a <pre>
and maybe (someday) some syntax highlighting or something
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.
We should land the table renderer so I can use it in this PR :) Then we can make a generic code
renderer.
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.
Lolz. This happened while I was responding. BRB!
/** | ||
* @typedef {{ | ||
* type: string, | ||
* text: string, |
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.
what is text
in this case? like a description of the code snippet that follows?
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.
It's the text for the code snippet. For this audit, they're the console message text. We're just that text in <pre>
so it looks like DT's log output.
* type: string, | ||
* text: string, | ||
* url: (string|undefined), | ||
* source: string, |
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.
what about code
instead of source
(to differentiate source
meaning like the URL or wherever the code is from)
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.
url
is where the code came from :) I stuck to source
b/c it's what the protocol uses: logEntry.source
.
LOL. probably should land and tweak later. This stuff is easy to change. |
_renderText(text) { | ||
const element = this._dom.createElement('div', 'lh-text'); | ||
element.textContent = text.text; | ||
_renderURL(text) { |
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.
ha, any reason to flip these? just adds noise
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.
lost track of which was which :) Github's making it uglier than it actually is.
* lineNumber: (string|undefined) | ||
* }} | ||
*/ | ||
DetailsRenderer.CodeDetailsJSON; // eslint-disable-line no-unused-expressions |
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.
delete now? renderCode
can just take a DetailsRenderer.DetailsJSON
now, I believe
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.
done
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.
LGTM!
let's do it. |