Docs: improve tag output

This commit is contained in:
Pieter Vander Vennet 2023-11-13 03:16:24 +01:00
parent 1fea2b56be
commit 818f3e9017
5 changed files with 54 additions and 27 deletions

View file

@ -72,11 +72,17 @@ export class And extends TagsFilter {
return allChoices
}
asHumanString(linkToWiki: boolean, shorten: boolean, properties) {
asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record<string, string>) {
return this.and
.map((t) => t.asHumanString(linkToWiki, shorten, properties))
.map((t) => {
let e = t.asHumanString(linkToWiki, shorten, properties)
if (t["or"]) {
e = "(" + e + ")"
}
return e
})
.filter((x) => x !== "")
.join(" &")
.join(" & ")
}
isUsableAsAnswer(): boolean {

View file

@ -49,8 +49,16 @@ export class Or extends TagsFilter {
return choices
}
asHumanString(linkToWiki: boolean, shorten: boolean, properties) {
return this.or.map((t) => t.asHumanString(linkToWiki, shorten, properties)).join(" |")
asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record<string, string>) {
return this.or
.map((t) => {
let e = t.asHumanString(linkToWiki, shorten, properties)
if (t["and"]) {
e = "(" + e + ")"
}
return e
})
.join(" | ")
}
isUsableAsAnswer(): boolean {

View file

@ -86,6 +86,11 @@ export class Tag extends TagsFilter {
v = Utils.EllipsesAfter(v, 25)
}
if ((v === "" || v === undefined) && currentProperties !== undefined) {
if (!currentProperties || Object.keys(currentProperties).length === 0) {
// We are probably generating documentation
return this.key + "="
}
// This tag will be removed if in the properties, so we indicate this with special rendering
if ((currentProperties[this.key] ?? "") === "") {
// This tag is not present in the current properties, so this tag doesn't change anything