Skip to content

Commit ec203fd

Browse files
committed
Duck types table
1 parent ca62436 commit ec203fd

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,14 +1071,14 @@ <h3 id="collectionsabcsequence">Collections.abc.Sequence</h3>
10711071
<span class="hljs-keyword">return</span> self.a[i]
10721072
</code></pre>
10731073
<h4 id="tableofprovidedmethods">Table of provided methods:</h4>
1074-
<pre><code class="text language-text">+------------+----------+------------+----------+--------------+
1075-
| | iterable | collection | sequence | abc.Sequence |
1076-
+------------+----------+------------+----------+--------------+
1077-
| iter() | yes | yes | yes | yes |
1078-
| len() | | yes | yes | yes |
1079-
| getitem() | | | yes | yes |
1080-
| contains() | | yes | | yes |
1081-
+------------+----------+------------+----------+--------------+
1074+
<pre><code class="text language-text">┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓
1075+
iterable collection sequence abc.Sequence
1076+
┠────────────┼──────────┼────────────┼──────────┼──────────────┨
1077+
iter() ✓ ┃
1078+
len() ✓ ┃
1079+
getitem()
1080+
contains()
1081+
┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛
10821082
</code></pre>
10831083
<h3 id="iterator-1">Iterator</h3>
10841084
<pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span>:</span>

parse.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,26 @@ const DIAGRAM_5_B =
140140
"┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" +
141141
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
142142

143+
const DIAGRAM_6_A =
144+
'+------------+----------+------------+----------+--------------+\n' +
145+
'| | iterable | collection | sequence | abc.Sequence |\n' +
146+
'+------------+----------+------------+----------+--------------+\n' +
147+
'| iter() | yes | yes | yes | yes |\n' +
148+
'| len() | | yes | yes | yes |\n' +
149+
'| getitem() | | | yes | yes |\n' +
150+
'| contains() | | yes | | yes |\n' +
151+
'+------------+----------+------------+----------+--------------+\n';
152+
153+
const DIAGRAM_6_B =
154+
'┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
155+
'┃ │ iterable │ collection │ sequence │ abc.Sequence ┃\n' +
156+
'┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n' +
157+
'┃ iter() │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' +
158+
'┃ len() │ │ ✓ │ ✓ │ ✓ ┃\n' +
159+
'┃ getitem() │ │ │ ✓ │ ✓ ┃\n' +
160+
'┃ contains() │ │ ✓ │ │ ✓ ┃\n' +
161+
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
162+
143163

144164
function main() {
145165
const html = getMd();
@@ -172,6 +192,7 @@ function switchClassDiagrams(readme) {
172192
readme = readme.replace(DIAGRAM_3_A, DIAGRAM_3_B)
173193
readme = readme.replace(DIAGRAM_4_A, DIAGRAM_4_B)
174194
readme = readme.replace(DIAGRAM_5_A, DIAGRAM_5_B)
195+
readme = readme.replace(DIAGRAM_6_A, DIAGRAM_6_B)
175196
return readme
176197
}
177198

web/script_2.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,26 @@ const DIAGRAM_5_B =
108108
"┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" +
109109
"┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n";
110110

111+
const DIAGRAM_6_A =
112+
'+------------+----------+------------+----------+--------------+\n' +
113+
'| | iterable | collection | sequence | abc.Sequence |\n' +
114+
'+------------+----------+------------+----------+--------------+\n' +
115+
'| iter() | yes | yes | yes | yes |\n' +
116+
'| len() | | yes | yes | yes |\n' +
117+
'| getitem() | | | yes | yes |\n' +
118+
'| contains() | | yes | | yes |\n' +
119+
'+------------+----------+------------+----------+--------------+\n';
120+
121+
const DIAGRAM_6_B =
122+
'┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
123+
'┃ │ iterable │ collection │ sequence │ abc.Sequence ┃\n' +
124+
'┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n' +
125+
'┃ iter() │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' +
126+
'┃ len() │ │ ✓ │ ✓ │ ✓ ┃\n' +
127+
'┃ getitem() │ │ │ ✓ │ ✓ ┃\n' +
128+
'┃ contains() │ │ ✓ │ │ ✓ ┃\n' +
129+
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
130+
111131

112132
// isFontAvailable:
113133
(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')) {
118138
$(`code:contains(${DIAGRAM_3_B})`).html(DIAGRAM_3_A);
119139
$(`code:contains(${DIAGRAM_4_B})`).html(DIAGRAM_4_A);
120140
$(`code:contains(${DIAGRAM_5_B})`).html(DIAGRAM_5_A);
141+
$(`code:contains(${DIAGRAM_6_B})`).html(DIAGRAM_6_A);
121142
// var htmlString = $('code:contains(ᴺᴱᵂ)').html().replace(/ᴺᴱᵂ/g, '');
122143
// $('code:contains(ᴺᴱᵂ)').html(htmlString);
123144
}

0 commit comments

Comments
 (0)