@api-viewer/docs
Advanced tools
Comparing version 1.0.0-pre.4 to 1.0.0-pre.5
@@ -152,2 +152,10 @@ { | ||
"kind": "field", | ||
"name": "methods", | ||
"type": { | ||
"text": "ClassMethod[]" | ||
}, | ||
"default": "[]" | ||
}, | ||
{ | ||
"kind": "field", | ||
"name": "slots", | ||
@@ -154,0 +162,0 @@ "type": { |
import { LitElement, html } from 'lit'; | ||
import { until } from 'lit/directives/until.js'; | ||
import { emptyDataWarning, getCustomElements, getElementData, getPublicFields, hasCustomElements, ManifestMixin } from '@api-viewer/common/lib/index.js'; | ||
import { emptyDataWarning, getCustomElements, getElementData, getPublicFields, getPublicMethods, hasCustomElements, ManifestMixin } from '@api-viewer/common/lib/index.js'; | ||
import { parse } from './utils/markdown.js'; | ||
@@ -14,2 +14,3 @@ import './layout.js'; | ||
const props = getPublicFields(data.members); | ||
const methods = getPublicMethods(data.members); | ||
return html ` | ||
@@ -38,2 +39,3 @@ <header part="header"> | ||
.attrs=${data.attributes ?? []} | ||
.methods=${methods} | ||
.events=${data.events ?? []} | ||
@@ -40,0 +42,0 @@ .slots=${data.slots ?? []} |
import { LitElement, PropertyValues, TemplateResult } from 'lit'; | ||
import { Attribute, ClassField, CssCustomProperty, CssPart, Event, Slot } from '@api-viewer/common/lib/index.js'; | ||
import { Attribute, ClassField, ClassMethod, CssCustomProperty, CssPart, Event, Slot } from '@api-viewer/common/lib/index.js'; | ||
import '@api-viewer/tabs'; | ||
@@ -8,2 +8,3 @@ declare class ApiDocsLayout extends LitElement { | ||
attrs: Attribute[]; | ||
methods: ClassMethod[]; | ||
slots: Slot[]; | ||
@@ -10,0 +11,0 @@ events: Event[]; |
@@ -56,2 +56,17 @@ import { __decorate } from "tslib"; | ||
}; | ||
const renderMethod = (method) => { | ||
const params = method.parameters || []; | ||
const type = method.return?.type?.text || 'void'; | ||
return html ` | ||
<span part="docs-method"> | ||
${method.name}(<span part="docs-method-params" | ||
>${params.map((param, idx) => html `<span part="docs-param-name">${param.name}</span>: | ||
<span part="docs-param-type">${param.type?.text}</span>${idx === | ||
params.length - 1 | ||
? '' | ||
: ', '}`)}</span | ||
>)</span | ||
><span part="docs-method-type">: ${type}</span> | ||
`; | ||
}; | ||
class ApiDocsLayout extends LitElement { | ||
@@ -63,2 +78,3 @@ constructor() { | ||
this.attrs = []; | ||
this.methods = []; | ||
this.slots = []; | ||
@@ -73,4 +89,12 @@ this.events = []; | ||
render() { | ||
const { slots, props, attrs, events, cssParts, cssProps } = this; | ||
const emptyDocs = [props, attrs, slots, events, cssProps, cssParts].every((arr) => arr.length === 0); | ||
const { slots, props, attrs, methods, events, cssParts, cssProps } = this; | ||
const emptyDocs = [ | ||
props, | ||
attrs, | ||
methods, | ||
slots, | ||
events, | ||
cssProps, | ||
cssParts | ||
].every((arr) => arr.length === 0); | ||
const attributes = (attrs || []).filter((x) => !props.some((y) => y.name === x.fieldName)); | ||
@@ -96,2 +120,5 @@ return emptyDocs | ||
`)} | ||
${renderTab('Methods', methods, html ` | ||
${methods.map((method) => renderItem('method', renderMethod(method), method.description))} | ||
`)} | ||
${renderTab('Slots', slots, html ` | ||
@@ -136,2 +163,5 @@ ${slots.map(({ name, description }) => renderItem('slot', name, description))} | ||
property({ attribute: false }) | ||
], ApiDocsLayout.prototype, "methods", void 0); | ||
__decorate([ | ||
property({ attribute: false }) | ||
], ApiDocsLayout.prototype, "slots", void 0); | ||
@@ -138,0 +168,0 @@ __decorate([ |
@@ -88,2 +88,10 @@ import { css } from 'lit'; | ||
[part$='params'] { | ||
color: var(--ave-item-color); | ||
} | ||
[part$='type'] { | ||
color: var(--ave-secondary-color); | ||
} | ||
.accent { | ||
@@ -90,0 +98,0 @@ color: var(--ave-accent-color); |
{ | ||
"name": "@api-viewer/docs", | ||
"version": "1.0.0-pre.4", | ||
"version": "1.0.0-pre.5", | ||
"publishConfig": { | ||
@@ -35,4 +35,4 @@ "access": "public" | ||
"dependencies": { | ||
"@api-viewer/common": "^1.0.0-pre.4", | ||
"@api-viewer/tabs": "^1.0.0-pre.4", | ||
"@api-viewer/common": "^1.0.0-pre.5", | ||
"@api-viewer/tabs": "^1.0.0-pre.5", | ||
"@types/dompurify": "^2.3.1", | ||
@@ -39,0 +39,0 @@ "@types/marked": "^4.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43182
626