Skip to content

Commit 2fa74f0

Browse files
committed
add css properties to JSON output
1 parent 9c63fd2 commit 2fa74f0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/cli/transformer/json/json-transformer.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { EventDeclaration } from "../../../analyze/types/event-types";
88
import { JsDoc } from "../../../analyze/types/js-doc";
99
import { flatten } from "../../util";
1010
import { WcaCliConfig } from "../../wca-cli-arguments";
11-
import { HtmlData, HtmlDataAttribute, HtmlDataEvent, HtmlDataProperty, HtmlDataSlot, HtmlDataTag } from "./vscode-html-data";
11+
import { HtmlData, HtmlDataAttribute, HtmlDataEvent, HtmlDataProperty, HtmlDataSlot, HtmlDataTag, HtmlDataCssProperty } from "./vscode-html-data";
12+
import { ComponentCSSProperty } from "../../../analyze";
1213

1314
/**
1415
* Transforms results to json.
@@ -49,15 +50,26 @@ function definitionToHtmlDataTag(definition: ComponentDefinition, checker: TypeC
4950
const slots = definition.declaration.slots
5051
.map(e => componentSlotToHtmlDataSlot(e, checker))
5152
.filter((val): val is NonNullable<typeof val> => val != null);
52-
53+
const cssProperties = definition.declaration.cssProperties
54+
.map(p => componentCssPropToHtmlCssProp(p, checker))
55+
.filter((val): val is NonNullable<typeof val> => val != null);
5356
return {
5457
name: definition.tagName,
5558
description: getDescriptionFromJsDoc(definition.declaration.jsDoc),
5659
jsDoc: getJsDocTextFromJsDoc(definition.declaration.jsDoc),
5760
attributes,
5861
properties,
5962
events,
60-
slots
63+
slots,
64+
cssProperties
65+
};
66+
}
67+
68+
function componentCssPropToHtmlCssProp(prop: ComponentCSSProperty, checker: TypeChecker): HtmlDataCssProperty | undefined {
69+
return {
70+
name: prop.name || "",
71+
description: getDescriptionFromJsDoc(prop.jsDoc),
72+
jsDoc: getJsDocTextFromJsDoc(prop.jsDoc)
6173
};
6274
}
6375

src/cli/transformer/json/vscode-html-data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export interface HtmlDataSlot extends HtmlDataMember {}
2727

2828
export interface HtmlDataEvent extends HtmlDataMember {}
2929

30+
export interface HtmlDataCssProperty extends HtmlDataMember {}
31+
3032
export interface HtmlDataTag {
3133
name: string;
3234
description?: string;
@@ -37,6 +39,7 @@ export interface HtmlDataTag {
3739
properties?: HtmlDataProperty[];
3840
slots?: HtmlDataSlot[];
3941
events?: HtmlDataEvent[];
42+
cssProperties?: HtmlDataCssProperty[];
4043
}
4144

4245
export interface HtmlDataV2 {

0 commit comments

Comments
 (0)