diff --git a/parse.js b/parse.js index 1f7da29..7d4d9d0 100755 --- a/parse.js +++ b/parse.js @@ -30,170 +30,6 @@ const TOC = '}\n' + '\n'; -const DIAGRAM_1_A = - '+---------+-------------+\n' + - '| Classes | Metaclasses |\n' + - '+---------+-------------|\n' + - '| MyClass > MyMetaClass |\n' + - '| | v |\n' + - '| object ---> type <+ |\n' + - '| | ^ +---+ |\n' + - '| str -------+ |\n' + - '+---------+-------------+\n'; - -const DIAGRAM_1_B = - '┏━━━━━━━━━┯━━━━━━━━━━━━━┓\n' + - '┃ Classes │ Metaclasses ┃\n' + - '┠─────────┼─────────────┨\n' + - '┃ MyClass → MyMetaClass ┃\n' + - '┃ │ ↓ ┃\n' + - '┃ object ───→ type ←╮ ┃\n' + - '┃ │ ↑ ╰───╯ ┃\n' + - '┃ str ───────╯ ┃\n' + - '┗━━━━━━━━━┷━━━━━━━━━━━━━┛\n'; - -const DIAGRAM_2_A = - '+---------+-------------+\n' + - '| Classes | Metaclasses |\n' + - '+---------+-------------|\n' + - '| MyClass | MyMetaClass |\n' + - '| v | v |\n' + - '| object <--- type |\n' + - '| ^ | |\n' + - '| str | |\n' + - '+---------+-------------+\n'; - -const DIAGRAM_2_B = - '┏━━━━━━━━━┯━━━━━━━━━━━━━┓\n' + - '┃ Classes │ Metaclasses ┃\n' + - '┠─────────┼─────────────┨\n' + - '┃ MyClass │ MyMetaClass ┃\n' + - '┃ ↓ │ ↓ ┃\n' + - '┃ object ←─── type ┃\n' + - '┃ ↑ │ ┃\n' + - '┃ str │ ┃\n' + - '┗━━━━━━━━━┷━━━━━━━━━━━━━┛\n'; - -const DIAGRAM_3_A = - '+------------------+----------+------------+----------+\n' + - '| | Sequence | Collection | Iterable |\n' + - '+------------------+----------+------------+----------+\n' + - '| list, range, str | yes | yes | yes |\n' + - '| dict, set | | yes | yes |\n' + - '| iter | | | yes |\n' + - '+------------------+----------+------------+----------+\n'; - -const DIAGRAM_3_B = - '┏━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┓\n' + - '┃ │ Sequence │ Collection │ Iterable ┃\n' + - '┠──────────────────┼──────────┼────────────┼──────────┨\n' + - '┃ list, range, str │ ✓ │ ✓ │ ✓ ┃\n' + - '┃ dict, set │ │ ✓ │ ✓ ┃\n' + - '┃ iter │ │ │ ✓ ┃\n' + - '┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┛\n'; - -const DIAGRAM_4_A = - '+--------------------+----------+----------+------+---------+--------+\n' + - '| | Integral | Rational | Real | Complex | Number |\n' + - '+--------------------+----------+----------+------+---------+--------+\n' + - '| int | yes | yes | yes | yes | yes |\n' + - '| fractions.Fraction | | yes | yes | yes | yes |\n' + - '| float | | | yes | yes | yes |\n' + - '| complex | | | | yes | yes |\n' + - '+--------------------+----------+----------+------+---------+--------+\n'; - -const DIAGRAM_4_B = - '┏━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━┯━━━━━━━━━┯━━━━━━━━┓\n' + - '┃ │ Integral │ Rational │ Real │ Complex │ Number ┃\n' + - '┠────────────────────┼──────────┼──────────┼──────┼─────────┼────────┨\n' + - '┃ int │ ✓ │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' + - '┃ fractions.Fraction │ │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' + - '┃ float │ │ │ ✓ │ ✓ │ ✓ ┃\n' + - '┃ complex │ │ │ │ ✓ │ ✓ ┃\n' + - '┗━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━┛\n'; - -const DIAGRAM_5_A = - "+----------------+----------------+---------------+----------------+-----------------+\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" + - "| 0.0056789 | '0.0056789' | '0.005679' | '5.678900e-03' | '0.567890%' |\n" + - "| 0.056789 | '0.056789' | '0.056789' | '5.678900e-02' | '5.678900%' |\n" + - "| 0.56789 | '0.56789' | '0.567890' | '5.678900e-01' | '56.789000%' |\n" + - "| 5.6789 | '5.6789' | '5.678900' | '5.678900e+00' | '567.890000%' |\n" + - "| 56.789 | '56.789' | '56.789000' | '5.678900e+01' | '5678.900000%' |\n" + - "| 567.89 | '567.89' | '567.890000' | '5.678900e+02' | '56789.000000%' |\n" + - "+----------------+----------------+---------------+----------------+-----------------+\n"; - -const DIAGRAM_5_B = - "┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\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" + - "┃ 0.0056789 │ '0.0056789' │ '0.005679' │ '5.678900e-03' │ '0.567890%' ┃\n" + - "┃ 0.056789 │ '0.056789' │ '0.056789' │ '5.678900e-02' │ '5.678900%' ┃\n" + - "┃ 0.56789 │ '0.56789' │ '0.567890' │ '5.678900e-01' │ '56.789000%' ┃\n" + - "┃ 5.6789 │ '5.6789' │ '5.678900' │ '5.678900e+00' │ '567.890000%' ┃\n" + - "┃ 56.789 │ '56.789' │ '56.789000' │ '5.678900e+01' │ '5678.900000%' ┃\n" + - "┃ 567.89 │ '567.89' │ '567.890000' │ '5.678900e+02' │ '56789.000000%' ┃\n" + - "┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┛\n"; - -const DIAGRAM_6_A = - "+----------------+----------------+---------------+----------------+-----------------+\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" + - "| 0.0056789 | '0.0057' | '0.01' | '5.68e-03' | '0.57%' |\n" + - "| 0.056789 | '0.057' | '0.06' | '5.68e-02' | '5.68%' |\n" + - "| 0.56789 | '0.57' | '0.57' | '5.68e-01' | '56.79%' |\n" + - "| 5.6789 | '5.7' | '5.68' | '5.68e+00' | '567.89%' |\n" + - "| 56.789 | '5.7e+01' | '56.79' | '5.68e+01' | '5678.90%' |\n" + - "| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |\n" + - "+----------------+----------------+---------------+----------------+-----------------+\n"; - -const DIAGRAM_6_B = - "┏━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\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" + - "┃ 0.0056789 │ '0.0057' │ '0.01' │ '5.68e-03' │ '0.57%' ┃\n" + - "┃ 0.056789 │ '0.057' │ '0.06' │ '5.68e-02' │ '5.68%' ┃\n" + - "┃ 0.56789 │ '0.57' │ '0.57' │ '5.68e-01' │ '56.79%' ┃\n" + - "┃ 5.6789 │ '5.7' │ '5.68' │ '5.68e+00' │ '567.89%' ┃\n" + - "┃ 56.789 │ '5.7e+01' │ '56.79' │ '5.68e+01' │ '5678.90%' ┃\n" + - "┃ 567.89 │ '5.7e+02' │ '567.89' │ '5.68e+02' │ '56789.00%' ┃\n" + - "┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┛\n"; - -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' + - '| index() | | | | yes |\n' + - '| count() | | | | yes |\n' + - '+------------+----------+------------+----------+--------------+\n'; - -const DIAGRAM_7_B = - '┏━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' + - '┃ │ Iterable │ Collection │ Sequence │ abc.Sequence ┃\n' + - '┠────────────┼──────────┼────────────┼──────────┼──────────────┨\n' + - '┃ iter() │ ! │ ! │ ✓ │ ✓ ┃\n' + - '┃ contains() │ ✓ │ ✓ │ ✓ │ ✓ ┃\n' + - '┃ len() │ │ ! │ ! │ ! ┃\n' + - '┃ getitem() │ │ │ ! │ ! ┃\n' + - '┃ reversed() │ │ │ ✓ │ ✓ ┃\n' + - '┃ index() │ │ │ │ ✓ ┃\n' + - '┃ count() │ │ │ │ ✓ ┃\n' + - '┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n'; - const OS_RENAME = 'os.rename(from, to) # Renames the file or directory.\n' + 'os.replace(from, to) # Same, but overwrites \'to\' if it exists.\n'; @@ -248,22 +84,10 @@ function initDom(html) { function getMd() { var readme = readFile('README.md'); - // readme = switchClassDiagrams(readme); const converter = new showdown.Converter(); return converter.makeHtml(readme); } -function switchClassDiagrams(readme) { - readme = readme.replace(DIAGRAM_1_A, DIAGRAM_1_B); - readme = readme.replace(DIAGRAM_2_A, DIAGRAM_2_B); - readme = readme.replace(DIAGRAM_3_A, DIAGRAM_3_B); - readme = readme.replace(DIAGRAM_4_A, DIAGRAM_4_B); - readme = readme.replace(DIAGRAM_5_A, DIAGRAM_5_B); - readme = readme.replace(DIAGRAM_6_A, DIAGRAM_6_B); - readme = readme.replace(DIAGRAM_7_A, DIAGRAM_7_B); - return readme -} - function modifyPage() { removeOrigToc(); addToc();