Skip to content

Commit dd5fd65

Browse files
authored
feat(pluginConfigs): add docs property (#19)
1 parent 3d1da81 commit dd5fd65

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

src/parse.ts

+3
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ function getPluginsConfig(
381381
const typeLiteral = properytSignature.type as ts.TypeLiteralNode;
382382

383383
const nm = properytSignature.name.getText();
384+
const symbol = typeChecker.getSymbolAtLocation(properytSignature.name);
385+
const docs = symbol ? serializeSymbol(typeChecker, symbol) : null;
384386
const i: DocsConfigInterface = {
385387
name: nm,
386388
slug: slugify(nm),
@@ -390,6 +392,7 @@ function getPluginsConfig(
390392
return getInterfaceProperty(typeChecker, propertySignature);
391393
})
392394
.filter(p => p != null) as DocsInterfaceProperty[],
395+
docs: docs?.docs || '',
393396
};
394397

395398
if (i.properties.length > 0) {

src/test/fixtures/definitions.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
declare module '@capacitor/cli' {
44
export interface PluginsConfig {
5+
/**
6+
* Haptics can be configured with this options:
7+
*/
58
Haptics?: {
69
/**
710
* Configure the style.

src/test/parse.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ describe('parse', () => {
147147
const p = pluginConfigs.find(i => i.name === `Haptics`);
148148

149149
expect(p.slug).toBe(`haptics`);
150+
expect(p.docs).toBe(`Haptics can be configured with this options:`);
150151
expect(p.properties).toHaveLength(2);
151152

152153
const p0 = p.properties[0];

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface DocsConfigInterface {
1010
name: string;
1111
slug: string;
1212
properties: DocsInterfaceProperty[];
13+
docs: string;
1314
}
1415

1516
export interface DocsInterface {

0 commit comments

Comments
 (0)