fork of hey-api/openapi-ts because I need some additional things
1import type { PyNodeBase } from '../base';
2import type { PyExpression } from '../expression';
3import { PyNodeKind } from '../kinds';
4import type { PyStatement } from '../statement';
5import type { PyBlock } from '../statements/block';
6import { createBlock } from '../statements/block';
7import type { PyFunctionParameter } from './functionParameter';
8
9export interface PyFunctionDeclaration extends PyNodeBase {
10 body: PyBlock;
11 decorators?: ReadonlyArray<PyExpression>;
12 docstring?: string;
13 kind: PyNodeKind.FunctionDeclaration;
14 modifiers?: ReadonlyArray<PyExpression>;
15 name: string;
16 parameters: ReadonlyArray<PyFunctionParameter>;
17 returnType?: PyExpression;
18}
19
20export function createFunctionDeclaration(
21 name: string,
22 parameters: ReadonlyArray<PyFunctionParameter>,
23 returnType: PyExpression | undefined,
24 body: ReadonlyArray<PyStatement>,
25 decorators?: ReadonlyArray<PyExpression>,
26 docstring?: string,
27 modifiers?: ReadonlyArray<PyExpression>,
28 leadingComments?: ReadonlyArray<string>,
29 trailingComments?: ReadonlyArray<string>,
30): PyFunctionDeclaration {
31 return {
32 body: createBlock(body),
33 decorators,
34 docstring,
35 kind: PyNodeKind.FunctionDeclaration,
36 leadingComments,
37 modifiers,
38 name,
39 parameters,
40 returnType,
41 trailingComments,
42 };
43}