Skip to content

Commit a24b375

Browse files
committed
Update documentation
1 parent f1e6da1 commit a24b375

File tree

6 files changed

+61
-477
lines changed

6 files changed

+61
-477
lines changed

ANALYZE.md

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Overview of what this library can analyze
44

5-
This library is designed to analyze components no matter where they are found. This means it needs to find and analyze components in both javascript, typescript and in typescript definition (when consumed from a library).
5+
This library is designed to analyze components no matter where they are found. This means it needs to find and analyze components in both javascript, typescript and in typescript definition files (when consumed from a library).
66

77
As you can see we loose a lot of information when the element is defined in a typescript definition file.
88

@@ -27,9 +27,9 @@ export class MyElement extends HTMLElement {
2727
customElements.define("my-element", MyElement);
2828
```
2929

30-
- **Tag name**: `my-element`
31-
- **Properties**: `value`, `myProp (String)`
32-
- **Attributes**: `attr1`, `attr2`
30+
- **Tag name**: `my-element`
31+
- **Properties**: `value`, `myProp (String)`
32+
- **Attributes**: `attr1`, `attr2`
3333

3434
#### In typescript definition files
3535

@@ -48,9 +48,9 @@ declare global {
4848
}
4949
```
5050

51-
- **Tag name**: `my-element`
52-
- **Properties**: `value (String)`, `myProp (String)`
53-
- **Attributes**: No attributes because `observedAttributes` is just a function that returns `string[]`
51+
- **Tag name**: `my-element`
52+
- **Properties**: `value (String)`, `myProp (String)`
53+
- **Attributes**: No attributes because `observedAttributes` is just a function that returns `string[]`
5454

5555
## [LitElement](https://lit-element.polymer-project.org/guide)
5656

@@ -78,9 +78,9 @@ export class MyElement extends LitElement {
7878
}
7979
```
8080

81-
- **Tag name**: `my-element`
82-
- **Properties**: `myProp (String)`, `prop1 (String)`, `prop2 (Number)`, `prop3 (Boolean)`, `prop4 (String)`, `prop5 (Boolean)`
83-
- **Attributes**: `prop1 (String)`, `prop-two (Number)`, `prop4 (String)`, `prop-5 (Boolean)`,
81+
- **Tag name**: `my-element`
82+
- **Properties**: `myProp (String)`, `prop1 (String)`, `prop2 (Number)`, `prop3 (Boolean)`, `prop4 (String)`, `prop5 (Boolean)`
83+
- **Attributes**: `prop1 (String)`, `prop-two (Number)`, `prop4 (String)`, `prop-5 (Boolean)`,
8484

8585
#### In typescript definition files
8686

@@ -136,10 +136,10 @@ export class MyEmbeddedComponent {
136136
}
137137
```
138138

139-
- **Tag name**: `my-embedded-component`
140-
- **Properties**: `color (String)`
141-
- **Attributes**: `color (String)`
142-
- **Events**: `change`, `todoCompleted`
139+
- **Tag name**: `my-embedded-component`
140+
- **Properties**: `color (String)`
141+
- **Attributes**: `color (String)`
142+
- **Events**: `change`, `todoCompleted`
143143

144144
### In typescript definition files
145145

@@ -179,28 +179,8 @@ declare global {
179179
}
180180
```
181181

182-
- **Tag name**: `progress-ring`
183-
- **Properties**: `decimalSize (Number)`
184-
- **Attributes**: `decimalSize (Number)`
182+
- **Tag name**: `progress-ring`
183+
- **Properties**: `decimalSize (Number)`
184+
- **Attributes**: `decimalSize (Number)`
185185

186-
## [SkateJS](https://skatejs.netlify.com/)
187-
188-
<h5 style="color: red">This is not supported yet.</h5>
189-
190-
```javascript
191-
class MyElement extends Element {
192-
static props = {
193-
name: String
194-
};
195-
}
196-
```
197-
198-
```javascript
199-
class MyElement extends Element {
200-
static get props() {
201-
return {
202-
todos: Array
203-
};
204-
}
205-
}
206-
```
186+
In addition, the entire content of HTMLElement is copied into the interfaces, so WCA makes sure to filter that out.

README.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212

1313
</p>
1414

15-
`web-component-analyzer` is a CLI that makes it possible to easily analyze web components. It analyzes your code and jsdoc in order to extract `properties`, `attributes`, `methods`, `events`, `slots` and `css custom properties`. Works with both javascript and typescript.
15+
`web-component-analyzer` is a CLI that makes it possible to easily analyze web components. It analyzes your code and jsdoc in order to extract `properties`, `attributes`, `methods`, `events`, `slots`, `css shadow parts` and `css custom properties`. Works with both javascript and typescript.
1616

17-
In addition to [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) this tool supports web components built with the following libraries:
17+
In addition to [vanilla web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) this tool supports web components built with the following libraries:
1818

1919
- [lit-element](https://github.com/Polymer/lit-element)
2020
- [polymer](https://github.com/Polymer/polymer)
2121
- [stencil](https://github.com/ionic-team/stencil) (partial)
22-
- [skatejs](https://github.com/skatejs/skatejs) (coming soon)
2322
- [open an issue for library requests](https://github.com/runem/web-component-analyzer/issues)
2423

2524
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#installation)
@@ -33,9 +32,7 @@ $ npm install -g web-component-analyzer
3332

3433
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#usage)
3534

36-
## ➤ Usage
37-
38-
### Analyze
35+
## Analyze
3936

4037
The analyze command analyses an optional `input glob` and emits the output to the console as default. When the `input glob` is omitted it will find all components excluding `node_modules`. The default format is `markdown`.
4138

@@ -46,36 +43,51 @@ The analyze command analyses an optional `input glob` and emits the output to th
4643
$ wca analyze
4744
$ wca analyze src --format markdown
4845
$ wca analyze "src/**/*.{js,ts}" --outDir components
49-
$ wca analyze my-element.js --outFile my-element.json
46+
$ wca analyze my-element.js --outFile custom-elements.json
5047
```
5148

52-
#### Options
49+
### Options
5350

5451
| Option | Type | Description |
5552
| -------------------- | -------------------------------- | ---------------------------------------------------------------------------- |
5653
| `--format FORMAT` | `markdown` \| `json` \| `vscode` | Specify output format. |
5754
| `--outFile FILE` | `file path` | Concatenate and emit output to a single file. |
5855
| `--outDir DIRECTORY` | `directory path` | Direct output to a directory where each file corresponds to a web component. |
5956

60-
### Diagnose
57+
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#api)
6158

62-
The diagnose command analyses components and emits diagnostics. Right now it only emits diagnostics for LitElement's. When the optional `input glob` is omitted it analyzes all components excluding `node_modules`. If any diagnostics are emitted this command exits with a non zero exit code.
59+
## Output Formats
6360

64-
<img src="https://user-images.githubusercontent.com/5372940/54445382-efeac700-4744-11e9-9a7b-92c5d251e124.gif" />
61+
### json
6562

66-
<!-- prettier-ignore -->
6763
```bash
68-
$ wca diagnose
69-
$ wca diagnose src
70-
$ wca diagnose "./src/**/*.{js,ts}"
71-
$ wca diagnose my-element.js
64+
wca analyze src --format json --outFile custom-elements.json
7265
```
7366

74-
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#api)
67+
This json format is for experimental and demo purposes, and is still being actively discussed. You can expect changes to this format. Please follow and contribute to the discussion at:
68+
69+
- https://github.com/webcomponents/custom-elements-json
70+
- https://github.com/w3c/webcomponents/issues/776
71+
72+
### markdown
73+
74+
```bash
75+
wca analyze src --format markdown --outDir readme
76+
```
77+
78+
Web Component Analyzer can output markdown documentation of your web components. This can either be output into a single file using `--outFile` or into multiple files using `--outDir`.
79+
80+
### vscode
81+
82+
```bash
83+
wca analyze src --format vscode --outFile vscode-html-custom-data.json
84+
```
85+
86+
VSCode supports a JSON format called [vscode custom data](https://github.com/microsoft/vscode-custom-data) for the built in html editor which is set using `html.customData` vscode setting. Web Component Analyzer can output this format.
7587

7688
## ➤ API
7789

78-
You can also use the underlying functionality of this tool if you don't want to use the CLI. More documentation coming soon.
90+
You can also use the underlying functionality of this tool if you don't want to use the CLI. Documentation will be added as soon as the API is considered stable.
7991

8092
<!-- prettier-ignore -->
8193
```typescript
@@ -90,17 +102,17 @@ analyzeComponents(sourceFile, { checker });
90102

91103
This tool extract information about your components by looking at your code directly and by looking at your JSDoc comments.
92104

93-
**Code**: In addition to `custom elements` this tool supports `lit-element`, `stencil`, `polymer` and `skatejs` web components. [Click here](https://github.com/runem/web-component-analyzer/blob/master/ANALYZE.md) for an overview of how each web component type is analyzed.
105+
**Code**: Web Component Analyzer supports multiple libraries. [Click here](https://github.com/runem/web-component-analyzer/blob/master/ANALYZE.md) for an overview of how each library is analyzed.
94106

95107
**JSDoc**: Read next section to learn more about how JSDoc is analyzed.
96108

97109
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#how-to-document-your-components-using-jsdoc)
98110

99111
## ➤ How to document your components using JSDoc
100112

101-
In addition to analyzing properties on your components this library also use JSDoc to construct the documentation. It's especially a good idea to use JSDoc for documenting `slots`, `events` and `cssprops` as these are under no circumstances analyzed statically by this tool as of now.
113+
In addition to analyzing the code of your components, this library also use JSDoc to construct the documentation. It's especially a good idea to use JSDoc for documenting `slots`, `events`, `css custom properties` and `css shadow parts` as these not analyzed statically by this tool as of now (except when constructing a CustomEvent within your component).
102114

103-
Here's an example including all supported JSDoc tags. All tags are on the the form `@tag {type} name - comment`.
115+
Here's an example including all supported JSDoc tags. All JSDoc tags are on the the form `@tag {type} name - comment`.
104116

105117
<!-- prettier-ignore -->
106118
```javascript
@@ -150,15 +162,15 @@ class MyElement extends HTMLElement {
150162

151163
### Overview of supported JSDoc tags
152164

153-
| JSDoc Tag | Description |
154-
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
155-
| `@element` | Gives your component a tag name. This JSDoc tag is especially useful if your 'customElements.define` is called dynamically eg. using a custom function. |
156-
| `@fires` | Documents events. |
157-
| `@slot` | Documents slots. Using an empty name here documents the unnamed (default) slot. |
158-
| `@attr` or `@attribute` | Documents an attribute on your component. |
159-
| `@prop` or `@property` | Documents a property on your component. |
160-
| `@cssprop` or `@cssproperty` | Documents a css custom property on your component. |
161-
| `@csspart` | Documents a css shadow part on your component. |
165+
| JSDoc Tag | Description |
166+
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
167+
| `@element` | Gives your component a tag name. This JSDoc tag is useful if your 'customElements.define` is called dynamically eg. using a custom function. |
168+
| `@fires` | Documents events. |
169+
| `@slot` | Documents slots. Using an empty name here documents the unnamed (default) slot. |
170+
| `@attr` or `@attribute` | Documents an attribute on your component. |
171+
| `@prop` or `@property` | Documents a property on your component. |
172+
| `@cssprop` or `@cssproperty` | Documents a css custom property on your component. |
173+
| `@csspart` | Documents a css shadow part on your component. |
162174

163175
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#contributors)
164176

blueprint.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)