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: include parameter details in Swift docstrings #118

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/generators/swift/swift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Type, Schema } from '../ast.js';
import Handlebars from 'handlebars';
import { Generator, BasePropertyContext, GeneratorClient } from '../gen.js';
import lodash from 'lodash';
import { registerPartial } from '../../templates.js';

const { camelCase, upperFirst } = lodash;

Expand Down Expand Up @@ -61,6 +62,10 @@ export const swift: Generator<
allowedIdentifierChars: 'A-Za-z0-9_$',
},
setup: async () => {
await registerPartial(
'generators/swift/templates/functionDocumentation.hbs',
'functionDocumentation',
);
Handlebars.registerHelper('propertiesDictionary', generatePropertiesDictionary);
Handlebars.registerHelper('functionCall', generateFunctionCall);
Handlebars.registerHelper('functionSignature', generateFunctionSignature);
Expand Down
4 changes: 1 addition & 3 deletions src/generators/swift/templates/analytics.swift.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class RudderTyperAnalytics {
{{functionCall "RudderTyperAnalytics" functionName properties "options" "RSOption()"}}
}

{{#if functionDescription}}
/// {{functionDescription}}
{{/if}}
{{> functionDocumentation }}
static func {{functionSignature functionName properties true}} {
{{indent " " (propertiesDictionary properties)}}

Expand Down
13 changes: 13 additions & 0 deletions src/generators/swift/templates/functionDocumentation.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
{{#if functionDescription}}
{{functionDescription}}
{{else}}
Fires a '{{functionName}}' track call.
{{/if}}

- Parameters:
{{#each properties}}
- {{name}}: {{#if isRequired}}[{{type}}]{{else}}{{type}}{{/if}}{{#if description}} - {{description}}{{/if}}
{{/each}}
- options: Event-level options.
*/
Loading