Skip to content

Commit

Permalink
deploy: 4d5f058
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Sep 6, 2023
1 parent 6f9a529 commit 8d1bfe4
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 138 deletions.
Binary file modified .doctrees/api/tyro/_argparse_formatter/index.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/examples/02_nesting/03_multiple_subcommands.doctree
Binary file not shown.
350 changes: 221 additions & 129 deletions _modules/tyro/_argparse_formatter/index.html

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions _modules/tyro/_cli/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ <h1>Source code for tyro._cli</h1><div class="highlight"><pre>

<span class="c1"># Print help message when no arguments are passed in. (but arguments are</span>
<span class="c1"># expected)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">parser_spec</span><span class="o">.</span><span class="n">has_required_args</span><span class="p">:</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;--help&quot;</span><span class="p">]</span>
<span class="c1"># if len(args) == 0 and parser_spec.has_required_args:</span>
<span class="c1"># args = [&quot;--help&quot;]</span>

<span class="k">if</span> <span class="n">return_parser</span><span class="p">:</span>
<span class="n">_arguments</span><span class="o">.</span><span class="n">USE_RICH</span> <span class="o">=</span> <span class="kc">True</span>
Expand Down Expand Up @@ -699,7 +699,6 @@ <h1>Source code for tyro._cli</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">._argparse_formatter</span> <span class="kn">import</span> <span class="n">THEME</span>

<span class="n">console</span> <span class="o">=</span> <span class="n">Console</span><span class="p">(</span><span class="n">theme</span><span class="o">=</span><span class="n">THEME</span><span class="o">.</span><span class="n">as_rich_theme</span><span class="p">())</span>
<span class="n">parser</span><span class="o">.</span><span class="n">_print_usage_succinct</span><span class="p">(</span><span class="n">console</span><span class="p">)</span>
<span class="n">console</span><span class="o">.</span><span class="n">print</span><span class="p">(</span>
<span class="n">Panel</span><span class="p">(</span>
<span class="n">Group</span><span class="p">(</span>
Expand All @@ -720,6 +719,8 @@ <h1>Source code for tyro._cli</h1><div class="highlight"><pre>
<span class="p">),</span>
<span class="n">pad</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span>
<span class="p">),</span>
<span class="n">Rule</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="n">Style</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s2">&quot;red&quot;</span><span class="p">)),</span>
<span class="sa">f</span><span class="s2">&quot;For full helptext, see [bold]</span><span class="si">{</span><span class="n">parser</span><span class="o">.</span><span class="n">prog</span><span class="si">}</span><span class="s2"> --help[/bold]&quot;</span><span class="p">,</span>
<span class="p">]</span>
<span class="p">),</span>
<span class="p">),</span>
Expand Down
15 changes: 15 additions & 0 deletions _sources/api/tyro/_argparse_formatter/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ Module Contents
Set an accent color to use in help messages. Takes any color supported by ``rich``\ ,
see ``python -m rich.color``. Experimental.

.. py:function:: recursive_arg_search(args: List[str], parser_spec: tyro._parsers.ParserSpecification, prog: str, unrecognized_arguments: Set[str]) -> Tuple[List[_ArgumentInfo], bool, bool]
Recursively search for arguments in a ParserSpecification. Used for error message
printing.

Returns a list of arguments, whether the parser has subcommands or not, and -- if
``unrecognized_arguments`` is passed in --- whether an unrecognized argument exists
under a different subparser.

:param args: Arguments being parsed. Used for heuristics on subcommands.
:param parser_spec: Argument parser specification.
:param subcommands: Prog corresponding to parser_spec.
:param unrecognized_arguments: Used for same_exists return value.

