From e2a93e4395c6358d52a61527b131d979a1ad2f93 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Tue, 28 Jan 2025 15:36:49 -0300 Subject: [PATCH] support deprecated options #refactor --- docs/extensions/config-options-reference.js | 19 ++++++++++++++++--- util/generate-config-info.py | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/extensions/config-options-reference.js b/docs/extensions/config-options-reference.js index 95d5603f9..f520f729b 100644 --- a/docs/extensions/config-options-reference.js +++ b/docs/extensions/config-options-reference.js @@ -90,6 +90,10 @@ function toDefaultValueStr(value) { } function pushOptionBlocks(options, block, parents = []) { + function makeOptionID(option) { + return [...parents, option.name].join('_') + "_option" + } + block.lines.push('') block.lines.push('') block.lines.push('') @@ -108,7 +112,8 @@ function pushOptionBlocks(options, block, parents = []) { let optionName = [...parents, option.name].join('.') block.lines.push('') block.lines.push(`
`) - block.lines.push(`${optionName}`) + const colorStr = option['deprecated'] ? 'red' : 'darkblue' + block.lines.push(`${optionName}`) block.lines.push(`
`) block.lines.push(`(${toTypeStr(option.type)})`) let observations = [] @@ -118,8 +123,11 @@ function pushOptionBlocks(options, block, parents = []) { if (option['command-line-only']) { observations.push('Command line only') } + if (option['deprecated']) { + observations.push(`Deprecated`) + } if (observations.length !== 0) { - block.lines.push(`

`) + block.lines.push(`
`) let observationsStr = observations.join(', ') block.lines.push(`(${observationsStr})`) } @@ -134,7 +142,9 @@ function pushOptionBlocks(options, block, parents = []) { // Option details for (let option of options) { let optionName = [...parents, option.name].join('.') - block.lines.push(`

${optionName}

`) + const optionID = optionName.replace(/\./g, '_') + const colorStr = option['deprecated'] ? 'red' : 'darkblue' + block.lines.push(`

${optionName}

`) block.lines.push(`

${option.brief}

`) if (option.details) { block.lines.push(`

${replaceCodeTags(escapeHtml(option.details))}

`) @@ -142,6 +152,9 @@ function pushOptionBlocks(options, block, parents = []) { block.lines.push(`

`) block.lines.push(`

`) block.lines.push(`
    `) + if (option['deprecated']) { + block.lines.push(`
  • Deprecated: ${replaceCodeTags(escapeHtml(option['deprecated']))}
  • `) + } if (option.type) { block.lines.push(`
  • Type: ${toTypeStr(option.type)}
  • `) } else { diff --git a/util/generate-config-info.py b/util/generate-config-info.py index bc3122c2b..75509b734 100644 --- a/util/generate-config-info.py +++ b/util/generate-config-info.py @@ -393,6 +393,7 @@ def generate_public_settings_hpp(config): contents += f' {cpp_type}' contents += f'> {to_camel_case("default")}Value = std::monostate();\n' contents += f' std::string {to_camel_case("relative-to")} = {{}};\n' + contents += f' std::optional {to_camel_case("deprecated")} = std::nullopt;\n' contents += ' };\n\n' contents += ' /** Normalize the configuration values with a visitor\n' @@ -441,6 +442,8 @@ def generate_public_settings_hpp(config): contents += f'{pad}.{to_camel_case("default")}Value = {cpp_type}({cpp_default_value}),\n' if 'relative-to' in option: contents += f'{pad}.{to_camel_case("relative-to")} = {escape_as_cpp_string(option["relative-to"])},\n' + if 'deprecated' in option: + contents += f'{pad}.{to_camel_case("deprecated")} = {escape_as_cpp_string(option["deprecated"])},\n' contents += f' }}));\n' contents += ' return {};\n' contents += ' }\n\n'