forked from MapComplete/MapComplete
Docs: improve tag output
This commit is contained in:
parent
1fea2b56be
commit
818f3e9017
5 changed files with 54 additions and 27 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue