mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-23 20:47:59 +00:00
rename dump_api_parameters to dump_properties
And do not dump object description automatically.
This commit is contained in:
parent
4e375ba95c
commit
67c7699b23
@ -299,8 +299,8 @@ pub fn dump_enum_properties(schema: &Schema) -> Result<String, Error> {
|
|||||||
bail!("dump_enum_properties failed - not an enum");
|
bail!("dump_enum_properties failed - not an enum");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate ReST Documentaion for objects
|
/// Generate ReST Documentaion for object properties
|
||||||
pub fn dump_api_parameters<I>(
|
pub fn dump_properties<I>(
|
||||||
param: &dyn ObjectSchemaType<PropertyIter = I>,
|
param: &dyn ObjectSchemaType<PropertyIter = I>,
|
||||||
indent: &str,
|
indent: &str,
|
||||||
style: ParameterDisplayStyle,
|
style: ParameterDisplayStyle,
|
||||||
@ -308,8 +308,7 @@ pub fn dump_api_parameters<I>(
|
|||||||
) -> String
|
) -> String
|
||||||
where I: Iterator<Item = &'static SchemaPropertyEntry>,
|
where I: Iterator<Item = &'static SchemaPropertyEntry>,
|
||||||
{
|
{
|
||||||
let mut res = wrap_text(indent, indent, param.description(), 80);
|
let mut res = String::new();
|
||||||
|
|
||||||
let next_indent = format!(" {}", indent);
|
let next_indent = format!(" {}", indent);
|
||||||
|
|
||||||
let mut required_list: Vec<String> = Vec::new();
|
let mut required_list: Vec<String> = Vec::new();
|
||||||
@ -336,7 +335,7 @@ pub fn dump_api_parameters<I>(
|
|||||||
Schema::String(StringSchema { format: Some(ApiStringFormat::PropertyString(sub_schema)), .. }) => {
|
Schema::String(StringSchema { format: Some(ApiStringFormat::PropertyString(sub_schema)), .. }) => {
|
||||||
match sub_schema {
|
match sub_schema {
|
||||||
Schema::Object(object_schema) => {
|
Schema::Object(object_schema) => {
|
||||||
let sub_text = dump_api_parameters(
|
let sub_text = dump_properties(
|
||||||
object_schema, &next_indent, ParameterDisplayStyle::ConfigSub, &[]);
|
object_schema, &next_indent, ParameterDisplayStyle::ConfigSub, &[]);
|
||||||
param_descr.push_str(&sub_text);
|
param_descr.push_str(&sub_text);
|
||||||
}
|
}
|
||||||
@ -421,10 +420,14 @@ fn dump_api_return_schema(
|
|||||||
res.push_str(&description);
|
res.push_str(&description);
|
||||||
}
|
}
|
||||||
Schema::Object(obj_schema) => {
|
Schema::Object(obj_schema) => {
|
||||||
res.push_str(&dump_api_parameters(obj_schema, "", style, &[]));
|
let description = wrap_text("", "", obj_schema.description, 80);
|
||||||
|
res.push_str(&description);
|
||||||
|
res.push_str(&dump_properties(obj_schema, "", style, &[]));
|
||||||
}
|
}
|
||||||
Schema::AllOf(all_of_schema) => {
|
Schema::AllOf(all_of_schema) => {
|
||||||
res.push_str(&dump_api_parameters(all_of_schema, "", style, &[]));
|
let description = wrap_text("", "", all_of_schema.description, 80);
|
||||||
|
res.push_str(&description);
|
||||||
|
res.push_str(&dump_properties(all_of_schema, "", style, &[]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +441,9 @@ fn dump_method_definition(method: &str, path: &str, def: Option<&ApiMethod>) ->
|
|||||||
match def {
|
match def {
|
||||||
None => None,
|
None => None,
|
||||||
Some(api_method) => {
|
Some(api_method) => {
|
||||||
let param_descr = dump_api_parameters(&api_method.parameters, "", style, &[]);
|
|
||||||
|
let description = wrap_text("", "", &api_method.parameters.description(), 80);
|
||||||
|
let param_descr = dump_properties(&api_method.parameters, "", style, &[]);
|
||||||
|
|
||||||
let return_descr = dump_api_return_schema(&api_method.returns, style);
|
let return_descr = dump_api_return_schema(&api_method.returns, style);
|
||||||
|
|
||||||
@ -450,8 +455,8 @@ fn dump_method_definition(method: &str, path: &str, def: Option<&ApiMethod>) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
let res = format!(
|
let res = format!(
|
||||||
"**{} {}**\n\n{}\n\n{}",
|
"**{} {}**\n\n{}{}\n\n{}",
|
||||||
method, path, param_descr, return_descr
|
method, path, description, param_descr, return_descr
|
||||||
);
|
);
|
||||||
Some(res)
|
Some(res)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user