From 3a1ba7e1f3558e79b9e5eb84b41457326ca431c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 8 Jul 2019 16:03:00 +0200 Subject: [PATCH] Ascii tables are now used by default instead of unicode ones --- index.html | 140 ++++++++++++++++++++++++------------------------ parse.js | 2 +- web/script_2.js | 46 ++++++++-------- 3 files changed, 93 insertions(+), 95 deletions(-) diff --git a/index.html b/index.html index 648ed18..3a1e3b3 100644 --- a/index.html +++ b/index.html @@ -380,26 +380,26 @@ to_exclusive = <range>.stop >>> isinstance([1, 2, 3], Iterable) True -
┏━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┓
-┃                  │ Sequence │ Collection │ Iterable ┃
-┠──────────────────┼──────────┼────────────┼──────────┨
-┃ list, range, str │    ✓     │     ✓      │    ✓     ┃
-┃ dict, set        │          │     ✓      │    ✓     ┃
-┃ iter             │          │            │    ✓     ┃
-┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┛
+
+------------------+----------+------------+----------+
+|                  | Sequence | Collection | Iterable |
++------------------+----------+------------+----------+
+| list, range, str |   yes    |    yes     |   yes    |
+| dict, set        |          |    yes     |   yes    |
+| iter             |          |            |   yes    |
++------------------+----------+------------+----------+
 
>>> from numbers import Integral, Rational, Real, Complex, Number
 >>> isinstance(123, Number)
 True
 
-
┏━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━┯━━━━━━━━━┯━━━━━━━━┓
-┃                    │ Integral │ Rational │ Real │ Complex │ Number ┃
-┠────────────────────┼──────────┼──────────┼──────┼─────────┼────────┨
-┃ int                │    ✓     │    ✓     │  ✓   │    ✓    │   ✓    ┃
-┃ fractions.Fraction │          │    ✓     │  ✓   │    ✓    │   ✓    ┃
-┃ float              │          │          │  ✓   │    ✓    │   ✓    ┃
-┃ complex            │          │          │      │    ✓    │   ✓    ┃
-┗━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━┛
+
+--------------------+----------+----------+------+---------+--------+
+|                    | Integral | Rational | Real | Complex | Number |
++--------------------+----------+----------+------+---------+--------+
+| int                |   yes    |   yes    | yes  |   yes   |  yes   |
+| fractions.Fraction |          |   yes    | yes  |   yes   |  yes   |
+| float              |          |          | yes  |   yes   |  yes   |
+| complex            |          |          |      |   yes   |  yes   |
++--------------------+----------+----------+------+---------+--------+
 

#String

<str>  = <str>.strip()                       # Strips all whitespace characters from both ends.
@@ -509,31 +509,31 @@ to_exclusive   = <range>.stop
 {1.23456:10.3%}  # '  123.456%'
 

Comparison of float presentation types:

