forked from mirrors/gecko-dev
This is still far from perfect given the limitations of the Storybook web components package, but I figured this was worth putting up since it's still an improvement over the current state of our args tables (I think). I'm mostly leaving the default generated `custom-elements-manifest.json` alone save for filtering some internal properties we don't want documented since they shouldn't really be accessed directly. If it seems too strange to just have the `aria-label` attr documented we could possibly remove `attributes` from the docs for now (this happens because it's the only attr where the name is different from the property name). Open to feedback/thoughts on if this is useful or too wonky for now given the weirdness around how Storybook creates naming collisions. Differential Revision: https://phabricator.services.mozilla.com/D162599
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/**
|
|
* Custom element manifest analyzer plugin to remove specific properties from
|
|
* custom-elements.json that we don't want to document in our Storybook props tables.
|
|
*/
|
|
function removeExcludedProperties() {
|
|
const EXCLUDED_PROPERTIES = [
|
|
"SUPPORT_URL",
|
|
"LOCAL_NAME",
|
|
"queries",
|
|
"stylesheetUrl",
|
|
"shadowRootOptions",
|
|
];
|
|
return {
|
|
packageLinkPhase({ customElementsManifest }) {
|
|
customElementsManifest?.modules?.forEach(module => {
|
|
module?.declarations?.forEach(declaration => {
|
|
if (declaration.members != null) {
|
|
declaration.members = declaration.members.filter(member => {
|
|
return (
|
|
!member.kind === "field" ||
|
|
!EXCLUDED_PROPERTIES.includes(member.name)
|
|
);
|
|
});
|
|
}
|
|
});
|
|
});
|
|
},
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Custom element manifest config. Controls how we parse directories for
|
|
* custom elements to populate custom-elements.json.
|
|
*/
|
|
const config = {
|
|
globs: ["../../../toolkit/content/widgets/**/*.mjs"],
|
|
exclude: [
|
|
"../../../toolkit/content/widgets/**/*.stories.mjs",
|
|
"../../../toolkit/content/widgets/vendor/**",
|
|
"../../../toolkit/content/widgets/lit-utils.mjs",
|
|
],
|
|
outdir: ".",
|
|
litelement: true,
|
|
plugins: [removeExcludedProperties()],
|
|
};
|
|
|
|
export default config;
|