| 3 | * the _data/api.11tydata.js script. |
| 4 | */ |
| 5 | module.exports = class Docs { |
| 6 | data() { |
| 7 | return { |
| 8 | layout: 'page.11ty.cjs', |
| 9 | title: '<my-element> ⌲ Docs', |
| 10 | }; |
| 11 | } |
| 12 | |
| 13 | render(data) { |
| 14 | const manifest = data.api['11tydata'].customElements; |
| 15 | const elements = manifest.modules.reduce( |
| 16 | (els, module) => |
| 17 | els.concat( |
| 18 | module.declarations?.filter((dec) => dec.customElement) ?? [] |
| 19 | ), |
| 20 | [] |
| 21 | ); |
| 22 | return ` |
| 23 | <h1>API</h1> |
| 24 | ${elements |
| 25 | .map( |
| 26 | (element) => ` |
| 27 | <h2><${element.tagName}></h2> |
| 28 | <div> |
| 29 | ${element.description} |
| 30 | </div> |
| 31 | ${renderTable( |
| 32 | 'Attributes', |
| 33 | ['name', 'description', 'type.text', 'default'], |
| 34 | element.attributes |
| 35 | )} |
| 36 | ${renderTable( |
| 37 | 'Properties', |
| 38 | ['name', 'attribute', 'description', 'type.text', 'default'], |
| 39 | element.members.filter((m) => m.kind === 'field') |
| 40 | )} |
| 41 | ${renderTable( |
| 42 | 'Methods', |
| 43 | ['name', 'parameters', 'description', 'return.type.text'], |
| 44 | element.members |
| 45 | .filter((m) => m.kind === 'method' && m.privacy !== 'private') |
| 46 | .map((m) => ({ |
| 47 | ...m, |
| 48 | parameters: renderTable( |
| 49 | '', |
| 50 | ['name', 'description', 'type.text'], |
| 51 | m.parameters |
| 52 | ), |
| 53 | })) |
| 54 | )} |
| 55 | ${renderTable('Events', ['name', 'description'], element.events)} |
| 56 | ${renderTable( |
| 57 | 'Slots', |
| 58 | [['name', '(default)'], 'description'], |
| 59 | element.slots |
| 60 | )} |
| 61 | ${renderTable( |
| 62 | 'CSS Shadow Parts', |
nothing calls this directly
no outgoing calls
no test coverage detected