Skip to content

Commit

Permalink
Adds parsing of type in js doc css property declaration.
Browse files Browse the repository at this point in the history
ex.  @cssprop {Color}  --my-element-color - Controls the color of this element

- outputs type in JSON

ex.  {
          "name": "--my-element-color",
          "description": "Controls the color of this element",
          "type": "Color"
        }
  • Loading branch information
aarondrabeck committed Nov 15, 2019
1 parent c3fe025 commit a341aaa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dev/src/custom-element/my-custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @fires change - Dispatched when this element changes
* @slot - Default content placed in the body of this element
* @slot header - Content placed in the header of this element
* @cssprop --my-element-color - Controls the color of this element
* @cssprop {Color} --my-element-color - Controls the color of this element
* @cssprop {Length} --my-element-font-size - Controls the font-size in this element
*/
export class MyCustomElement extends HTMLElement {
/**
Expand Down
3 changes: 2 additions & 1 deletion src/analyze/flavors/js-doc/parse-declaration-css-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function parseDeclarationCSSProps(node: Node, context: ParseComponentMemb
if (parsed.name != null) {
return {
name: parsed.name,
jsDoc: parsed.comment != null ? { comment: parsed.comment } : undefined
jsDoc: parsed.comment != null ? { comment: parsed.comment } : undefined,
type: parsed.type
} as ComponentCSSProperty;
}
},
Expand Down
1 change: 1 addition & 0 deletions src/analyze/types/component-css-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { JsDoc } from "./js-doc";
export interface ComponentCSSProperty {
name: string;
jsDoc?: JsDoc;
type?: string;
}
5 changes: 4 additions & 1 deletion src/cli/transformer/json/custom-elements-json-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export interface HtmlDataSlot extends HtmlDataMember {}

export interface HtmlDataEvent extends HtmlDataMember {}

export interface HtmlDataCssProperty extends HtmlDataMember {}
export interface HtmlDataCssProperty extends HtmlDataMember {
// Suggested fields:
type?: string;
}

export interface HtmlDataCssPart extends HtmlDataMember {}

Expand Down
3 changes: 2 additions & 1 deletion src/cli/transformer/json/json-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function componentCssPropToHtmlCssProp(prop: ComponentCSSProperty, checker: Type
return {
name: prop.name || "",
description: getDescriptionFromJsDoc(prop.jsDoc),
jsDoc: getJsDocTextFromJsDoc(prop.jsDoc)
jsDoc: getJsDocTextFromJsDoc(prop.jsDoc),
type: prop.type
};
}

Expand Down

0 comments on commit a341aaa

Please sign in to comment.