doc: Rework generated configuration to have anchors

Also first line of default code blocks being used as the language instead of json
and fixes a missing `json` language in a doc comment code block.
This commit is contained in:
bbb651 2025-04-20 17:22:50 +03:00
parent 150bb4a00f
commit 2ffcb99683
3 changed files with 690 additions and 358 deletions

View file

@ -426,7 +426,7 @@ config_data! {
///
/// Similarly, the JSON representation of `DiscoverArgument::Buildfile` is:
///
/// ```
/// ```json
/// {
/// "buildfile": "BUILD"
/// }
@ -3655,12 +3655,16 @@ fn validate_toml_table(
#[cfg(test)]
fn manual(fields: &[SchemaField]) -> String {
fields.iter().fold(String::new(), |mut acc, (field, _ty, doc, default)| {
let name = format!("rust-analyzer.{}", field.replace('_', "."));
let id = field.replace('_', ".");
let name = format!("rust-analyzer.{id}");
let doc = doc_comment_to_string(doc);
if default.contains('\n') {
format_to_acc!(acc, " **{name}**\n\nDefault:\n\n```{default}\n\n```\n\n {doc}\n\n ")
format_to_acc!(
acc,
"## {name} {{#{id}}}\n\nDefault:\n```json\n{default}\n```\n\n{doc}\n\n"
)
} else {
format_to_acc!(acc, "**{name}** (default: {default})\n\n {doc}\n\n")
format_to_acc!(acc, "## {name} {{#{id}}}\n\nDefault: `{default}`\n\n{doc}\n\n")
}
})
}