-
┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓
-┃                │    {<float>}   │  {<float>:f}  │   {<float>:e}  │   {<float>:%}   ┃
-┠────────────────┼────────────────┼───────────────┼────────────────┼─────────────────┨
-┃    0.000056789 │   '5.6789e-05' │    '0.000057' │ '5.678900e-05' │     '0.005679%' ┃
-┃    0.00056789  │   '0.00056789' │    '0.000568' │ '5.678900e-04' │     '0.056789%' ┃
-┃    0.0056789   │   '0.0056789'  │    '0.005679' │ '5.678900e-03' │     '0.567890%' ┃
-┃    0.056789    │   '0.056789'   │    '0.056789' │ '5.678900e-02' │     '5.678900%' ┃
-┃    0.56789     │   '0.56789'    │    '0.567890' │ '5.678900e-01' │    '56.789000%' ┃
-┃    5.6789      │   '5.6789'     │    '5.678900' │ '5.678900e+00' │   '567.890000%' ┃
-┃   56.789       │  '56.789'      │   '56.789000' │ '5.678900e+01' │  '5678.900000%' ┃
-┃  567.89        │ '567.89'       │  '567.890000' │ '5.678900e+02' │ '56789.000000%' ┃
-┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┛
-
-
┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓
-┃                │  {<float>:.2}  │ {<float>:.2f} │  {<float>:.2e} │  {<float>:.2%}  ┃
-┠────────────────┼────────────────┼───────────────┼────────────────┼─────────────────┨
-┃    0.000056789 │   '5.7e-05'    │      '0.00'   │   '5.68e-05'   │       '0.01%'   ┃
-┃    0.00056789  │   '0.00057'    │      '0.00'   │   '5.68e-04'   │       '0.06%'   ┃
-┃    0.0056789   │   '0.0057'     │      '0.01'   │   '5.68e-03'   │       '0.57%'   ┃
-┃    0.056789    │   '0.057'      │      '0.06'   │   '5.68e-02'   │       '5.68%'   ┃
-┃    0.56789     │   '0.57'       │      '0.57'   │   '5.68e-01'   │      '56.79%'   ┃
-┃    5.6789      │   '5.7'        │      '5.68'   │   '5.68e+00'   │     '567.89%'   ┃
-┃   56.789       │   '5.7e+01'    │     '56.79'   │   '5.68e+01'   │    '5678.90%'   ┃
-┃  567.89        │   '5.7e+02'    │    '567.89'   │   '5.68e+02'   │   '56789.00%'   ┃
-┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┛
+
+----------------+----------------+---------------+----------------+-----------------+
+|                |    {<float>}   |  {<float>:f}  |   {<float>:e}  |   {<float>:%}   |
++----------------+----------------+---------------+----------------+-----------------+
+|    0.000056789 |   '5.6789e-05' |    '0.000057' | '5.678900e-05' |     '0.005679%' |
+|    0.00056789  |   '0.00056789' |    '0.000568' | '5.678900e-04' |     '0.056789%' |
+|    0.0056789   |   '0.0056789'  |    '0.005679' | '5.678900e-03' |     '0.567890%' |
+|    0.056789    |   '0.056789'   |    '0.056789' | '5.678900e-02' |     '5.678900%' |
+|    0.56789     |   '0.56789'    |    '0.567890' | '5.678900e-01' |    '56.789000%' |
+|    5.6789      |   '5.6789'     |    '5.678900' | '5.678900e+00' |   '567.890000%' |
+|   56.789       |  '56.789'      |   '56.789000' | '5.678900e+01' |  '5678.900000%' |
+|  567.89        | '567.89'       |  '567.890000' | '5.678900e+02' | '56789.000000%' |
++----------------+----------------+---------------+----------------+-----------------+
+
+
+----------------+----------------+---------------+----------------+-----------------+
+|                |  {<float>:.2}  | {<float>:.2f} |  {<float>:.2e} |  {<float>:.2%}  |
++----------------+----------------+---------------+----------------+-----------------+
+|    0.000056789 |   '5.7e-05'    |      '0.00'   |   '5.68e-05'   |       '0.01%'   |
+|    0.00056789  |   '0.00057'    |      '0.00'   |   '5.68e-04'   |       '0.06%'   |
+|    0.0056789   |   '0.0057'     |      '0.01'   |   '5.68e-03'   |       '0.57%'   |
+|    0.056789    |   '0.057'      |      '0.06'   |   '5.68e-02'   |       '5.68%'   |
+|    0.56789     |   '0.57'       |      '0.57'   |   '5.68e-01'   |      '56.79%'   |
+|    5.6789      |   '5.7'        |      '5.68'   |   '5.68e+00'   |     '567.89%'   |
+|   56.789       |   '5.7e+01'    |     '56.79'   |   '5.68e+01'   |    '5678.90%'   |
+|  567.89        |   '5.7e+02'    |    '567.89'   |   '5.68e+02'   |   '56789.00%'   |
++----------------+----------------+---------------+----------------+-----------------+
 

Ints

{90:c}           # 'Z'
@@ -1153,18 +1153,18 @@ lock = threading.RLock(); with lock: ...
         return self.a[i]
 

Table of required and available special methods:

