Skip to content

Commit

Permalink
Update various docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasdabbas committed Apr 2, 2024
1 parent f6b052c commit 80aaf75
Show file tree
Hide file tree
Showing 34 changed files with 1,472 additions and 970 deletions.
2 changes: 1 addition & 1 deletion advertools/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def crawl(
custom_settings=None,
):
"""
Crawl a website of a list of URLs based on the supplied options.
Crawl a website or a list of URLs based on the supplied options.
Parameters
----------
Expand Down
Binary file modified docs/_build/doctrees/advertools.ad_create.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.extract.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.knowledge_graph.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.logs.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.reverse_dns_lookup.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.robotstxt.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.serp.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.sitemaps.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/advertools.spider.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
65 changes: 43 additions & 22 deletions docs/_build/html/_modules/advertools/ad_create.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ <h1>Source code for advertools.ad_create</h1><div class="highlight"><pre>
<span class="sd"> &#39;5-star Hotels In Portugal&#39;]</span>

<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">string</span>


Expand All @@ -191,41 +192,61 @@ <h1>Source code for advertools.ad_create</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="nf">ad_create</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">replacements</span><span class="p">,</span> <span class="n">fallback</span><span class="p">,</span> <span class="n">max_len</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="n">capitalize</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Insert each of the replacement strings in its place within template.</span>

<span class="sd"> :param str template: a string format template, using braces e.g. &quot;Get the</span>
<span class="sd"> latest {} today.&quot;</span>
<span class="sd"> :param list replacements: replacement strings to be inserted in</span>
<span class="sd"> :attr:`template`</span>
<span class="sd"> :param str fallback: the string to insert in :attr:`template` in case</span>
<span class="sd"> :attr:`replacement` is longer than :attr:`max_len`</span>
<span class="sd"> :param int max_len: the maximum allowed length of the full string</span>
<span class="sd"> :param bool capitalize: whether or not to capitalize words in the result</span>
<span class="sd"> :returns formatted: list of strings</span>

<span class="sd"> &gt;&gt;&gt; ad_create(&quot;Let\&#39;s count {}&quot;, [&#39;one&#39;, &#39;two&#39;, &#39;three&#39;], &#39;one&#39;, 20)</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> template : str</span>
<span class="sd"> A string format template, using braces e.g. &quot;Get the latest {} today.&quot;</span>
<span class="sd"> replacements : list</span>
<span class="sd"> Replacement strings to be inserted in :attr:`template`.</span>
<span class="sd"> fallback : str</span>
<span class="sd"> The string to insert in :attr:`template` in case :attr:`replacement` is longer</span>
<span class="sd"> than :attr:`max_len`.</span>
<span class="sd"> max_len : int</span>
<span class="sd"> The maximum allowed length of the full string.</span>
<span class="sd"> capitalize : bool</span>
<span class="sd"> Whether or not to capitalize words in the result.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> formatted : list</span>
<span class="sd"> List of ads (strings).</span>

<span class="sd"> Examples</span>
<span class="sd"> --------</span>
<span class="sd"> &gt;&gt;&gt; ad_create(&quot;Let&#39;s count {}&quot;, [&quot;one&quot;, &quot;two&quot;, &quot;three&quot;], &quot;one&quot;, 20)</span>
<span class="sd"> [&quot;Let&#39;s Count One&quot;, &quot;Let&#39;s Count Two&quot;, &quot;Let&#39;s Count Three&quot;]</span>

<span class="sd"> &gt;&gt;&gt; ad_create(template=&#39;My favorite car is {}&#39;,</span>
<span class="sd"> ... replacements=[&#39;Toyota&#39;, &#39;BMW&#39;, &#39;Mercedes&#39;, &#39;Lamborghini&#39;],</span>
<span class="sd"> ... fallback=&#39;great&#39;,</span>
<span class="sd"> ... max_len=28)</span>
<span class="sd"> &gt;&gt;&gt; ad_create(</span>
<span class="sd"> ... template=&quot;My favorite car is {}&quot;,</span>
<span class="sd"> ... replacements=[&quot;Toyota&quot;, &quot;BMW&quot;, &quot;Mercedes&quot;, &quot;Lamborghini&quot;],</span>
<span class="sd"> ... fallback=&quot;great&quot;,</span>
<span class="sd"> ... max_len=28,</span>
<span class="sd"> ... )</span>
<span class="sd"> [&#39;My Favorite Car Is Toyota&#39;, &#39;My Favorite Car Is Bmw&#39;,</span>
<span class="sd"> &#39;My Favorite Car Is Mercedes&#39;, &#39;My Favorite Car Is Great&#39;]</span>

<span class="sd"> &gt;&gt;&gt; ad_create(&#39;KeEP cApITalization {}&#39;, [&#39;As IS&#39;],</span>
<span class="sd"> ... fallback=&#39;fallback&#39;, max_len=50, capitalize=False)</span>
<span class="sd"> &gt;&gt;&gt; ad_create(</span>
<span class="sd"> ... &quot;KeEP cApITalization {}&quot;,</span>
<span class="sd"> ... [&quot;As IS&quot;],</span>
<span class="sd"> ... fallback=&quot;fallback&quot;,</span>
<span class="sd"> ... max_len=50,</span>
<span class="sd"> ... capitalize=False,</span>
<span class="sd"> ... )</span>
<span class="sd"> [&#39;KeEP cApITalization As IS&#39;]</span>

<span class="sd"> &gt;&gt;&gt; ad_create(&#39;This is very long and will produce and error&#39;,</span>
<span class="sd"> ... replacements=[&#39;something&#39;, &#39;long&#39;], fallback=&#39;Very long&#39;,</span>
<span class="sd"> ... max_len=20)</span>
<span class="sd"> &gt;&gt;&gt; ad_create(</span>
<span class="sd"> ... &quot;This is very long and will produce and error&quot;,</span>
<span class="sd"> ... replacements=[&quot;something&quot;, &quot;long&quot;],</span>
<span class="sd"> ... fallback=&quot;Very long&quot;,</span>
<span class="sd"> ... max_len=20,</span>
<span class="sd"> ... )</span>
<span class="sd"> Traceback (most recent call last):</span>
<span class="sd"> File &quot;&lt;input&gt;&quot;, line 1, in &lt;module&gt;</span>
<span class="sd"> File &quot;&lt;input&gt;&quot;, line 26, in ad_create</span>
<span class="sd"> ValueError: template + fallback should be &lt;= 20 chars</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">template</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">fallback</span><span class="p">))</span> <span class="o">&gt;</span> <span class="n">max_len</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;template + fallback should be &lt;= &#39;</span>
<span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">max_len</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; chars&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;template + fallback should be &lt;= &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">max_len</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; chars&quot;</span><span class="p">)</span>
<span class="n">final_ad</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">rep</span> <span class="ow">in</span> <span class="n">replacements</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">template</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">rep</span><span class="p">))</span> <span class="o">&lt;=</span> <span class="n">max_len</span><span class="p">:</span>
Expand Down
3 changes: 2 additions & 1 deletion docs/_build/html/_modules/advertools/emoji.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
<div itemprop="articleBody">

<h1>Source code for advertools.emoji</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span></span><span class="c1"># ruff: noqa: E501</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">.. _emoji:</span>

<span class="sd">Emoji: Extract, Analyze, and Get Insights</span>
Expand Down
Loading

0 comments on commit 80aaf75

Please sign in to comment.