Skip to content

Commit

Permalink
only and between range
Browse files Browse the repository at this point in the history
  • Loading branch information
Flemmli97 committed Feb 15, 2025
1 parent 3ea96bc commit b93d1ce
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/java-edition/src/mcdocAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ export function registerMcdocAttributes(
return ReleaseVersion.cmp(release, config as ReleaseVersion) < 0
},
})
mcdoc.runtime.registerAttribute(meta, 'only', validator.string, {
filterElement: (config, ctx) => {
if (!config.startsWith('1.')) {
ctx.logger.warn(`Invalid mcdoc attribute for "until": ${config}`)
return true
}
return ReleaseVersion.cmp(release, config as ReleaseVersion) == 0

Check warning on line 42 in packages/java-edition/src/mcdocAttributes.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected '===' and instead saw '=='
},
})
mcdoc.runtime.registerAttribute(meta, 'between', validator.string, {
filterElement: (config, ctx) => {
const range = config.split("-")
if (range.length != 2 || !range[0].startsWith('1.')|| !range[1].startsWith('1.')) {

Check warning on line 48 in packages/java-edition/src/mcdocAttributes.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected '!==' and instead saw '!='
ctx.logger.warn(`Invalid mcdoc attribute for "until": ${config}`)
return true
}
return ReleaseVersion.cmp(release, range[0] as ReleaseVersion) >= 0
&& ReleaseVersion.cmp(release, range[1] as ReleaseVersion) <= 0
},
})
mcdoc.runtime.registerAttribute(meta, 'deprecated', validator.optional(validator.string), {
mapField: (config, field, ctx) => {
if (config === undefined) {
Expand Down

0 comments on commit b93d1ce

Please sign in to comment.