Skip to content

Commit e2a93e4

Browse files
committed
support deprecated options
#refactor
1 parent 6cc3217 commit e2a93e4

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

docs/extensions/config-options-reference.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ function toDefaultValueStr(value) {
9090
}
9191

9292
function pushOptionBlocks(options, block, parents = []) {
93+
function makeOptionID(option) {
94+
return [...parents, option.name].join('_') + "_option"
95+
}
96+
9397
block.lines.push('<table class="tableblock frame-all grid-all stretch">')
9498
block.lines.push('<colgroup>')
9599
block.lines.push('<col style="width: 23.3333%;">')
@@ -108,7 +112,8 @@ function pushOptionBlocks(options, block, parents = []) {
108112
let optionName = [...parents, option.name].join('.')
109113
block.lines.push('<tr>')
110114
block.lines.push(`<td class="tableblock halign-left valign-top">`)
111-
block.lines.push(`<code style="color: darkblue">${optionName}</code>`)
115+
const colorStr = option['deprecated'] ? 'red' : 'darkblue'
116+
block.lines.push(`<a href="#${makeOptionID(option)}"><code style="color: ${colorStr}">${optionName}</code></a>`)
112117
block.lines.push(`<br/>`)
113118
block.lines.push(`<span style="color: darkgreen;">(${toTypeStr(option.type)})</span>`)
114119
let observations = []
@@ -118,8 +123,11 @@ function pushOptionBlocks(options, block, parents = []) {
118123
if (option['command-line-only']) {
119124
observations.push('Command line only')
120125
}
126+
if (option['deprecated']) {
127+
observations.push(`Deprecated`)
128+
}
121129
if (observations.length !== 0) {
122-
block.lines.push(`<br/><br/>`)
130+
block.lines.push(`<br/>`)
123131
let observationsStr = observations.join(', ')
124132
block.lines.push(`<span style="color: orangered;">(${observationsStr})</span>`)
125133
}
@@ -134,14 +142,19 @@ function pushOptionBlocks(options, block, parents = []) {
134142
// Option details
135143
for (let option of options) {
136144
let optionName = [...parents, option.name].join('.')
137-
block.lines.push(`<div class="paragraph"><p><b><code style="color: darkblue">${optionName}</code></b></p></div>`)
145+
const optionID = optionName.replace(/\./g, '_')
146+
const colorStr = option['deprecated'] ? 'red' : 'darkblue'
147+
block.lines.push(`<div class="paragraph" id="${makeOptionID(option)}"><p><b><code style="color: ${colorStr}">${optionName}</code></b></p></div>`)
138148
block.lines.push(`<div class="paragraph"><p><i>${option.brief}</i></p></div>`)
139149
if (option.details) {
140150
block.lines.push(`<div class="paragraph"><p>${replaceCodeTags(escapeHtml(option.details))}</p></div>`)
141151
}
142152
block.lines.push(`<div class="paragraph"><p>`)
143153
block.lines.push(`<div class="ulist">`)
144154
block.lines.push(`<ul>`)
155+
if (option['deprecated']) {
156+
block.lines.push(`<li><span style="color: red;">Deprecated</span>: ${replaceCodeTags(escapeHtml(option['deprecated']))}</li>`)
157+
}
145158
if (option.type) {
146159
block.lines.push(`<li>Type: ${toTypeStr(option.type)}</li>`)
147160
} else {

util/generate-config-info.py

+3
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def generate_public_settings_hpp(config):
393393
contents += f' {cpp_type}'
394394
contents += f'> {to_camel_case("default")}Value = std::monostate();\n'
395395
contents += f' std::string {to_camel_case("relative-to")} = {{}};\n'
396+
contents += f' std::optional<std::string> {to_camel_case("deprecated")} = std::nullopt;\n'
396397
contents += ' };\n\n'
397398

398399
contents += ' /** Normalize the configuration values with a visitor\n'
@@ -441,6 +442,8 @@ def generate_public_settings_hpp(config):
441442
contents += f'{pad}.{to_camel_case("default")}Value = {cpp_type}({cpp_default_value}),\n'
442443
if 'relative-to' in option:
443444
contents += f'{pad}.{to_camel_case("relative-to")} = {escape_as_cpp_string(option["relative-to"])},\n'
445+
if 'deprecated' in option:
446+
contents += f'{pad}.{to_camel_case("deprecated")} = {escape_as_cpp_string(option["deprecated"])},\n'
444447
contents += f' }}));\n'
445448
contents += ' return {};\n'
446449
contents += ' }\n\n'

0 commit comments

Comments
 (0)