Skip to content

Commit 6d5407b

Browse files
committed
chipping away at native docgen
1 parent dd00f61 commit 6d5407b

File tree

5 files changed

+62
-165
lines changed

5 files changed

+62
-165
lines changed

scripts/native.js

Lines changed: 38 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const fs = require("fs");
22
const nativeJSON = require("./data/native.json");
33
const utils = require('./utils.js');
44

5+
56
(async function() {
67
// console.log(cliJSON);
78

@@ -14,6 +15,7 @@ function writePage(page) {
1415
renderImports(page),
1516
renderIntro(page),
1617
renderSalesCTA(page),
18+
renderInstallation(page),
1719
// renderProperties(page),
1820
// renderEvents(page),
1921
// renderMethods(page),
@@ -43,6 +45,10 @@ ${Object.entries(frontmatter)
4345
function renderImports({}) {
4446
return `
4547
import DocsCard from '@site/src/components/DocsCard';
48+
import DocsButton from '@site/src/components/DocsButton';
49+
import Tabs from '@theme/Tabs';
50+
import TabItem from '@theme/TabItem';
51+
import CodeBlock from '@theme/CodeBlock';
4652
`;
4753
}
4854

@@ -61,161 +67,45 @@ ${description}
6167
function renderSalesCTA({}) {
6268
return `
6369
<h2>Stuck on a Cordova issue?</h2>
64-
<DocsCard class="cordova-ee-card" header="Don't waste precious time on plugin issues." href="https://ionicframework.com/sales?product_of_interest=Ionic%20Native">
70+
<DocsCard className="cordova-ee-card" header="Don't waste precious time on plugin issues." href="https://ionicframework.com/sales?product_of_interest=Ionic%20Native">
6571
<div>
6672
<img src="/docs/icons/native-cordova-bot.png" class="cordova-ee-img" />
6773
<p>If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.</p>
68-
<docs-button class="native-ee-detail">Contact Us Today!</docs-button>
74+
<DocsButton className="native-ee-detail">Contact Us Today!</DocsButton>
6975
</div>
7076
</DocsCard>
7177
7278
`;
7379
}
7480

75-
// function renderUsage({ usage }) {
76-
// const keys = Object.keys(usage);
77-
78-
// if (keys.length === 0) {
79-
// return "";
80-
// }
81-
82-
// if (keys.length === 1) {
83-
// return `
84-
// ## Usage
85-
86-
// ${usage[keys[0]]}
87-
// `;
88-
// }
89-
90-
// return `
91-
// ## Usage
92-
93-
// <Tabs defaultValue="${keys[0]}" values={[${keys
94-
// .map(key => `{ value: '${key}', label: '${key.toUpperCase()}' }`)
95-
// .join(", ")}]}>
96-
97-
// ${Object.entries(usage)
98-
// .map(
99-
// ([key, value]) => `
100-
// <TabItem value="${key}">
101-
102-
// ${value}
103-
104-
// </TabItem>
105-
// `
106-
// )
107-
// .join("\n")}
108-
// </Tabs>
109-
// `;
110-
// }
111-
112-
// function renderProperties({ props: properties }) {
113-
// if (properties.length === 0) {
114-
// return "";
115-
// }
116-
117-
// return `
118-
// ## Properties
119-
120-
// ${properties
121-
// .map(
122-
// prop => `
123-
// ### ${prop.name}
124-
125-
// | | |
126-
// | --- | --- |
127-
// | **Description** | ${prop.docs.split("\n").join("<br />")} |
128-
// | **Attribute** | \`${prop.attr}\` |
129-
// | **Type** | \`${prop.type.replace(/\|/g, "\\|")}\` |
130-
// | **Default** | \`${prop.default}\` |
131-
132-
// `
133-
// )
134-
// .join("\n")}
135-
// `;
136-
// }
137-
138-
// function renderEvents({ events }) {
139-
// if (events.length === 0) {
140-
// return "";
141-
// }
142-
143-
// return `
144-
// ## Events
145-
146-
// | Name | Description |
147-
// | --- | --- |
148-
// ${events.map(event => `| \`${event.event}\` | ${event.docs} |`).join("\n")}
149-
150-
// `;
151-
// }
152-
153-
// function renderMethods({ methods }) {
154-
// if (methods.length === 0) {
155-
// return "";
156-
// }
157-
158-
// return `
159-
// ## Methods
160-
161-
// ${methods
162-
// .map(
163-
// method => `
164-
// ### ${method.name}
165-
166-
// | | |
167-
// | --- | --- |
168-
// | **Description** | ${method.docs.split("\n").join("<br />")} |
169-
// | **Signature** | \`${method.signature.replace(/\|/g, "\\|")}\` |
170-
// `
171-
// )
172-
// .join("\n")}
173-
174-
// `;
175-
// }
176-
177-
// function renderParts({ parts }) {
178-
// if (parts.length === 0) {
179-
// return "";
180-
// }
181-
182-
// return `
183-
// ## CSS Shadow Parts
184-
185-
// | Name | Description |
186-
// | --- | --- |
187-
// ${parts.map(prop => `| \`${prop.name}\` | ${prop.docs} |`).join("\n")}
188-
189-
// `;
190-
// }
191-
192-
// function renderCustomProps({ styles: customProps }) {
193-
// if (customProps.length === 0) {
194-
// return "";
195-
// }
196-
197-
// return `
198-
// ## CSS Custom Properties
199-
200-
// | Name | Description |
201-
// | --- | --- |
202-
// ${customProps.map(prop => `| \`${prop.name}\` | ${prop.docs} |`).join("\n")}
203-
204-
// `;
205-
// }
206-
207-
// function renderSlots({ slots }) {
208-
// if (slots.length === 0) {
209-
// return "";
210-
// }
211-
212-
// return `
213-
// ## Slots
214-
215-
// | Name | Description |
216-
// | --- | --- |
217-
// ${slots.map(slot => `| \`${slot.name}\` | ${slot.docs} |`).join("\n")}
218-
219-
// `;
220-
// }
81+
function renderInstallation({cordovaPlugin, packageName}) {
82+
return `
83+
<h2 id="installation">
84+
<a href="#installation">Installation</a>
85+
</h2>
86+
<Tabs defaultValue="Capacitor" values={[
87+
{value: 'Capacitor', label: 'CAPACITOR'},
88+
{value: 'Cordova', label: 'CORDOVA'},
89+
{value: 'Enterprise', label: 'ENTERPRISE'},
90+
]}>
91+
<TabItem value="Capacitor">
92+
<CodeBlock>
93+
npm install ${cordovaPlugin.name}
94+
npm install ${packageName}
95+
ionic cap sync
96+
</CodeBlock>
97+
</TabItem>
98+
<TabItem value="Cordova">
99+
<CodeBlock>
100+
ionic cordova plugin add ${cordovaPlugin.name}
101+
npm install ${packageName}
102+
</CodeBlock>
103+
</TabItem>
104+
<TabItem value="Enterprise">
105+
<blockquote>Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. &nbsp;
106+
<a class="btn" href="https://ionic.io/docs/premier-plugins">Learn More</a> or if you're interested in an enterprise version of this plugin <a class="btn" href="https://ionicframework.com/sales?product_of_interest=Ionic%20Enterprise%20Engine">Contact Us</a></blockquote>
107+
</TabItem>
108+
</Tabs>
109+
`
110+
}
221111

src/components/DocsButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export default function DocsButton({ href, round = false, ...props }) {
1515
});
1616

1717
return href ? (
18-
<a href={href} {...props}>
18+
<a href={href} className='docsButton' {...props}>
1919
{props.children}
2020
</a>
2121
) : (
22-
<button {...props}>{props.children}</button>
22+
<button className='docsButton' {...props}>{props.children}</button>
2323
);
2424
}
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
.docsButton {
2-
background-color: rgba(var(--accent-color-rgb), var(--bg-alpha, 0.06));
2+
background-color: var(--ifm-link-color);
3+
color: white;
4+
font-weight: 600;
35
border-radius: 6px;
4-
color: var(--accent-color);
56
display: inline-block;
67
font-weight: 600;
78
white-space: nowrap;
8-
}
9-
10-
.docsButton a,
11-
.docsButton button {
12-
color: inherit;
139
display: inline-block;
1410
font-size: inherit;
15-
font-weight: inherit;
1611
padding: 0.75em 1.5em;
1712
}
1813

19-
.docsButton button {
14+
button.docsButton {
2015
appearance: none;
21-
background: none;
2216
border: none;
2317
line-height: inherit;
2418
}
@@ -36,10 +30,10 @@
3630

3731
@media (hover: hover) {
3832
.docsButton:hover {
39-
--bg-alpha: 0.08;
33+
background-color: var(--ifm-link-hover-color);
4034
}
4135

4236
.docsButton:active {
43-
--bg-alpha: 0.1;
37+
opacity: 0.9;
4438
}
4539
}

src/components/DocsCard/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Outbound } from '@site/src/icons';
66

77
import './card.css';
88

9-
interface Props {
9+
interface Props extends React.HTMLAttributes<HTMLDivElement>{
1010
href?: string;
1111
header?: string;
1212
icon?: string;
@@ -48,10 +48,13 @@ function DocsCard(props: Props): JSX.Element {
4848
</div>
4949
</>);
5050

51+
console.log('test', props.className)
52+
5153
const className = clsx({
5254
'Card-with-image': typeof props.img !== 'undefined',
5355
'Card-without-image': typeof props.img === 'undefined',
5456
'Card-size-lg': props.size === 'lg',
57+
[props.className]: props.className
5558
});
5659

5760
if (isStatic) {

src/css/custom.css

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,22 @@ iframe {
282282
fill: currentColor;
283283
}
284284

285+
286+
.cordova-ee-card {
287+
max-width:100%;
288+
}
289+
285290
.cordova-ee-img {
286291
width:50px;
287292
float:left;
288293
margin-right:20px;
289294
}
290295

291-
.cordova-ee-card {
292-
max-width:100%;
296+
.native-ee-detail {
297+
float: right;
298+
cursor: pointer;
299+
}
300+
301+
.cordova-ee-card p {
302+
margin: 1rem 0 0;
293303
}

0 commit comments

Comments
 (0)