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

Script/ce-update #571

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/muon/components/cta/src/cta-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import styles from './cta-styles.css';
* A call-to-action allows users to take action once they are ready for it.
*
* @element cta
* @placement {"div"|"muon-form"}
*/

export class Cta extends ScopedElementsMixin(MuonElement) {
Expand Down
1 change: 1 addition & 0 deletions packages/muon/components/icon/src/icon-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import styles from './icon-styles.css';
* Icons are visual symbols that are used to represent objects or actions to reduce cognitive load to a user.
*
* @element icon
* @placement {"muon-form"}
*/

export class Icon extends MuonElement {
Expand Down
4 changes: 4 additions & 0 deletions packages/muon/components/inputter/src/inputter-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import slottedStyles from './inputter-styles.slotted.css';
* date, tel, number, textarea, search.
*
* @element inputter
* @slot {"label"} label - The label for the input.
* @slot {"input"|"select"} - The form element passed in such as input, select, textarea.
* @slot {"div"} tip-details - The tip details related to the helper.
* @placement {"muon-form"}
*/

export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(MuonElement))) {
Expand Down
31 changes: 30 additions & 1 deletion packages/muon/scripts/utils/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,32 @@ const getAliasPaths = (type) => {
return undefined;
};

const updateAnalyzedResults = (results, jsonOutput) => {
results.forEach((result) => {
const tagName = result.componentDefinitions[0]?.tagName;
const declaration = result.componentDefinitions[0]?.declaration;

const slots = declaration.slots.map((slot) => {
return {
name: slot.name,
description: slot.jsDoc.description,
permittedTagNames: slot.permittedTagNames
}
});
const placements = declaration?.jsDoc.tags?.filter((jsDocTag) => jsDocTag.tag === 'placement')?.[0]?.comment;

if (slots || placements) {
const jsonTag = jsonOutput.tags.find((tag) => tag.name === tagName);
if (slots?.length > 0) {
jsonTag["slots"] = slots;
}
if (placements) {
jsonTag["placements"] = placements.replaceAll('"', '').replace('{', '').replace('}', '').split('|');
}
}
});
};

const sourceFilesAnalyzer = async () => {
const files = await findComponents();
const paths = getAliasPaths('glob');
Expand Down Expand Up @@ -233,7 +259,10 @@ const sourceFilesAnalyzer = async () => {
console.error('---------------------------------------------');
process.exit(1);
}
return transformAnalyzerResult('json', results, program);
const jsonResults = transformAnalyzerResult('json', results, program);
const outputJSON = JSON.parse(jsonResults);
updateAnalyzedResults(results, outputJSON);
return JSON.stringify(outputJSON, null, 2);
};

const styleDictionary = async () => {
Expand Down
Loading