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

Add line/code renderer to deprecations audit #2145

Merged
merged 7 commits into from
May 4, 2017
Merged

Conversation

ebidel
Copy link
Contributor

@ebidel ebidel commented May 4, 2017

screen shot 2017-05-03 at 9 16 57 pm

Copy link
Member

@brendankenny brendankenny left a 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),
Copy link
Member

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

Copy link
Contributor Author

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) {
Copy link
Member

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

Copy link
Contributor Author

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) {
Copy link
Member

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

Copy link
Contributor Author

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

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

PTAL

@paulirish
Copy link
Member

do we want to group by the entry text? in case there are a bunch of /deep/ errors (or whatever) from various locations?

Also how about visualizing similar to how they're shown in the console, where the location is on the right side:

image

@paulirish
Copy link
Member

Combing the two might look something like this:

image

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

My understanding is that the deprecation system only warns on first use. So we won't see a bunch of /deep/. Not sure about violations. What pages are you testing against in those screenshots?

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

Looks like the console now. I also added a warning icon for audit errors.

screen shot 2017-05-04 at 11 09 23 am

@@ -47,6 +49,16 @@ class DetailsRenderer {
* @param {!DetailsRenderer.DetailsJSON} text
* @return {!Element}
*/
_renderURL(text) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

stole this from #2019

@patrickhulce
Copy link
Collaborator

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?

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

@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 .

@patrickhulce
Copy link
Collaborator

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 :)

@paulirish
Copy link
Member

So we won't see a bunch of /deep/. Not sure about violations. What pages are you testing against in those screenshots?

I was hand-editing those screenshots but it started from the console of https://chromedevtools.github.io/devtools-protocol/

@paulirish
Copy link
Member

new look generally lgtm. plenty to bikeshed but nothing big.

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

Here's left aligned. Not sure that it's better. WDYT?

screen shot 2017-05-04 at 1 36 03 pm

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

Oh snap. Didn't realize the viewer was Polymer.

@patrickhulce
Copy link
Collaborator

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

Copy link
Member

@brendankenny brendankenny left a 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
Copy link
Member

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

Copy link
Contributor Author

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) {
Copy link
Member

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?

Copy link
Contributor Author

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':
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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,
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 text in this case? like a description of the code snippet that follows?

Copy link
Contributor Author

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,
Copy link
Member

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)

Copy link
Contributor Author

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.

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

Also:

screen shot 2017-05-04 at 1 41 37 pm

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

Non red also looks decent:

screen shot 2017-05-04 at 1 47 05 pm

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

LOL. probably should land and tweak later. This stuff is easy to change.

@patrickhulce
Copy link
Collaborator

ooooh I like this one :) haha yeah it's all good
image

@ebidel
Copy link
Contributor Author

ebidel commented May 4, 2017

This is using the table renderer now. Simplifies things a big and renderCode became a standalone renderer for <pre>.

The table render needs some UI love, but we can do that later when the rest of the audits are in that need it.

screen shot 2017-05-04 at 3 17 09 pm

_renderText(text) {
const element = this._dom.createElement('div', 'lh-text');
element.textContent = text.text;
_renderURL(text) {
Copy link
Collaborator

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

Copy link
Contributor Author

@ebidel ebidel May 4, 2017

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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM!

@paulirish
Copy link
Member

let's do it.

@paulirish paulirish merged commit d2518c5 into master May 4, 2017
@paulirish paulirish deleted the deprecations branch May 4, 2017 23:09
paulirish pushed a commit to paulirish/lighthouse that referenced this pull request May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants