mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-24 19:22:35 +00:00
Autogenerate possible values for enums in reference documentation (#5137)
## Summary For example:  Closes https://github.com/astral-sh/uv/issues/5129.
This commit is contained in:
parent
3e93255ac9
commit
a191f84929
8 changed files with 218 additions and 62 deletions
|
@ -216,7 +216,18 @@ fn emit_field(output: &mut String, name: &str, field: &OptionField, parents: &[S
|
|||
output.push_str("\n\n");
|
||||
output.push_str(&format!("**Default value**: `{}`\n", field.default));
|
||||
output.push('\n');
|
||||
output.push_str(&format!("**Type**: `{}`\n", field.value_type));
|
||||
if let Some(possible_values) = field
|
||||
.possible_values
|
||||
.as_ref()
|
||||
.filter(|values| !values.is_empty())
|
||||
{
|
||||
output.push_str("**Possible values**:\n\n");
|
||||
for value in possible_values {
|
||||
output.push_str(format!("- {value}\n").as_str());
|
||||
}
|
||||
} else {
|
||||
output.push_str(&format!("**Type**: `{}`\n", field.value_type));
|
||||
}
|
||||
output.push('\n');
|
||||
output.push_str("**Example usage**:\n\n");
|
||||
output.push_str(&format_tab(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue