Skip to content

Commit f0a7132

Browse files
committed
tweak examples, fix tests
1 parent 887d2a3 commit f0a7132

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

docs/examples/example1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from devtools import debug
22

33
v1 = {
4-
'bar': ['apple', 'banana', 'carrot', 'grapefruit'],
54
'foo': {1: 'nested', 2: 'dict'},
5+
'bar': ['apple', 'banana', 'carrot', 'grapefruit'],
66
}
77

88
debug(v1, sum(range(5)))

docs/examples/example2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
from devtools import debug
12
import numpy as np
23

34
foo = {
45
'foo': np.array(range(20)),
5-
'bar': {'apple', 'banana', 'carrot', 'grapefruit'},
6-
'spam': [{'a': i, 'b': {j for j in range(1 + i * 2)}} for i in range(3)],
7-
'gen': (i for i in ['i', 'am', 'a', 'generator']),
6+
'bar': [{'a': i, 'b': {j for j in range(1 + i * 2)}} for i in range(3)],
7+
'spam': (i for i in ['i', 'am', 'a', 'generator']),
88
}
9-
bar = {1: 2, 11: 12}
109

1110
debug(foo)
1211

1312
# kwargs can be used as keys for what you are printing
1413
debug(
1514
long_string='long strings get wrapped ' * 10,
16-
new_line_sring='wraps also on newline\n' * 3,
15+
new_line_string='wraps also on newline\n' * 3,
1716
)
1817

18+
bar = {1: 2, 11: 12}
1919
# debug can also show the output of expressions
2020
debug(
2121
len(foo),

docs/gen_html.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212
)
1313
conv = Ansi2HTMLConverter()
1414

15-
16-
def gen_html(name):
17-
p = subprocess.run((sys.executable, str(EX_DIR / '{}.py'.format(name))), stdout=subprocess.PIPE, check=True)
15+
for f in EX_DIR.iterdir():
16+
if f.suffix != '.py' or f.name == 'sitecustomize.py':
17+
continue
18+
print('generating output for: {}'.format(f))
19+
p = subprocess.run((sys.executable, str(f)), stdout=subprocess.PIPE, check=True)
1820
html = conv.convert(p.stdout.decode(), full=False).strip('\r\n')
1921
html = '<pre class="ansi2html-content">\n{}\n</pre>'.format(html)
20-
(EX_DIR / '{}.html'.format(name)).write_text(html)
21-
22-
23-
gen_html('example1')
24-
gen_html('example2')
25-
gen_html('prettier')
22+
(EX_DIR / '{}.html'.format(f.stem)).write_text(html)

0 commit comments

Comments
 (0)