From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [RFC proxmox 2/2] schema: add extra info to array parameters
Date: Wed, 15 Sep 2021 15:36:34 +0200 [thread overview]
Message-ID: <20210915133634.4149021-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20210915133634.4149021-1-f.gruenbichler@proxmox.com>
it's not immediately obvious that they can be specified more than once
otherwise.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
see previous patch for some remaining warts that are not yet solved..
proxmox/src/api/format.rs | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/proxmox/src/api/format.rs b/proxmox/src/api/format.rs
index a362b21..64fcd0a 100644
--- a/proxmox/src/api/format.rs
+++ b/proxmox/src/api/format.rs
@@ -134,15 +134,15 @@ pub fn get_property_description(
) -> String {
let type_text = get_schema_type_text(schema, style);
- let (descr, default) = match schema {
- Schema::Null => ("null", None),
- Schema::String(ref schema) => (schema.description, schema.default.map(|v| v.to_owned())),
- Schema::Boolean(ref schema) => (schema.description, schema.default.map(|v| v.to_string())),
- Schema::Integer(ref schema) => (schema.description, schema.default.map(|v| v.to_string())),
- Schema::Number(ref schema) => (schema.description, schema.default.map(|v| v.to_string())),
- Schema::Object(ref schema) => (schema.description, None),
- Schema::AllOf(ref schema) => (schema.description, None),
- Schema::Array(ref schema) => (schema.description, None),
+ let (descr, default, extra) = match schema {
+ Schema::Null => ("null", None, None),
+ Schema::String(ref schema) => (schema.description, schema.default.map(|v| v.to_owned()), None),
+ Schema::Boolean(ref schema) => (schema.description, schema.default.map(|v| v.to_string()), None),
+ Schema::Integer(ref schema) => (schema.description, schema.default.map(|v| v.to_string()), None),
+ Schema::Number(ref schema) => (schema.description, schema.default.map(|v| v.to_string()), None),
+ Schema::Object(ref schema) => (schema.description, None, None),
+ Schema::AllOf(ref schema) => (schema.description, None, None),
+ Schema::Array(ref schema) => (schema.description, None, Some(String::from("Can be specified more than once."))),
};
let default_text = match default {
@@ -150,6 +150,11 @@ pub fn get_property_description(
None => String::new(),
};
+ let descr = match extra {
+ Some(extra) => format!("{} {}", descr, extra),
+ None => String::from(descr),
+ };
+
if format == DocumentationFormat::ReST {
let mut text = match style {
ParameterDisplayStyle::Config => {
@@ -169,7 +174,7 @@ pub fn get_property_description(
}
};
- text.push_str(&wrap_text("", " ", descr, 80));
+ text.push_str(&wrap_text("", " ", &descr, 80));
text.push('\n');
text
@@ -184,7 +189,7 @@ pub fn get_property_description(
let mut text = format!(" {:-10} {}{}", display_name, type_text, default_text);
let indent = " ";
text.push('\n');
- text.push_str(&wrap_text(indent, indent, descr, 80));
+ text.push_str(&wrap_text(indent, indent, &descr, 80));
text
}
--
2.30.2
next prev parent reply other threads:[~2021-09-15 13:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 13:36 [pbs-devel] [RFC proxmox 1/2] schema: print item type-text instead of <array> Fabian Grünbichler
2021-09-15 13:36 ` Fabian Grünbichler [this message]
2021-09-22 5:59 ` [pbs-devel] applied: [RFC proxmox 2/2] schema: add extra info to array parameters Thomas Lamprecht
2021-09-22 5:58 ` [pbs-devel] applied: [RFC proxmox 1/2] schema: print item type-text instead of <array> Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210915133634.4149021-2-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox