Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pluginConfigs): Add docs property #19

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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