function hoistEnumMemberAnnotations()

in compiler/src/model/utils.ts [902:937]


function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]): void {
  // in most of the cases the jsDocs comes in a single block,
  // but it can happen that the user defines multiple single line jsDoc.
  // We want to enforce a single jsDoc block.
  assert(jsDocs, jsDocs.length < 2, 'Use a single multiline jsDoc block instead of multiple single line blocks')

  const validTags = ['obsolete', 'obsolete_description', 'codegen_name', 'availability', 'aliases']
  const tags = parseJsDocTags(jsDocs)
  if (jsDocs.length === 1) {
    const description = jsDocs[0].getDescription()
    if (description.length > 0) member.description = description.trim().replace(/\r/g, '')
  }

  setTags(jsDocs, member, tags, validTags, (tags, tag, value) => {
    if (tag === 'codegen_name') {
      member.codegenName = value
    } else if (tag === 'aliases') {
      member.aliases = parseCommaSeparated(value)
    } else if (tag === 'availability') {
      // The @availability jsTag is different than most because it allows
      // multiple values within the same docstring, hence needing to parse
      // the values again in order to preserve multiple values.
      const jsDocsMulti = parseJsDocTagsAllowDuplicates(jsDocs)
      const availabilities = parseAvailabilityTags(jsDocs, jsDocsMulti.availability)

      // The absence of an 'availability' field on a property implies that
      // the property is available in all flavors.
      member.availability = {}
      for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
        member.availability[availabilityName] = availabilityValue
      }
    } else {
      assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on enum member ${member.name}`)
    }
  })
}