-
┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓
-┃            │ Iterable │ Collection │ Sequence │ abc.Sequence ┃
-┠────────────┼──────────┼────────────┼──────────┼──────────────┨
-┃ iter()     │    !     │     !      │    ✓     │      ✓       ┃
-┃ contains() │    ✓     │     ✓      │    ✓     │      ✓       ┃
-┃ len()      │          │     !      │    !     │      !       ┃
-┃ getitem()  │          │            │    !     │      !       ┃
-┃ reversed() │          │            │    ✓     │      ✓       ┃
-┃ reverse()  │          │            │          │      ✓       ┃
-┃ index()    │          │            │          │      ✓       ┃
-┃ count()    │          │            │          │      ✓       ┃
-┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛
+
+------------+----------+------------+----------+--------------+
+|            | Iterable | Collection | Sequence | abc.Sequence |
++------------+----------+------------+----------+--------------+
+| iter()     |   REQ    |    REQ     |   yes    |     yes      |
+| contains() |   yes    |    yes     |   yes    |     yes      |
+| len()      |          |    REQ     |   REQ    |     REQ      |
+| getitem()  |          |            |   REQ    |     REQ      |
+| reversed() |          |            |   yes    |     yes      |
+| reverse()  |          |            |          |     yes      |
+| index()    |          |            |          |     yes      |
+| count()    |          |            |          |     yes      |
++------------+----------+------------+----------+--------------+
 
  • Other useful ABCs that automatically generate missing methods are: MutableSequence, Set, MutableSet, Mapping and MutableMapping.
  • @@ -1633,29 +1633,29 @@ param_names = list(<sig>.parameters.keys())
    type(MyClass)     == MyMetaClass  # MyClass is an instance of MyMetaClass.
     type(MyMetaClass) == type         # MyMetaClass is an instance of type.
     
    -
    ┏━━━━━━━━━┯━━━━━━━━━━━━━┓
    -┃ Classes │ Metaclasses ┃
    -┠─────────┼─────────────┨
    -┃ MyClass → MyMetaClass ┃
    -┃         │     ↓       ┃
    -┃  object ───→ type ←╮  ┃
    -┃         │    ↑ ╰───╯  ┃
    -┃   str ───────╯        ┃
    -┗━━━━━━━━━┷━━━━━━━━━━━━━┛
    +
    +---------+-------------+
    +| Classes | Metaclasses |
    ++---------+-------------|
    +| MyClass > MyMetaClass |
    +|         |     v       |
    +|  object ---> type <+  |
    +|         |    ^ +---+  |
    +|   str -------+        |
    ++---------+-------------+
     

    Inheritance Diagram

    MyClass.__base__     == object    # MyClass is a subclass of object.
     MyMetaClass.__base__ == type      # MyMetaClass is a subclass of type.
     
    -
    ┏━━━━━━━━━┯━━━━━━━━━━━━━┓
    -┃ Classes │ Metaclasses ┃
    -┠─────────┼─────────────┨
    -┃ MyClass │ MyMetaClass ┃
    -┃    ↓    │     ↓       ┃
    -┃  object ←─── type     ┃
    -┃    ↑    │             ┃
    -┃   str   │             ┃
    -┗━━━━━━━━━┷━━━━━━━━━━━━━┛
    +
    +---------+-------------+
    +| Classes | Metaclasses |
    ++---------+-------------|
    +| MyClass | MyMetaClass |
    +|    v    |     v       |
    +|  object <--- type     |
    +|    ^    |             |
    +|   str   |             |
    ++---------+-------------+
     

    #Operator

    from operator import add, sub, mul, truediv, floordiv, mod, pow, neg, abs
    diff --git a/parse.js b/parse.js
    index 3ba07ff..8f407e7 100755
    --- a/parse.js
    +++ b/parse.js
    @@ -217,7 +217,7 @@ function initDom(html) {
     
     function getMd() {
       var readme = readFile('README.md');
    -  readme = switchClassDiagrams(readme);
    +  // readme = switchClassDiagrams(readme);
       const converter = new showdown.Converter();
       return converter.makeHtml(readme);
     }
    diff --git a/web/script_2.js b/web/script_2.js
    index 8e211e3..637d97d 100644
    --- a/web/script_2.js
    +++ b/web/script_2.js
    @@ -82,7 +82,7 @@ const DIAGRAM_4_B =
     
     const DIAGRAM_5_A =
       "+----------------+----------------+---------------+----------------+-----------------+\n" +
    -  "|                |    {<float>}   |  {<float>:f}  |   {<float>:e}  |   {<float>:%}   |\n" +
    +  "|                |    {}   |  {:f}  |   {:e}  |   {:%}   |\n" +
       "+----------------+----------------+---------------+----------------+-----------------+\n" +
       "|    0.000056789 |   '5.6789e-05' |    '0.000057' | '5.678900e-05' |     '0.005679%' |\n" +
       "|    0.00056789  |   '0.00056789' |    '0.000568' | '5.678900e-04' |     '0.056789%' |\n" +
    @@ -96,7 +96,7 @@ const DIAGRAM_5_A =
     
     const DIAGRAM_5_B =
       "┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\n" +
    -  "┃                │    {}   │  {:f}  │   {:e}  │   {:%}   ┃\n" +
    +  "┃                │    {<float>}   │  {<float>:f}  │   {<float>:e}  │   {<float>:%}   ┃\n" +
       "┠────────────────┼────────────────┼───────────────┼────────────────┼─────────────────┨\n" +
       "┃    0.000056789 │   '5.6789e-05' │    '0.000057' │ '5.678900e-05' │     '0.005679%' ┃\n" +
       "┃    0.00056789  │   '0.00056789' │    '0.000568' │ '5.678900e-04' │     '0.056789%' ┃\n" +
    @@ -110,7 +110,7 @@ const DIAGRAM_5_B =
     
     const DIAGRAM_6_A =
       "+----------------+----------------+---------------+----------------+-----------------+\n" +
    -  "|                |  {<float>:.2}  | {<float>:.2f} |  {<float>:.2e} |  {<float>:.2%}  |\n" +
    +  "|                |  {:.2}  | {:.2f} |  {:.2e} |  {:.2%}  |\n" +
       "+----------------+----------------+---------------+----------------+-----------------+\n" +
       "|    0.000056789 |   '5.7e-05'    |      '0.00'   |   '5.68e-05'   |       '0.01%'   |\n" +
       "|    0.00056789  |   '0.00057'    |      '0.00'   |   '5.68e-04'   |       '0.06%'   |\n" +
    @@ -124,7 +124,7 @@ const DIAGRAM_6_A =
     
     const DIAGRAM_6_B =
       "┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\n" +
    -  "┃                │  {:.2}  │ {:.2f} │  {:.2e} │  {:.2%}  ┃\n" +
    +  "┃                │  {<float>:.2}  │ {<float>:.2f} │  {<float>:.2e} │  {<float>:.2%}  ┃\n" +
       "┠────────────────┼────────────────┼───────────────┼────────────────┼─────────────────┨\n" +
       "┃    0.000056789 │   '5.7e-05'    │      '0.00'   │   '5.68e-05'   │       '0.01%'   ┃\n" +
       "┃    0.00056789  │   '0.00057'    │      '0.00'   │   '5.68e-04'   │       '0.06%'   ┃\n" +
    @@ -139,36 +139,34 @@ const DIAGRAM_6_B =
     const DIAGRAM_7_A =
       '+------------+----------+------------+----------+--------------+\n' +
       '|            | Iterable | Collection | Sequence | abc.Sequence |\n' +
    -  '+------------+----------+------------+----------+--------------+\n' +
    -  '| iter()     |   REQ    |    REQ     |   yes    |     yes      |\n' +
    -  '| contains() |   yes    |    yes     |   yes    |     yes      |\n' +
    -  '| len()      |          |    REQ     |   REQ    |     REQ      |\n' +
    -  '| getitem()  |          |            |   REQ    |     REQ      |\n' +
    -  '| reversed() |          |            |   yes    |     yes      |\n' +
    -  '| reverse()  |          |            |          |     yes      |\n' +
    -  '| index()    |          |            |          |     yes      |\n' +
    -  '| count()    |          |            |          |     yes      |\n' +
       '+------------+----------+------------+----------+--------------+\n';
     
     const DIAGRAM_7_B =
       '┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
       '┃            │ Iterable │ Collection │ Sequence │ abc.Sequence ┃\n' +
    -  '┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n';
    +  '┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n' +
    +  '┃ iter()     │    !     │     !      │    ✓     │      ✓       ┃\n' +
    +  '┃ contains() │    ✓     │     ✓      │    ✓     │      ✓       ┃\n' +
    +  '┃ len()      │          │     !      │    !     │      !       ┃\n' +
    +  '┃ getitem()  │          │            │    !     │      !       ┃\n' +
    +  '┃ reversed() │          │            │    ✓     │      ✓       ┃\n' +
    +  '┃ reverse()  │          │            │          │      ✓       ┃\n' +
    +  '┃ index()    │          │            │          │      ✓       ┃\n' +
    +  '┃ count()    │          │            │          │      ✓       ┃\n' +
    +  '┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
     
     
     // 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);
     
    -if (!isFontAvailable('Menlo')) {
    -  $(`code:contains(${DIAGRAM_1_B})`).html(DIAGRAM_1_A);
    -  $(`code:contains(${DIAGRAM_2_B})`).html(DIAGRAM_2_A);
    -  $(`code:contains(${DIAGRAM_3_B})`).html(DIAGRAM_3_A);
    -  $(`code:contains(${DIAGRAM_4_B})`).html(DIAGRAM_4_A);
    -  $(`code:contains(${DIAGRAM_5_B})`).html(DIAGRAM_5_A);
    -  $(`code:contains(${DIAGRAM_6_B})`).html(DIAGRAM_6_A);
    -  $(`code:contains(${DIAGRAM_7_B})`).html(DIAGRAM_7_A);
    -  // var htmlString = $('code:contains(ᴺᴱᵂ)').html().replace(/ᴺᴱᵂ/g, '');
    -  // $('code:contains(ᴺᴱᵂ)').html(htmlString);
    +if (isFontAvailable('Menlo')) {
    +  $(`code:contains(${DIAGRAM_1_A})`).html(DIAGRAM_1_B);
    +  $(`code:contains(${DIAGRAM_2_A})`).html(DIAGRAM_2_B);
    +  $(`code:contains(${DIAGRAM_3_A})`).html(DIAGRAM_3_B);
    +  $(`code:contains(${DIAGRAM_4_A})`).html(DIAGRAM_4_B);
    +  $(`code:contains(${DIAGRAM_5_A})`).html(DIAGRAM_5_B);
    +  $(`code:contains(${DIAGRAM_6_A})`).html(DIAGRAM_6_B);
    +  $(`code:contains(${DIAGRAM_7_A})`).html(DIAGRAM_7_B);
     }
     
     var isMobile = false;