From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 41F5669E5F for ; Wed, 15 Sep 2021 15:41:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 34B5919A88 for ; Wed, 15 Sep 2021 15:41:54 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4A38819A6E for ; Wed, 15 Sep 2021 15:41:53 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C447B448B4 for ; Wed, 15 Sep 2021 15:36:41 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Wed, 15 Sep 2021 15:36:34 +0200 Message-Id: <20210915133634.4149021-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915133634.4149021-1-f.gruenbichler@proxmox.com> References: <20210915133634.4149021-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.398 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [format.rs] Subject: [pbs-devel] [RFC proxmox 2/2] schema: add extra info to array parameters X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 13:41:54 -0000 it's not immediately obvious that they can be specified more than once otherwise. Signed-off-by: Fabian Grünbichler --- 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