DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <david.marchand@redhat.com>
Cc: <dev@dpdk.org>
Subject: [PATCH v3 6/6] argparse: fix doc don't display two hyphens
Date: Mon, 18 Mar 2024 09:18:48 +0000	[thread overview]
Message-ID: <20240318091848.14360-7-fengchengwen@huawei.com> (raw)
In-Reply-To: <20240318091848.14360-1-fengchengwen@huawei.com>

With the line in rst file:
	The single mode: "--aaa" or "-a".
corresponding line in html doc:
	The single mode: -aaa or -a.
the two hyphens (--aaa) become one (-aaa).

According to [1], this commit uses the backquote (``xxx``) to fix it.
And for consistency, use this format for all arguments.

Fixes: e3e579f5bab5 ("argparse: introduce argparse library")

[1] https://stackoverflow.com/questions/51075907/display-two-dashes-in-rst-file

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 doc/guides/prog_guide/argparse_lib.rst | 47 +++++++++++++-------------
 lib/argparse/rte_argparse.h            |  4 +--
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/doc/guides/prog_guide/argparse_lib.rst b/doc/guides/prog_guide/argparse_lib.rst
index a6ac11b1c0..f827312daa 100644
--- a/doc/guides/prog_guide/argparse_lib.rst
+++ b/doc/guides/prog_guide/argparse_lib.rst
@@ -90,9 +90,9 @@ The following code demonstrates how to use:
    }
 
 In this example, the arguments which start with a hyphen (-) are optional
