Skip to content
Myr

restore “eval-rst … click:example::” directives

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by denuoweb · committed by denuoweb · parent 38d9d60 · Browse files · 1 file+13 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−11 removed

  • other:+13 added−11 removed

1 file+13 added−11 removed

modified:docs/utils.md+13 added-11 removed
87 unmodified lines
88writes to stdout and, if possible, through a pager.8990Example:9192```{eval-rst}92```python93@click.command()94def less():95 click.echo_via_pager("\n".join(f"Line {idx}" for idx in range(200)))93.. click:example::94 @click.command()95 def less():96 click.echo_via_pager("\n".join(f"Line {idx}" for idx in range(200)))97```9899If you want to use the pager for a lot of text, especially if generating everything in advance would take a lot of time,100you can pass a generator (or generator function) instead of a string:101102```{eval-rst}101```python102def _generate_output():103 for idx in range(50000):104 yield f"Line {idx}\n"103.. click:example::104 def _generate_output():105 for idx in range(50000):106 yield f"Line {idx}\n"107106@click.command()107def less():108 click.echo_via_pager(_generate_output())108 @click.command()109 def less():110 click.echo_via_pager(_generate_output())111```112113## Screen Clearing114
278 unmodified lines