diff --git a/parse.js b/parse.js index 8387b24..027356f 100755 --- a/parse.js +++ b/parse.js @@ -30,13 +30,29 @@ const TOC = '}\n' + '\n'; +const LRU_CACHE = + 'from functools import lru_cache\n' + + '\n' + + '@lru_cache(maxsize=None)\n' + + 'def fib(n):\n' + + ' return n if n < 2 else fib(n-2) + fib(n-1)\n'; + +const DATACLASS = + 'from dataclasses import make_dataclass\n' + + '<class> = make_dataclass(\'<class_name>\', <coll_of_attribute_names>)\n' + + '<class> = make_dataclass(\'<class_name>\', <coll_of_tuples>)\n' + + '<tuple> = (\'<attr_name>\', <type> [, <default_value>])'; + +const SHUTIL_COPY = + 'shutil.copy(from, to) # Copies the file. \'to\' can exist or be a dir.\n' + + 'shutil.copytree(from, to) # Copies the directory. \'to\' must not exist.\n'; + const OS_RENAME = 'os.rename(from, to) # Renames/moves the file or directory.\n' + 'os.replace(from, to) # Same, but overwrites \'to\' if it exists.\n'; -const SHUTIL_COPY = - 'shutil.copy(from, to) # Copies the file. \'to\' can exist or be a dir.\n' + - 'shutil.copytree(from, to) # Copies the directory. \'to\' must not exist.\n'; +const TYPE = + '<class> = type(\'<class_name>\', <parents_tuple>, <attributes_dict>)'; const EVAL = '>>> from ast import literal_eval\n' + @@ -47,21 +63,12 @@ const EVAL = '>>> literal_eval(\'abs(1)\')\n' + 'ValueError: malformed node or string\n'; -const LRU_CACHE = - 'from functools import lru_cache\n' + - '\n' + - '@lru_cache(maxsize=None)\n' + - 'def fib(n):\n' + - ' return n if n < 2 else fib(n-2) + fib(n-1)\n'; - -const TYPE = - '<class> = type(\'<class_name>\', <parents_tuple>, <attributes_dict>)'; - -const DATACLASS = - 'from dataclasses import make_dataclass\n' + - '<class> = make_dataclass(\'<class_name>\', <coll_of_attribute_names>)\n' + - '<class> = make_dataclass(\'<class_name>\', <coll_of_tuples>)\n' + - '<tuple> = (\'<attr_name>\', <type> [, <default_value>])'; +const PROGRESS_BAR = + '# $ pip3 install tqdm\n' + + '>>> from tqdm import tqdm\n' + + '>>> for el in tqdm([1, 2, 3], desc=\'Processing\'):\n' + + '... pass\n' + + 'Processing: 100%|██████████████████| 3/3 [00:00<00:00, 11516.49it/s]\n'; const PYINSTALLER = '$ pip3 install pyinstaller\n' + @@ -75,13 +82,6 @@ const INDEX = '
  • Ctrl+F / ⌘F is usually sufficient.
  • \n' + '
  • Searching \'#<title>\' will limit the search to the titles.
  • \n'; -const PROGRESS_BAR = - '# $ pip3 install tqdm\n' + - '>>> from tqdm import tqdm\n' + - '>>> for el in tqdm([1, 2, 3], desc=\'Processing\'):\n' + - '... pass\n' + - 'Processing: 100%|██████████████████| 3/3 [00:00<00:00, 11516.49it/s]\n'; - const DIAGRAM_1_A = '+------------------+------------+------------+------------+\n' + @@ -314,7 +314,7 @@ const DIAGRAM_14_B = "┃ sr.trans(…) │ y 2 │ y 2 │ y 2 ┃\n" + "┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; -const DIAGRAM_15_A = +const DIAGRAM_15_A = '+------------------------+---------------+------------+------------+--------------------------+'; const DIAGRAM_15_B = @@ -373,7 +373,7 @@ const DIAGRAM_17_B = "┃ │ │ b 2 2 │ ┃\n" + "┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n"; -const DIAGRAM_18_A = +const DIAGRAM_18_A = '| gb.agg(…) | x y | x y | x y | x |'; const DIAGRAM_18_B = @@ -504,15 +504,15 @@ function fixClasses() { } function fixHighlights() { - $(`code:contains(os.rename)`).html(OS_RENAME); - $(`code:contains(shutil.copy)`).html(SHUTIL_COPY); - $(`code:contains(ValueError: malformed node)`).html(EVAL); $(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE); - $(`code:contains(\'\', , )`).html(TYPE); $(`code:contains(make_dataclass(\'\')`).html(DATACLASS); + $(`code:contains(shutil.copy)`).html(SHUTIL_COPY); + $(`code:contains(os.rename)`).html(OS_RENAME); + $(`code:contains(\'\', , )`).html(TYPE); + $(`code:contains(ValueError: malformed node)`).html(EVAL); + $(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR); $(`code:contains(pip3 install pyinstaller)`).html(PYINSTALLER); $(`ul:contains(Only available in)`).html(INDEX); - $(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR); } function preventPageBreaks() {