(source)
| 273 | } |
| 274 | |
| 275 | function parseMetadata(source) { |
| 276 | const firstMatch = pattern => source.match(pattern)?.[1] ?? '' |
| 277 | const name = firstMatch(/name:\s*'([^']+)'/) |
| 278 | const type = firstMatch(/type:\s*'([^']+)'/) |
| 279 | const description = firstMatch(/description:\s*`([^`]+)`/) || firstMatch(/description:\s*'([^']+)'/) |
| 280 | const argumentHint = firstMatch(/argumentHint:\s*'([^']+)'/) |
| 281 | const aliases = parseSimpleStringArray(source, 'aliases') |
| 282 | const availability = parseSimpleStringArray(source, 'availability') |
| 283 | const immediate = source.match(/immediate:\s*(true|false)/)?.[1] ?? '' |
| 284 | const hiddenKind = |
| 285 | source.match(/isHidden:\s*(true|false)/)?.[1] ?? |
| 286 | (source.includes('get isHidden()') ? 'getter' : '') |
| 287 | const hasIsEnabled = source.includes('isEnabled:') |
| 288 | return { |
| 289 | name, |
| 290 | type, |
| 291 | description, |
| 292 | argumentHint, |
| 293 | aliases, |
| 294 | availability, |
| 295 | immediate, |
| 296 | hiddenKind, |
| 297 | hasIsEnabled, |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | function parseBooleanField(source, fieldName) { |
| 302 | return source.match(new RegExp(`${fieldName}:\\s*(true|false)`))?.[1] ?? '' |
no test coverage detected