Browse Source

Duck types table

pull/36/head
Jure Šorn 5 years ago
parent
commit
ec203fd7a6
3 changed files with 50 additions and 8 deletions
  1. 16
      index.html
  2. 21
      parse.js
  3. 21
      web/script_2.js

16
index.html

@ -1071,14 +1071,14 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<span class="hljs-keyword">return</span> self.a[i] <span class="hljs-keyword">return</span> self.a[i]
</code></pre> </code></pre>
<h4 id="tableofprovidedmethods">Table of provided methods:</h4> <h4 id="tableofprovidedmethods">Table of provided methods:</h4>
<pre><code class="text language-text">+------------+----------+------------+----------+--------------+
| | iterable | collection | sequence | abc.Sequence |
+------------+----------+------------+----------+--------------+
| iter() | yes | yes | yes | yes |
| len() | | yes | yes | yes |
| getitem() | | | yes | yes |
| contains() | | yes | | yes |
+------------+----------+------------+----------+--------------+
<pre><code class="text language-text">┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓
┃ │ iterable │ collection │ sequence │ abc.Sequence ┃
┠────────────┼──────────┼────────────┼──────────┼──────────────┨
┃ iter() │ ✓ │ ✓ │ ✓ │ ✓ ┃
┃ len() │ │ ✓ │ ✓ │ ✓ ┃
┃ getitem() │ │ │ ✓ │ ✓ ┃
┃ contains() │ │ ✓ │ │ ✓ ┃
┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛
</code></pre> </code></pre>
<h3 id="iterator-1">Iterator</h3> <h3 id="iterator-1">Iterator</h3>
<pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span>:</span> <pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span>:</span>

21
parse.js

@ -140,6 +140,26 @@ const DIAGRAM_5_B =
"┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" + "┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; "┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_6_A =
'+------------+----------+------------+----------+--------------+\n' +
'| | iterable | collection | sequence | abc.Sequence |\n' +
'+------------+----------+------------+----------+--------------+\n' +
'| iter() | yes | yes | yes | yes |\n' +
'| len() | | yes | yes | yes |\n' +
'| getitem() | | | yes | yes |\n' +
'| contains() | | yes | | yes |\n' +
'+------------+----------+------------+----------+--------------+\n';
const DIAGRAM_6_B =
'┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
'┃ │ iterable │ collection │ sequence │ abc.Sequence ┃\n' +
'┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n' +
'┃ iter() │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' +
'┃ len() │ │ ✓ │ ✓ │ ✓ ┃\n' +
'┃ getitem() │ │ │ ✓ │ ✓ ┃\n' +
'┃ contains() │ │ ✓ │ │ ✓ ┃\n' +
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
function main() { function main() {
const html = getMd(); const html = getMd();
@ -172,6 +192,7 @@ function switchClassDiagrams(readme) {
readme = readme.replace(DIAGRAM_3_A, DIAGRAM_3_B) readme = readme.replace(DIAGRAM_3_A, DIAGRAM_3_B)
readme = readme.replace(DIAGRAM_4_A, DIAGRAM_4_B) readme = readme.replace(DIAGRAM_4_A, DIAGRAM_4_B)
readme = readme.replace(DIAGRAM_5_A, DIAGRAM_5_B) readme = readme.replace(DIAGRAM_5_A, DIAGRAM_5_B)
readme = readme.replace(DIAGRAM_6_A, DIAGRAM_6_B)
return readme return readme
} }

21
web/script_2.js

@ -108,6 +108,26 @@ const DIAGRAM_5_B =
"┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" + "┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" +
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; "┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
const DIAGRAM_6_A =
'+------------+----------+------------+----------+--------------+\n' +
'| | iterable | collection | sequence | abc.Sequence |\n' +
'+------------+----------+------------+----------+--------------+\n' +
'| iter() | yes | yes | yes | yes |\n' +
'| len() | | yes | yes | yes |\n' +
'| getitem() | | | yes | yes |\n' +
'| contains() | | yes | | yes |\n' +
'+------------+----------+------------+----------+--------------+\n';
const DIAGRAM_6_B =
'┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
'┃ │ iterable │ collection │ sequence │ abc.Sequence ┃\n' +
'┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n' +
'┃ iter() │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' +
'┃ len() │ │ ✓ │ ✓ │ ✓ ┃\n' +
'┃ getitem() │ │ │ ✓ │ ✓ ┃\n' +
'┃ contains() │ │ ✓ │ │ ✓ ┃\n' +
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
// isFontAvailable: // isFontAvailable:
(function(d){function c(c){b.style.fontFamily=c;e.appendChild(b);f=b.clientWidth;e.removeChild(b);return f}var f,e=d.body,b=d.createElement("span");b.innerHTML=Array(100).join("wi");b.style.cssText=["position:absolute","width:auto","font-size:128px","left:-99999px"].join(" !important;");var g=c("monospace"),h=c("serif"),k=c("sans-serif");window.isFontAvailable=function(b){return g!==c(b+",monospace")||k!==c(b+",sans-serif")||h!==c(b+",serif")}})(document); (function(d){function c(c){b.style.fontFamily=c;e.appendChild(b);f=b.clientWidth;e.removeChild(b);return f}var f,e=d.body,b=d.createElement("span");b.innerHTML=Array(100).join("wi");b.style.cssText=["position:absolute","width:auto","font-size:128px","left:-99999px"].join(" !important;");var g=c("monospace"),h=c("serif"),k=c("sans-serif");window.isFontAvailable=function(b){return g!==c(b+",monospace")||k!==c(b+",sans-serif")||h!==c(b+",serif")}})(document);
@ -118,6 +138,7 @@ if (!isFontAvailable('Menlo')) {
$(`code:contains(${DIAGRAM_3_B})`).html(DIAGRAM_3_A); $(`code:contains(${DIAGRAM_3_B})`).html(DIAGRAM_3_A);
$(`code:contains(${DIAGRAM_4_B})`).html(DIAGRAM_4_A); $(`code:contains(${DIAGRAM_4_B})`).html(DIAGRAM_4_A);
$(`code:contains(${DIAGRAM_5_B})`).html(DIAGRAM_5_A); $(`code:contains(${DIAGRAM_5_B})`).html(DIAGRAM_5_A);
$(`code:contains(${DIAGRAM_6_B})`).html(DIAGRAM_6_A);
// var htmlString = $('code:contains(ᴺᴱᵂ)').html().replace(/ᴺᴱᵂ/g, ''); // var htmlString = $('code:contains(ᴺᴱᵂ)').html().replace(/ᴺᴱᵂ/g, '');
// $('code:contains(ᴺᴱᵂ)').html(htmlString); // $('code:contains(ᴺᴱᵂ)').html(htmlString);
} }

Loading…
Cancel
Save