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

docs: add plugin guide #8728

Merged
merged 11 commits into from
May 3, 2019
Merged

docs: add plugin guide #8728

merged 11 commits into from
May 3, 2019

Conversation

patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Apr 30, 2019

Summary
Well this took much longer than expected :)

In a google doc it turned out to be ~15 pages though so that makes a little more sense and I hope it's fairly comprehensive 😆

Only one functionality change (fairly big): Exposes our NetworkRecords computed artifact on the public Audit interface

docs/plugins.md Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated

Lighthouse plugins are a way to extend the functionality of Lighthouse with insight from domain experts (that's you!) and easily share this extra functionality with other Lighthouse users. At its core, a plugin is a node module that implements a set of checks that will get run by Lighthouse and added to the report as a new category.

### Do You Need a Custom Audit?
Copy link
Member

Choose a reason for hiding this comment

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

i dont really understand this section. mostly it feels kinda unnecessary. i have problems with the content too.. so maybe you'll just agree it's not important and we can ignore all that. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

haha, fair points! My dangling sentence was going to say "consider the criteria for Lighthouse audits when adding your own" (i.e. it's actionable, it's impactful, etc) but if we feel like this is getting too preachy that plugin devs know what they're doing, I understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(removed it already but wanted to leave the point here for thought)

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
- `title: string` **REQUIRED** - The display name of the group in the report.
- `description: string` *OPTIONAL* - A more detailed description of the group's purpose.

### Plugin Audits
Copy link
Member

Choose a reason for hiding this comment

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

i like calling these "plugin audits" rather than custom audits. :) seems good!

docs/plugins.md Show resolved Hide resolved
@paulirish paulirish mentioned this pull request Apr 30, 2019
67 tasks
@@ -73,5 +73,6 @@ lighthouse.getAuditList = Runner.getAuditList;
lighthouse.traceCategories = require('./gather/driver').traceCategories;
lighthouse.Audit = require('./audits/audit');
lighthouse.Gatherer = require('./gather/gatherers/gatherer');
lighthouse.NetworkRecords = require('./computed/network-records.js');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wanted to call this change out as the only real functionality change, but fairly large impact on our public API :)

Copy link
Member

Choose a reason for hiding this comment

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

hmm, I don't really have a problem with this one in particular, but this won't work if/when we end up exposing more and more computed artifacts. Do we need a namespace for them? Just point folks at the directory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah at that point I think we should restructure a lot of our exports and expose some aliases so folks can require('lighthouse/types') require('lighthouse/computed') etc and we're free to move around files as we wish

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

lots of ways for these docs to evolve, but i'm happy for this as a start.

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
@brendankenny
Copy link
Member

I'll take a stab tonight or in the morning, but looking great so far

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.

this is looking good. Some change suggestions

@@ -73,5 +73,6 @@ lighthouse.getAuditList = Runner.getAuditList;
lighthouse.traceCategories = require('./gather/driver').traceCategories;
lighthouse.Audit = require('./audits/audit');
lighthouse.Gatherer = require('./gather/gatherers/gatherer');
lighthouse.NetworkRecords = require('./computed/network-records.js');
Copy link
Member

Choose a reason for hiding this comment

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

hmm, I don't really have a problem with this one in particular, but this won't work if/when we end up exposing more and more computed artifacts. Do we need a namespace for them? Just point folks at the directory?

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated
| ------------------------------------ | ------ | ------------- |
| Add custom audits | ✅ | ✅ |
| Add custom categories | ✅ | ✅ |
| Easily sharable via NPM | ✅ | ❌ |
Copy link
Member

Choose a reason for hiding this comment

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

you'd just need an absolute path to the config in an npm module, but sure :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah sharable via NPM felt slightly off, what I want to get at here is that custom configs aren't sustainably sharable. you can only ever use one, they can't extend each other, etc. plugins are the real sharable way to offer bits of lighthouse logic.

better name/phrase to capture that complex thought? :)

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Show resolved Hide resolved
Co-Authored-By: patrickhulce <patrick.hulce@gmail.com>
Co-Authored-By: patrickhulce <patrick.hulce@gmail.com>
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.

should we add a section like eslint does with recommended npm keywords? https://eslint.org/docs/developer-guide/working-with-plugins#share-plugins

This is really good :) Added some more suggestions, but I think this is good to go

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved

- `title: string` **REQUIRED** - The display name of the plugin's category in the report.
- `description: string` _OPTIONAL_ - A more detailed description of the category's purpose.
- `manualDescription: string` _OPTIONAL_ - A more detailed description of all of the manual audits in a plugin. Only use this if you've added manual audits.
Copy link
Member

Choose a reason for hiding this comment

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

ha, I half feel like we shouldn't even mention this... ("what's a manual audit?")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Heh, yeah I don't think we should encourage them for sure :) but feels like we should at least document what it is

docs/plugins.md Show resolved Hide resolved
docs/plugins.md Outdated

It is an object whose keys are the group IDs and whose values are objects with the following properties:

- `title: string` **REQUIRED** - The display name of the group in the report.
Copy link
Member

Choose a reason for hiding this comment

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

maybe put these above the screenshots? I forgot we were still talking about groups by the time I passed the images :)

> Images need alt attributes.

> 4.8.4.4 Requirements for providing text to act as an alternative for images
> Except where otherwise specified, the alt attribute.... 10,000 words later... and that is everything you need to know about the `alt` attribute!
Copy link
Member

Choose a reason for hiding this comment

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

😆

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Show resolved Hide resolved
Co-Authored-By: patrickhulce <patrick.hulce@gmail.com>
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.

3 participants