Skip to content

Commit 5d8a05f

Browse files
authored
Add support for doc_id in properties (#755)
1 parent 22ef83f commit 5d8a05f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/model/metamodel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class Property {
125125
required: boolean
126126
description?: string
127127
docUrl?: string
128+
docId?: string
128129
since?: string
129130
serverDefault?: boolean | string | number
130131
deprecation?: Deprecation

compiler/model/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
661661
// We want to enforce a single jsDoc block.
662662
assert(jsDocs, jsDocs.length < 2, 'Use a single multiline jsDoc block instead of multiple single line blocks')
663663

664-
const validTags = ['stability', 'prop_serializer', 'doc_url', 'aliases', 'identifier', 'since', 'server_default', 'variant']
664+
const validTags = ['stability', 'prop_serializer', 'doc_url', 'aliases', 'identifier', 'since', 'server_default', 'variant', 'doc_id']
665665
const tags = parseJsDocTags(jsDocs)
666666
if (jsDocs.length === 1) {
667667
const description = jsDocs[0].getDescription()
@@ -680,6 +680,9 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
680680
} else if (tag === 'since') {
681681
assert(jsDocs, semver.valid(value), `${property.name}'s @since is not valid semver: ${value}`)
682682
property.since = value
683+
} else if (tag === 'doc_id') {
684+
assert(jsDocs, value.trim() !== '', `Property ${property.name}'s @doc_id is cannot be empty`)
685+
property.docId = value
683686
} else if (tag === 'server_default') {
684687
assert(jsDocs, property.type.kind === 'instance_of' || property.type.kind === 'union_of', `Default values can only be configured for instance_of or union_of types, you are using ${property.type.kind}`)
685688
assert(jsDocs, !property.required, 'Default values can only be specified on optional properties')

0 commit comments

Comments
 (0)