Skip to content

Commit 993d853

Browse files
committed
adding native plugins section
1 parent 78beeba commit 993d853

9 files changed

Lines changed: 205 additions & 2 deletions

File tree

‎docs/native/plugins/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

‎scripts/native.js‎

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
const fetch = require("node-fetch");
2+
const fs = require("fs");
3+
const path = require("path");
4+
const nativeJSON = require("./data/native.json");
5+
6+
(async function() {
7+
// console.log(cliJSON);
8+
9+
nativeJSON.map(writePage);
10+
}());
11+
12+
function writePage(page) {
13+
const data = [
14+
renderFrontmatter(page),
15+
renderReadme(page),
16+
// renderUsage(page),
17+
// renderProperties(page),
18+
// renderEvents(page),
19+
// renderMethods(page),
20+
// renderParts(page),
21+
// renderCustomProps(page),
22+
// renderSlots(page)
23+
].join("");
24+
25+
const path = `docs/native/plugins/${page.packageName.replace('@ionic-native/','')}.md`;
26+
fs.writeFileSync(path, data);
27+
}
28+
29+
function renderFrontmatter({ displayName }) {
30+
const frontmatter = {
31+
title: displayName
32+
};
33+
34+
return `---
35+
${Object.entries(frontmatter)
36+
.map(([key, value]) => `${key}: ${value}`)
37+
.join("\n")}
38+
---
39+
40+
`;
41+
}
42+
43+
function renderReadme({ description, displayName }) {
44+
return `
45+
# ${displayName}
46+
47+
${description}`;
48+
}
49+
50+
// function renderUsage({ usage }) {
51+
// const keys = Object.keys(usage);
52+
53+
// if (keys.length === 0) {
54+
// return "";
55+
// }
56+
57+
// if (keys.length === 1) {
58+
// return `
59+
// ## Usage
60+
61+
// ${usage[keys[0]]}
62+
// `;
63+
// }
64+
65+
// return `
66+
// ## Usage
67+
68+
// <Tabs defaultValue="${keys[0]}" values={[${keys
69+
// .map(key => `{ value: '${key}', label: '${key.toUpperCase()}' }`)
70+
// .join(", ")}]}>
71+
72+
// ${Object.entries(usage)
73+
// .map(
74+
// ([key, value]) => `
75+
// <TabItem value="${key}">
76+
77+
// ${value}
78+
79+
// </TabItem>
80+
// `
81+
// )
82+
// .join("\n")}
83+
// </Tabs>
84+
// `;
85+
// }
86+
87+
// function renderProperties({ props: properties }) {
88+
// if (properties.length === 0) {
89+
// return "";
90+
// }
91+
92+
// return `
93+
// ## Properties
94+
95+
// ${properties
96+
// .map(
97+
// prop => `
98+
// ### ${prop.name}
99+
100+
// | | |
101+
// | --- | --- |
102+
// | **Description** | ${prop.docs.split("\n").join("<br />")} |
103+
// | **Attribute** | \`${prop.attr}\` |
104+
// | **Type** | \`${prop.type.replace(/\|/g, "\\|")}\` |
105+
// | **Default** | \`${prop.default}\` |
106+
107+
// `
108+
// )
109+
// .join("\n")}
110+
// `;
111+
// }
112+
113+
// function renderEvents({ events }) {
114+
// if (events.length === 0) {
115+
// return "";
116+
// }
117+
118+
// return `
119+
// ## Events
120+
121+
// | Name | Description |
122+
// | --- | --- |
123+
// ${events.map(event => `| \`${event.event}\` | ${event.docs} |`).join("\n")}
124+
125+
// `;
126+
// }
127+
128+
// function renderMethods({ methods }) {
129+
// if (methods.length === 0) {
130+
// return "";
131+
// }
132+
133+
// return `
134+
// ## Methods
135+
136+
// ${methods
137+
// .map(
138+
// method => `
139+
// ### ${method.name}
140+
141+
// | | |
142+
// | --- | --- |
143+
// | **Description** | ${method.docs.split("\n").join("<br />")} |
144+
// | **Signature** | \`${method.signature.replace(/\|/g, "\\|")}\` |
145+
// `
146+
// )
147+
// .join("\n")}
148+
149+
// `;
150+
// }
151+
152+
// function renderParts({ parts }) {
153+
// if (parts.length === 0) {
154+
// return "";
155+
// }
156+
157+
// return `
158+
// ## CSS Shadow Parts
159+
160+
// | Name | Description |
161+
// | --- | --- |
162+
// ${parts.map(prop => `| \`${prop.name}\` | ${prop.docs} |`).join("\n")}
163+
164+
// `;
165+
// }
166+
167+
// function renderCustomProps({ styles: customProps }) {
168+
// if (customProps.length === 0) {
169+
// return "";
170+
// }
171+
172+
// return `
173+
// ## CSS Custom Properties
174+
175+
// | Name | Description |
176+
// | --- | --- |
177+
// ${customProps.map(prop => `| \`${prop.name}\` | ${prop.docs} |`).join("\n")}
178+
179+
// `;
180+
// }
181+
182+
// function renderSlots({ slots }) {
183+
// if (slots.length === 0) {
184+
// return "";
185+
// }
186+
187+
// return `
188+
// ## Slots
189+
190+
// | Name | Description |
191+
// | --- | --- |
192+
// ${slots.map(slot => `| \`${slot.name}\` | ${slot.docs} |`).join("\n")}
193+
194+
// `;
195+
// }
196+

‎sidebars.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ module.exports = {
477477
items: [
478478
{
479479
type: 'autogenerated',
480-
dirName: 'cli/commands', // Generate sidebar slice from docs/guides
480+
dirName: 'cli/commands', // Generate section automatically based on files
481481
}
482482
],
483483
},
@@ -501,7 +501,12 @@ module.exports = {
501501
{
502502
type: 'category',
503503
label: 'Plugins',
504-
items: [],
504+
items: [
505+
{
506+
type: 'autogenerated',
507+
dirName: 'native/plugins', // Generate section automatically based on files
508+
}
509+
],
505510
},
506511
],
507512
};
5.15 KB
Loading
25.4 KB
Loading
3.9 KB
Loading
21 KB
Loading
16.3 KB
Loading
11.4 KB
Loading

0 commit comments

Comments
 (0)