.. py:data:: THEME
Expand Down
25 changes: 25 additions & 0 deletions api/tyro/_argparse_formatter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,30 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Permalin
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tyro._argparse_formatter.recursive_arg_search">
<span class="sig-prename descclassname"><span class="pre">tyro._argparse_formatter.</span></span><span class="sig-name descname"><span class="pre">recursive_arg_search</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parser_spec</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../_parsers/#tyro._parsers.ParserSpecification" title="tyro._parsers.ParserSpecification"><span class="pre">tyro._parsers.ParserSpecification</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">prog</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unrecognized_arguments</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Set</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">_ArgumentInfo</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">bool</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">bool</span><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../../../_modules/tyro/_argparse_formatter/#recursive_arg_search"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tyro._argparse_formatter.recursive_arg_search" title="Permalink to this definition">#</a></dt>
<dd><p>Recursively search for arguments in a ParserSpecification. Used for error message
printing.</p>
<p>Returns a list of arguments, whether the parser has subcommands or not, and – if
<code class="docutils literal notranslate"><span class="pre">unrecognized_arguments</span></code> is passed in — whether an unrecognized argument exists
under a different subparser.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>args</strong> (<em>List</em><em>[</em><em>str</em><em>]</em>) – Arguments being parsed. Used for heuristics on subcommands.</p></li>
<li><p><strong>parser_spec</strong> (<a class="reference internal" href="../_parsers/#tyro._parsers.ParserSpecification" title="tyro._parsers.ParserSpecification"><em>tyro._parsers.ParserSpecification</em></a>) – Argument parser specification.</p></li>
<li><p><strong>subcommands</strong> – Prog corresponding to parser_spec.</p></li>
<li><p><strong>unrecognized_arguments</strong> (<em>Set</em><em>[</em><em>str</em><em>]</em>) – Used for same_exists return value.</p></li>
<li><p><strong>prog</strong> (<em>str</em>) – </p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>Tuple[List[_ArgumentInfo], bool, bool]</p>
</dd>
</dl>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="tyro._argparse_formatter.THEME">
<span class="sig-prename descclassname"><span class="pre">tyro._argparse_formatter.</span></span><span class="sig-name descname"><span class="pre">THEME</span></span><a class="headerlink" href="#tyro._argparse_formatter.THEME" title="Permalink to this definition">#</a></dt>
Expand Down Expand Up @@ -518,6 +542,7 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Permalin
</ul>
</li>
<li><a class="reference internal" href="#tyro._argparse_formatter.set_accent_color">set_accent_color</a></li>
<li><a class="reference internal" href="#tyro._argparse_formatter.recursive_arg_search">recursive_arg_search</a></li>
<li><a class="reference internal" href="#tyro._argparse_formatter.THEME">THEME</a></li>
<li><a class="reference internal" href="#tyro._argparse_formatter.monkeypatch_len">monkeypatch_len</a></li>
<li><a class="reference internal" href="#tyro._argparse_formatter.ansi_context">ansi_context</a></li>
Expand Down
10 changes: 5 additions & 5 deletions examples/02_nesting/03_multiple_subcommands/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ <h1>Sequenced Subcommands<a class="headerlink" href="#sequenced-subcommands" tit
</pre></div>
</div>
<hr class="docutils" />
<kbd>python 02_nesting/03_multiple_subcommands.py</kbd><pre class="ansi-block literal-block">usage: 03_multiple_subcommands.py [-h] {dataset:mnist,dataset:image-net}

╭─ Parsing error ──────────────────────────────────────────────────────────────
The following arguments are required: {dataset:mnist,dataset:image-net}
╰──────────────────────────────────────────────────────────────────────────────</pre>
<kbd>python 02_nesting/03_multiple_subcommands.py</kbd><pre class="ansi-block literal-block">╭─ Required arguments ────────────────────────────────────────────────────╮
│ The following arguments are required: {dataset:mnist,dataset:image-net} │
─────────────────────────────────────────────────────────────────────── │
For full helptext, run 03_multiple_subcommands.py --help
╰─────────────────────────────────────────────────────────────────────────╯</pre>
<hr class="docutils" />
<kbd>python 02_nesting/03_multiple_subcommands.py --help</kbd><pre class="ansi-block literal-block">usage: 03_multiple_subcommands.py [-h] {dataset:mnist,dataset:image-net}

Expand Down
2 changes: 2 additions & 0 deletions genindex/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,8 @@ <h2>P</h2>
<h2>R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="../api/tyro/_argparse_formatter/#tyro._argparse_formatter.recursive_arg_search">recursive_arg_search() (in module tyro._argparse_formatter)</a>
</li>
<li><a href="../api/tyro/_strings/#tyro._strings.remove_single_line_breaks">remove_single_line_breaks() (in module tyro._strings)</a>
</li>
<li><a href="../api/tyro/_arguments/#tyro._arguments.LoweredArgumentDefinition.required">required (tyro._arguments.LoweredArgumentDefinition attribute)</a>
Expand Down
Binary file modified objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 8d1bfe4

Please sign in to comment.