Skip to content

Commit

Permalink
feat(pluginConfigs): add docs property (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Mar 3, 2021
1 parent 3d1da81 commit dd5fd65
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ function getPluginsConfig(
const typeLiteral = properytSignature.type as ts.TypeLiteralNode;

const nm = properytSignature.name.getText();
const symbol = typeChecker.getSymbolAtLocation(properytSignature.name);
const docs = symbol ? serializeSymbol(typeChecker, symbol) : null;
const i: DocsConfigInterface = {
name: nm,
slug: slugify(nm),
Expand All @@ -390,6 +392,7 @@ function getPluginsConfig(
return getInterfaceProperty(typeChecker, propertySignature);
})
.filter(p => p != null) as DocsInterfaceProperty[],
docs: docs?.docs || '',
};

if (i.properties.length > 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/test/fixtures/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

declare module '@capacitor/cli' {
export interface PluginsConfig {
/**
* Haptics can be configured with this options:
*/
Haptics?: {
/**
* Configure the style.
Expand Down
1 change: 1 addition & 0 deletions src/test/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe('parse', () => {
const p = pluginConfigs.find(i => i.name === `Haptics`);

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

const p0 = p.properties[0];
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface DocsConfigInterface {
name: string;
slug: string;
properties: DocsInterfaceProperty[];
docs: string;
}

export interface DocsInterface {
Expand Down

0 comments on commit dd5fd65

Please sign in to comment.