Skip to content

Commit

Permalink
Deployed 33ea7f6 with MkDocs version: 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Sep 10, 2024
1 parent 6a95398 commit 7e6bf03
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
41 changes: 38 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ <h2 id="you-got-dialogues">You got dialogues</h2>
<a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a> <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Your important number is </span><span class="si">{</span><span class="n">m</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">important_number</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a> <span class="n">boolean</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">is_yes</span><span class="p">(</span><span class="s2">&quot;Is that alright?&quot;</span><span class="p">)</span>
</code></pre></div>
<p><img alt="Small window with the text 'Your important number'" src="docs/asset/hello-with-statement.webp" title="With statement to redirect the output" />
<img alt="The same in terminal'" src="docs/asset/hello-with-statement-tui.avif" title="With statement in TUI fallback" /></p>
<p><img alt="Small window with the text 'Your important number'" src="asset/hello-with-statement.webp" title="With statement to redirect the output" />
<img alt="The same in terminal'" src="asset/hello-with-statement-tui.avif" title="With statement in TUI fallback" /></p>
<h1 id="contents">Contents</h1>
<ul>
<li><a href="#mininterface-gui-tui-cli-and-config">Mininterface – GUI, TUI, CLI and config</a></li>
Expand All @@ -540,7 +540,42 @@ <h1 id="installation">Installation</h1>
<h1 id="docs">Docs</h1>
<p>See the docs at https://cz-nic.github.io/mininterface/.</p>
<h1 id="examples">Examples</h1>
<p>TODO a complex one</p>
<p>This is a complex example.</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Annotated</span>
<a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a><span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span>
<a id="__codelineno-5-3" name="__codelineno-5-3" href="#__codelineno-5-3"></a><span class="kn">from</span> <span class="nn">mininterface.validators</span> <span class="kn">import</span> <span class="n">not_empty</span>
<a id="__codelineno-5-4" name="__codelineno-5-4" href="#__codelineno-5-4"></a><span class="kn">from</span> <span class="nn">mininterface</span> <span class="kn">import</span> <span class="n">run</span><span class="p">,</span> <span class="n">Tag</span><span class="p">,</span> <span class="n">Validation</span>
<a id="__codelineno-5-5" name="__codelineno-5-5" href="#__codelineno-5-5"></a>
<a id="__codelineno-5-6" name="__codelineno-5-6" href="#__codelineno-5-6"></a><span class="nd">@dataclass</span>
<a id="__codelineno-5-7" name="__codelineno-5-7" href="#__codelineno-5-7"></a><span class="k">class</span> <span class="nc">NestedEnv</span><span class="p">:</span>
<a id="__codelineno-5-8" name="__codelineno-5-8" href="#__codelineno-5-8"></a> <span class="n">another_number</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">7</span>
<a id="__codelineno-5-9" name="__codelineno-5-9" href="#__codelineno-5-9"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot; This field is nested &quot;&quot;&quot;</span>
<a id="__codelineno-5-10" name="__codelineno-5-10" href="#__codelineno-5-10"></a>
<a id="__codelineno-5-11" name="__codelineno-5-11" href="#__codelineno-5-11"></a><span class="nd">@dataclass</span>
<a id="__codelineno-5-12" name="__codelineno-5-12" href="#__codelineno-5-12"></a><span class="k">class</span> <span class="nc">Env</span><span class="p">:</span>
<a id="__codelineno-5-13" name="__codelineno-5-13" href="#__codelineno-5-13"></a> <span class="n">nested_config</span><span class="p">:</span> <span class="n">NestedEnv</span>
<a id="__codelineno-5-14" name="__codelineno-5-14" href="#__codelineno-5-14"></a>
<a id="__codelineno-5-15" name="__codelineno-5-15" href="#__codelineno-5-15"></a> <span class="n">my_number</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">5</span>
<a id="__codelineno-5-16" name="__codelineno-5-16" href="#__codelineno-5-16"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot; This is just a dummy number &quot;&quot;&quot;</span>
<a id="__codelineno-5-17" name="__codelineno-5-17" href="#__codelineno-5-17"></a>
<a id="__codelineno-5-18" name="__codelineno-5-18" href="#__codelineno-5-18"></a> <span class="n">my_string</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;Hello&quot;</span>
<a id="__codelineno-5-19" name="__codelineno-5-19" href="#__codelineno-5-19"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot; A dummy string &quot;&quot;&quot;</span>
<a id="__codelineno-5-20" name="__codelineno-5-20" href="#__codelineno-5-20"></a>
<a id="__codelineno-5-21" name="__codelineno-5-21" href="#__codelineno-5-21"></a> <span class="n">my_flag</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
<a id="__codelineno-5-22" name="__codelineno-5-22" href="#__codelineno-5-22"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot; Checkbox test &quot;&quot;&quot;</span>
<a id="__codelineno-5-23" name="__codelineno-5-23" href="#__codelineno-5-23"></a>
<a id="__codelineno-5-24" name="__codelineno-5-24" href="#__codelineno-5-24"></a> <span class="n">my_validated</span><span class="p">:</span> <span class="n">Annotated</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Validation</span><span class="p">(</span><span class="n">not_empty</span><span class="p">)]</span> <span class="o">=</span> <span class="s2">&quot;hello&quot;</span>
<a id="__codelineno-5-25" name="__codelineno-5-25" href="#__codelineno-5-25"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot; A validated field &quot;&quot;&quot;</span>
<a id="__codelineno-5-26" name="__codelineno-5-26" href="#__codelineno-5-26"></a>
<a id="__codelineno-5-27" name="__codelineno-5-27" href="#__codelineno-5-27"></a><span class="n">m</span> <span class="o">=</span> <span class="n">run</span><span class="p">(</span><span class="n">Env</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;My program&quot;</span><span class="p">)</span>
<a id="__codelineno-5-28" name="__codelineno-5-28" href="#__codelineno-5-28"></a><span class="c1"># See some values</span>
<a id="__codelineno-5-29" name="__codelineno-5-29" href="#__codelineno-5-29"></a><span class="nb">print</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">nested_config</span><span class="o">.</span><span class="n">another_number</span><span class="p">)</span> <span class="c1"># 7</span>
<a id="__codelineno-5-30" name="__codelineno-5-30" href="#__codelineno-5-30"></a><span class="nb">print</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">env</span><span class="p">)</span>
<a id="__codelineno-5-31" name="__codelineno-5-31" href="#__codelineno-5-31"></a><span class="c1"># Env(nested_config=NestedEnv(another_number=7), my_number=5, my_string=&#39;Hello&#39;, my_flag=False, my_validated=&#39;hello&#39;)</span>
<a id="__codelineno-5-32" name="__codelineno-5-32" href="#__codelineno-5-32"></a>
<a id="__codelineno-5-33" name="__codelineno-5-33" href="#__codelineno-5-33"></a><span class="c1"># Edit values in a dialog</span>
<a id="__codelineno-5-34" name="__codelineno-5-34" href="#__codelineno-5-34"></a><span class="n">m</span><span class="o">.</span><span class="n">form</span><span class="p">()</span>
</code></pre></div>



Expand Down
Loading

0 comments on commit 7e6bf03

Please sign in to comment.