-arguments (they're "--aaa"/"--bbb"/"--ccc"/"--ddd"/"--eee"/"--fff"); and the
-arguments which don't start with a hyphen (-) are positional arguments
-(they're "ooo"/"ppp").
+arguments (they're ``--aaa``/``--bbb``/``--ccc``/``--ddd``/``--eee``/``--fff``);
+and the arguments which don't start with a hyphen (-) are positional arguments
+(they're ``ooo``/``ppp``).
 
 Every argument must be set whether to carry a value (one of
 ``RTE_ARGPARSE_ARG_NO_VALUE``, ``RTE_ARGPARSE_ARG_REQUIRED_VALUE`` and
@@ -106,23 +106,23 @@ User Input Requirements
 ~~~~~~~~~~~~~~~~~~~~~~~
 
 For optional arguments which take no-value,
-the following mode is supported (take above "--aaa" as an example):
+the following mode is supported (take above ``--aaa`` as an example):
 
-- The single mode: "--aaa" or "-a".
+- The single mode: ``--aaa`` or ``-a``.
 
 For optional arguments which take required-value,
-the following two modes are supported (take above "--bbb" as an example):
+the following two modes are supported (take above ``--bbb`` as an example):
 
-- The kv mode: "--bbb=1234" or "-b=1234".
+- The kv mode: ``--bbb=1234`` or ``-b=1234``.
 
-- The split mode: "--bbb 1234" or "-b 1234".
+- The split mode: ``--bbb 1234`` or ``-b 1234``.
 
 For optional arguments which take optional-value,
-the following two modes are supported (take above "--ccc" as an example):
+the following two modes are supported (take above ``--ccc`` as an example):
 
-- The single mode: "--ccc" or "-c".
+- The single mode: ``--ccc`` or ``-c``.
 
-- The kv mode: "--ccc=123" or "-c=123".
+- The kv mode: ``--ccc=123`` or ``-c=123``.
 
 For positional arguments which must take required-value,
 their values are parsing in the order defined.
@@ -130,7 +130,7 @@ their values are parsing in the order defined.
 .. note::
 
    The compact mode is not supported.
-   Take above "-a" and "-d" as an example, don't support "-ad" input.
+   Take above ``-a`` and ``-d`` as an example, don't support ``-ad`` input.
 
 Parsing by autosave way
 ~~~~~~~~~~~~~~~~~~~~~~~
@@ -139,23 +139,23 @@ Argument of known value type (e.g. ``RTE_ARGPARSE_ARG_VALUE_INT``)
 could be parsed using this autosave way,
 and its result will save in the ``val_saver`` field.
 
-In the above example, the arguments "--aaa"/"--bbb"/"--ccc" and "ooo"
+In the above example, the arguments ``--aaa``/``--bbb``/``--ccc`` and ``ooo``
 both use this way, the parsing is as follows:
 
-- For argument "--aaa", it is configured as no-value,
+- For argument ``--aaa``, it is configured as no-value,
   so the ``aaa_val`` will be set to ``val_set`` field
   which is 100 in the above example.
 
-- For argument "--bbb", it is configured as required-value,
+- For argument ``--bbb``, it is configured as required-value,
   so the ``bbb_val`` will be set to user input's value
-  (e.g. will be set to 1234 with input "--bbb 1234").
+  (e.g. will be set to 1234 with input ``--bbb 1234``).
 
-- For argument "--ccc", it is configured as optional-value,
-  if user only input "--ccc" then the ``ccc_val`` will be set to ``val_set`` field
-  which is 200 in the above example;
-  if user input "--ccc=123", then the ``ccc_val`` will be set to 123.
+- For argument ``--ccc``, it is configured as optional-value,
+  if user only input ``--ccc`` then the ``ccc_val`` will be set to ``val_set``
+  field which is 200 in the above example;
+  if user input ``--ccc=123``, then the ``ccc_val`` will be set to 123.
 
-- For argument "ooo", it is positional argument,
+- For argument ``ooo``, it is positional argument,
   the ``ooo_val`` will be set to user input's value.
 
 Parsing by callback way
@@ -165,7 +165,8 @@ It could also choose to use callback to parse,
 just define a unique index for the argument
 and make the ``val_save`` field to be NULL also zero value-type.
 
-In the above example, the arguments "--ddd"/"--eee"/"--fff" and "ppp" both use this way.
+In the above example, the arguments ``--ddd``/``--eee``/``--fff`` and ``ppp``
+both use this way.
 
 Multiple times argument
 ~~~~~~~~~~~~~~~~~~~~~~~
@@ -178,7 +179,7 @@ For example:
 
    { "--xyz", "-x", "xyz argument", NULL, (void *)10, RTE_ARGPARSE_ARG_REQUIRED_VALUE | RTE_ARGPARSE_ARG_SUPPORT_MULTI },
 
-Then the user input could contain multiple "--xyz" arguments.
+Then the user input could contain multiple ``--xyz`` arguments.
 
 .. note::
 
diff --git a/lib/argparse/rte_argparse.h b/lib/argparse/rte_argparse.h
index 98ad9971ea..b6b016e388 100644
--- a/lib/argparse/rte_argparse.h
+++ b/lib/argparse/rte_argparse.h
@@ -83,8 +83,8 @@ extern "C" {
 struct rte_argparse_arg {
 	/**
 	 * Long name of the argument:
-	 * 1) If the argument is optional, it must start with '--'.
-	 * 2) If the argument is positional, it must not start with '-'.
+	 * 1) If the argument is optional, it must start with ``--``.
+	 * 2) If the argument is positional, it must not start with ``-``.
 	 * 3) Other case will be considered as error.
 	 */
 	const char *name_long;
-- 
2.17.1


  parent reply	other threads:[~2024-03-18  9:21 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 13:14 [PATCH 0/4] refine argparse library Chengwen Feng
2024-02-20 13:14 ` [PATCH 1/4] argparse: refine error message Chengwen Feng
2024-02-20 13:15 ` [PATCH 2/4] argparse: remove dead code Chengwen Feng
2024-02-20 13:15 ` [PATCH 3/4] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-06 17:34   ` David Marchand
2024-03-07 13:14     ` fengchengwen
2024-02-20 13:15 ` [PATCH 4/4] test/argparse: refine testcases Chengwen Feng
2024-03-07 13:07 ` [PATCH v2 0/5] refine argparse library Chengwen Feng
2024-03-07 13:07   ` [PATCH v2 1/5] argparse: refine error message Chengwen Feng
2024-03-07 13:07   ` [PATCH v2 2/5] argparse: remove dead code Chengwen Feng
2024-03-07 13:07   ` [PATCH v2 3/5] argparse: replace flag enum with marco Chengwen Feng
2024-03-07 17:43     ` Tyler Retzlaff
2024-03-07 17:58       ` David Marchand
2024-03-07 18:37         ` Tyler Retzlaff
2024-03-07 13:07   ` [PATCH v2 4/5] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-18  2:31     ` Thomas Monjalon
2024-03-18  9:22       ` fengchengwen
2024-03-07 13:07   ` [PATCH v2 5/5] test/argparse: refine testcases Chengwen Feng
2024-03-18  9:18 ` [PATCH v3 0/6] refine argparse library Chengwen Feng
2024-03-18  9:18   ` [PATCH v3 1/6] argparse: refine error message Chengwen Feng
2024-03-18  9:18   ` [PATCH v3 2/6] argparse: remove dead code Chengwen Feng
2024-03-18  9:18   ` [PATCH v3 3/6] argparse: replace flag enum with marco Chengwen Feng
2024-03-18  9:18   ` [PATCH v3 4/6] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-18  9:38     ` Thomas Monjalon
2024-03-18 11:24       ` fengchengwen
2024-03-18  9:18   ` [PATCH v3 5/6] test/argparse: refine testcases Chengwen Feng
2024-03-18  9:18   ` Chengwen Feng [this message]
2024-03-18 11:18 ` [PATCH v4 0/6] refine argparse library Chengwen Feng
2024-03-18 11:18   ` [PATCH v4 1/6] argparse: refine error message Chengwen Feng
2024-03-18 11:18   ` [PATCH v4 2/6] argparse: remove dead code Chengwen Feng
2024-03-18 11:18   ` [PATCH v4 3/6] argparse: replace flag enum with marco Chengwen Feng
2024-03-18 11:18   ` [PATCH v4 4/6] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-18 11:18   ` [PATCH v4 5/6] test/argparse: refine testcases Chengwen Feng
2024-03-18 11:18   ` [PATCH v4 6/6] argparse: fix doc don't display two hyphens Chengwen Feng
2024-03-21 17:27   ` [PATCH v4 0/6] refine argparse library Thomas Monjalon
2024-03-22  1:24     ` fengchengwen
2024-05-08  9:10     ` fengchengwen

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=20240318091848.14360-7-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).