@@ -30,13 +30,29 @@ const TOC =
30
30
'}\n' +
31
31
'</code></pre>\n' ;
32
32
33
+ const LRU_CACHE =
34
+ '<span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> lru_cache\n' +
35
+ '\n' +
36
+ '<span class="hljs-meta">@lru_cache(maxsize=None)</span>\n' +
37
+ '<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">fib</span><span class="hljs-params">(n)</span>:</span>\n' +
38
+ ' <span class="hljs-keyword">return</span> n <span class="hljs-keyword">if</span> n < <span class="hljs-number">2</span> <span class="hljs-keyword">else</span> fib(n-<span class="hljs-number">2</span>) + fib(n-<span class="hljs-number">1</span>)\n' ;
39
+
40
+ const DATACLASS =
41
+ '<span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> make_dataclass\n' +
42
+ '<class> = make_dataclass(<span class="hljs-string">\'<class_name>\'</span>, <coll_of_attribute_names>)\n' +
43
+ '<class> = make_dataclass(<span class="hljs-string">\'<class_name>\'</span>, <coll_of_tuples>)\n' +
44
+ '<tuple> = (<span class="hljs-string">\'<attr_name>\'</span>, <type> [, <default_value>])' ;
45
+
46
+ const SHUTIL_COPY =
47
+ 'shutil.copy(from, to) <span class="hljs-comment"># Copies the file. \'to\' can exist or be a dir.</span>\n' +
48
+ 'shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory. \'to\' must not exist.</span>\n' ;
49
+
33
50
const OS_RENAME =
34
51
'os.rename(from, to) <span class="hljs-comment"># Renames/moves the file or directory.</span>\n' +
35
52
'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n' ;
36
53
37
- const SHUTIL_COPY =
38
- 'shutil.copy(from, to) <span class="hljs-comment"># Copies the file. \'to\' can exist or be a dir.</span>\n' +
39
- 'shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory. \'to\' must not exist.</span>\n' ;
54
+ const TYPE =
55
+ '<class> = type(<span class="hljs-string">\'<class_name>\'</span>, <parents_tuple>, <attributes_dict>)' ;
40
56
41
57
const EVAL =
42
58
'<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> ast <span class="hljs-keyword">import</span> literal_eval\n' +
@@ -47,21 +63,12 @@ const EVAL =
47
63
'<span class="hljs-meta">>>> </span>literal_eval(<span class="hljs-string">\'abs(1)\'</span>)\n' +
48
64
'ValueError: malformed node or string\n' ;
49
65
50
- const LRU_CACHE =
51
- '<span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> lru_cache\n' +
52
- '\n' +
53
- '<span class="hljs-meta">@lru_cache(maxsize=None)</span>\n' +
54
- '<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">fib</span><span class="hljs-params">(n)</span>:</span>\n' +
55
- ' <span class="hljs-keyword">return</span> n <span class="hljs-keyword">if</span> n < <span class="hljs-number">2</span> <span class="hljs-keyword">else</span> fib(n-<span class="hljs-number">2</span>) + fib(n-<span class="hljs-number">1</span>)\n' ;
56
-
57
- const TYPE =
58
- '<class> = type(<span class="hljs-string">\'<class_name>\'</span>, <parents_tuple>, <attributes_dict>)' ;
59
-
60
- const DATACLASS =
61
- '<span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> make_dataclass\n' +
62
- '<class> = make_dataclass(<span class="hljs-string">\'<class_name>\'</span>, <coll_of_attribute_names>)\n' +
63
- '<class> = make_dataclass(<span class="hljs-string">\'<class_name>\'</span>, <coll_of_tuples>)\n' +
64
- '<tuple> = (<span class="hljs-string">\'<attr_name>\'</span>, <type> [, <default_value>])' ;
66
+ const PROGRESS_BAR =
67
+ '<span class="hljs-comment"># $ pip3 install tqdm</span>\n' +
68
+ '<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm\n' +
69
+ '<span class="hljs-meta">>>> </span><span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> tqdm([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], desc=<span class="hljs-string">\'Processing\'</span>):\n' +
70
+ '<span class="hljs-meta">... </span> <span class="hljs-keyword">pass</span>\n' +
71
+ 'Processing: 100%|██████████████████| 3/3 [00:00<00:00, 11516.49it/s]\n' ;
65
72
66
73
const PYINSTALLER =
67
74
'$ pip3 install pyinstaller\n' +
@@ -75,13 +82,6 @@ const INDEX =
75
82
'<li><strong>Ctrl+F / ⌘F is usually sufficient.</strong></li>\n' +
76
83
'<li><strong>Searching <code class="python hljs"><span class="hljs-string">\'#<title>\'</span></code> will limit the search to the titles.</strong></li>\n' ;
77
84
78
- const PROGRESS_BAR =
79
- '<span class="hljs-comment"># $ pip3 install tqdm</span>\n' +
80
- '<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm\n' +
81
- '<span class="hljs-meta">>>> </span><span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> tqdm([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], desc=<span class="hljs-string">\'Processing\'</span>):\n' +
82
- '<span class="hljs-meta">... </span> <span class="hljs-keyword">pass</span>\n' +
83
- 'Processing: 100%|██████████████████| 3/3 [00:00<00:00, 11516.49it/s]\n' ;
84
-
85
85
86
86
const DIAGRAM_1_A =
87
87
'+------------------+------------+------------+------------+\n' +
@@ -314,7 +314,7 @@ const DIAGRAM_14_B =
314
314
"┃ sr.trans(…) │ y 2 │ y 2 │ y 2 ┃\n" +
315
315
"┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n" ;
316
316
317
- const DIAGRAM_15_A =
317
+ const DIAGRAM_15_A =
318
318
'+------------------------+---------------+------------+------------+--------------------------+' ;
319
319
320
320
const DIAGRAM_15_B =
@@ -373,7 +373,7 @@ const DIAGRAM_17_B =
373
373
"┃ │ │ b 2 2 │ ┃\n" +
374
374
"┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛\n" ;
375
375
376
- const DIAGRAM_18_A =
376
+ const DIAGRAM_18_A =
377
377
'| gb.agg(…) | x y | x y | x y | x |' ;
378
378
379
379
const DIAGRAM_18_B =
@@ -504,15 +504,15 @@ function fixClasses() {
504
504
}
505
505
506
506
function fixHighlights ( ) {
507
- $ ( `code:contains(os.rename)` ) . html ( OS_RENAME ) ;
508
- $ ( `code:contains(shutil.copy)` ) . html ( SHUTIL_COPY ) ;
509
- $ ( `code:contains(ValueError: malformed node)` ) . html ( EVAL ) ;
510
507
$ ( `code:contains(@lru_cache(maxsize=None))` ) . html ( LRU_CACHE ) ;
511
- $ ( `code:contains(\'<class_name>\', <parents_tuple>, <attributes_dict>)` ) . html ( TYPE ) ;
512
508
$ ( `code:contains(make_dataclass(\'<class_name>\')` ) . html ( DATACLASS ) ;
509
+ $ ( `code:contains(shutil.copy)` ) . html ( SHUTIL_COPY ) ;
510
+ $ ( `code:contains(os.rename)` ) . html ( OS_RENAME ) ;
511
+ $ ( `code:contains(\'<class_name>\', <parents_tuple>, <attributes_dict>)` ) . html ( TYPE ) ;
512
+ $ ( `code:contains(ValueError: malformed node)` ) . html ( EVAL ) ;
513
+ $ ( `code:contains(pip3 install tqdm)` ) . html ( PROGRESS_BAR ) ;
513
514
$ ( `code:contains(pip3 install pyinstaller)` ) . html ( PYINSTALLER ) ;
514
515
$ ( `ul:contains(Only available in)` ) . html ( INDEX ) ;
515
- $ ( `code:contains(pip3 install tqdm)` ) . html ( PROGRESS_BAR ) ;
516
516
}
517
517
518
518
function preventPageBreaks ( ) {
0 commit comments