public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Fomichev <stfomichev@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	donald.hunter@gmail.com, gal@nvidia.com
Subject: Re: [PATCH net-next 2/7] tools: ynl: cli: wrap the doc text if it's long
Date: Sat, 10 Jan 2026 11:04:08 -0800	[thread overview]
Message-ID: <aWKiqKPYiAeeyhPq@mini-arch> (raw)
In-Reply-To: <20260109211756.3342477-3-kuba@kernel.org>

On 01/09, Jakub Kicinski wrote:
> We already use textwrap when printing "doc" section about an attribute,
> but only to indent the text. Switch to using fill() to split and indent
> all the lines. While at it indent the text by 2 more spaces, so that it
> doesn't align with the name of the attribute.
> 
> Before (I'm drawing a "box" at ~60 cols here, in an attempt for clarity):
> 
>  |  - irq-suspend-timeout: uint                              |
>  |    The timeout, in nanoseconds, of how long to suspend irq|
>  |processing, if event polling finds events                  |
> 
> After:
> 
>  |  - irq-suspend-timeout: uint                              |
>  |      The timeout, in nanoseconds, of how long to suspend  |
>  |      irq processing, if event polling finds events        |
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  tools/net/ynl/pyynl/cli.py | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/net/ynl/pyynl/cli.py b/tools/net/ynl/pyynl/cli.py
> index aa50d42e35ac..e5e71ee4e133 100755
> --- a/tools/net/ynl/pyynl/cli.py
> +++ b/tools/net/ynl/pyynl/cli.py
> @@ -10,6 +10,7 @@ import json
>  import os
>  import pathlib
>  import pprint
> +import shutil
>  import sys
>  import textwrap
>  
> @@ -101,7 +102,14 @@ RELATIVE_SCHEMA_DIR='../../../../Documentation/netlink'
>                  attr_info += f" -> {nested_set_name}"
>  
>              if attr.yaml.get('doc'):
> -                doc_text = textwrap.indent(attr.yaml['doc'], prefix + '  ')
> +                doc_prefix = prefix + ' ' * 4
> +                if sys.stdout.isatty():
> +                    term_width = shutil.get_terminal_size().columns
> +                else:
> +                    term_width = 80
> +                doc_text = textwrap.fill(attr.yaml['doc'], width=term_width,
> +                                         initial_indent=doc_prefix,
> +                                         subsequent_indent=doc_prefix)

Any specific reason you wrap to 80 for !isatty?

  reply	other threads:[~2026-01-10 19:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 21:17 [PATCH net-next 0/7] tools: ynl: cli: improve the help and doc Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 1/7] tools: ynl: cli: introduce formatting for attr names in --list-attrs Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 2/7] tools: ynl: cli: wrap the doc text if it's long Jakub Kicinski
2026-01-10 19:04   ` Stanislav Fomichev [this message]
2026-01-10 19:07     ` Jakub Kicinski
2026-01-10 23:26       ` Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 3/7] tools: ynl: cli: improve --help Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 4/7] tools: ynl: cli: add --doc as alias to --list-attrs Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 5/7] tools: ynl: cli: factor out --list-attrs / --doc handling Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 6/7] tools: ynl: cli: extract the event/notify handling in --list-attrs Jakub Kicinski
2026-01-09 21:17 ` [PATCH net-next 7/7] tools: ynl: cli: print reply in combined format if possible Jakub Kicinski

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=aWKiqKPYiAeeyhPq@mini-arch \
    --to=stfomichev@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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