(field: Field)
| 228 | } |
| 229 | |
| 230 | field(field: Field): string { |
| 231 | |
| 232 | const fieldDescription = this.description(field.description); |
| 233 | const argumentsDescription = this.argumentsDescription(field); |
| 234 | |
| 235 | if (fieldDescription.length > 0 && argumentsDescription.length) |
| 236 | fieldDescription.push(html.comment('')); |
| 237 | |
| 238 | const fieldDefinition = field.args.length > 0 && this.fieldLength(field) > MAX_CODE_LEN ? |
| 239 | |
| 240 | // Multiline definition: |
| 241 | // fieldName( |
| 242 | // argumentName: ArgumentType, \n ... |
| 243 | // ): ReturnType [@deprecated...] |
| 244 | [ |
| 245 | html.property(field.name) + '(', |
| 246 | ...this.argumentsMultiline(field).map(l => html.tab(l)), |
| 247 | '): ' + html.useIdentifier(field.type, this.url(field.type)) + ' ' + this.deprecated(field) |
| 248 | ] : |
| 249 | |
| 250 | // Single line |
| 251 | // fieldName(argumentName: ArgumentType): ReturnType [@deprecated...] |
| 252 | [ |
| 253 | html.property(field.name) + this.arguments(field) + ': ' + |
| 254 | html.useIdentifier(field.type, this.url(field.type)) + ' ' + this.deprecated(field) |
| 255 | ]; |
| 256 | |
| 257 | return ([] as string[]) |
| 258 | .concat(fieldDescription) |
| 259 | .concat(argumentsDescription) |
| 260 | .concat(fieldDefinition) |
| 261 | .map(line => html.line(html.tab(line))) |
| 262 | .join(''); |
| 263 | } |
| 264 | |
| 265 | fieldLength(field: Field): number { |
| 266 |
no test coverage detected