pyglove 0.4.5.dev202410170809__py3-none-any.whl → 0.4.5.dev202410190807__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyglove/core/__init__.py +1 -0
- pyglove/core/symbolic/base.py +10 -10
- pyglove/core/symbolic/base_test.py +47 -8
- pyglove/core/symbolic/diff.py +60 -66
- pyglove/core/symbolic/diff_test.py +33 -98
- pyglove/core/symbolic/ref.py +17 -3
- pyglove/core/symbolic/ref_test.py +9 -110
- pyglove/core/views/__init__.py +1 -0
- pyglove/core/views/base.py +45 -151
- pyglove/core/views/base_test.py +14 -49
- pyglove/core/views/html/base.py +19 -18
- pyglove/core/views/html/base_test.py +10 -8
- pyglove/core/views/html/tree_view.py +911 -561
- pyglove/core/views/html/tree_view_test.py +743 -164
- {pyglove-0.4.5.dev202410170809.dist-info → pyglove-0.4.5.dev202410190807.dist-info}/METADATA +1 -1
- {pyglove-0.4.5.dev202410170809.dist-info → pyglove-0.4.5.dev202410190807.dist-info}/RECORD +19 -19
- {pyglove-0.4.5.dev202410170809.dist-info → pyglove-0.4.5.dev202410190807.dist-info}/LICENSE +0 -0
- {pyglove-0.4.5.dev202410170809.dist-info → pyglove-0.4.5.dev202410190807.dist-info}/WHEEL +0 -0
- {pyglove-0.4.5.dev202410170809.dist-info → pyglove-0.4.5.dev202410190807.dist-info}/top_level.txt +0 -0
@@ -351,9 +351,9 @@ class DiffTest(unittest.TestCase):
|
|
351
351
|
def assert_style(html, expected):
|
352
352
|
expected = inspect.cleandoc(expected).strip()
|
353
353
|
actual = html.style_section.strip()
|
354
|
-
if
|
354
|
+
if expected not in actual:
|
355
355
|
print(actual)
|
356
|
-
self.
|
356
|
+
self.assertIn(expected, actual)
|
357
357
|
|
358
358
|
def assert_content(html, expected):
|
359
359
|
expected = inspect.cleandoc(expected).strip()
|
@@ -365,112 +365,47 @@ class DiffTest(unittest.TestCase):
|
|
365
365
|
assert_style(
|
366
366
|
pg_diff(1, 1).to_html(),
|
367
367
|
"""
|
368
|
-
<style>
|
369
|
-
/* Tooltip styles. */
|
370
|
-
span.tooltip {
|
371
|
-
visibility: hidden;
|
372
|
-
white-space: pre-wrap;
|
373
|
-
font-weight: normal;
|
374
|
-
background-color: #484848;
|
375
|
-
color: #fff;
|
376
|
-
padding: 10px;
|
377
|
-
border-radius: 6px;
|
378
|
-
position: absolute;
|
379
|
-
z-index: 1;
|
380
|
-
}
|
381
|
-
/* Summary styles. */
|
382
|
-
details.pyglove summary {
|
383
|
-
font-weight: bold;
|
384
|
-
margin: -0.5em -0.5em 0;
|
385
|
-
padding: 0.5em;
|
386
|
-
}
|
387
|
-
.summary_name {
|
388
|
-
display: inline;
|
389
|
-
padding: 0 5px;
|
390
|
-
}
|
391
|
-
.summary_title {
|
392
|
-
display: inline;
|
393
|
-
}
|
394
|
-
.summary_name + div.summary_title {
|
395
|
-
display: inline;
|
396
|
-
color: #aaa;
|
397
|
-
}
|
398
|
-
.summary_title:hover + span.tooltip {
|
399
|
-
visibility: visible;
|
400
|
-
}
|
401
|
-
/* Type-specific styles. */
|
402
|
-
.pyglove.str .summary_title {
|
403
|
-
color: darkred;
|
404
|
-
font-style: italic;
|
405
|
-
}
|
406
|
-
/* Value details styles. */
|
407
|
-
details.pyglove {
|
408
|
-
border: 1px solid #aaa;
|
409
|
-
border-radius: 4px;
|
410
|
-
padding: 0.5em 0.5em 0;
|
411
|
-
margin: 0.1em 0;
|
412
|
-
}
|
413
|
-
details.pyglove.special_value {
|
414
|
-
margin-bottom: 0.75em;
|
415
|
-
}
|
416
|
-
details.pyglove[open] {
|
417
|
-
padding: 0.5em 0.5em 0.5em;
|
418
|
-
}
|
419
|
-
.highlight {
|
420
|
-
background-color: Mark;
|
421
|
-
}
|
422
|
-
.lowlight {
|
423
|
-
opacity: 0.2;
|
424
|
-
}
|
425
368
|
/* Diff styles. */
|
426
|
-
.diff
|
369
|
+
.has-diff.summary-title::after {
|
427
370
|
content: ' (diff)';
|
428
371
|
color: #aaa;
|
429
372
|
}
|
430
|
-
.diff
|
373
|
+
.has-diff.summary-title {
|
431
374
|
background-color: yellow;
|
432
375
|
}
|
433
|
-
.diff
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
align-items: center;
|
376
|
+
.no-diff.summary-title::after {
|
377
|
+
content: ' (no diff)';
|
378
|
+
font-style: italic;
|
379
|
+
font-weight: normal;
|
380
|
+
color: #aaa;
|
439
381
|
}
|
440
|
-
.
|
441
|
-
opacity: 0.
|
382
|
+
.no-diff {
|
383
|
+
opacity: 0.6;
|
442
384
|
}
|
443
|
-
.
|
385
|
+
.no-diff.simple_value::after {
|
444
386
|
content: '(no diff)';
|
445
387
|
margin-left: 0.5em;
|
446
388
|
color: #aaa;
|
447
389
|
font-style: italic;
|
448
390
|
}
|
449
|
-
.
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
391
|
+
.diff-empty::before {
|
392
|
+
content: '(empty)';
|
393
|
+
font-style: italic;
|
394
|
+
margin-left: 0.5em;
|
395
|
+
color: #aaa;
|
454
396
|
}
|
455
|
-
.
|
397
|
+
.diff-left.summary-title::before, .diff-left.simple-value::before{
|
456
398
|
content: '🇱';
|
457
399
|
}
|
458
|
-
.
|
400
|
+
.diff-left {
|
459
401
|
background-color: #ffcccc;
|
460
402
|
}
|
461
|
-
.
|
462
|
-
background-color: #ffcccc;
|
463
|
-
}
|
464
|
-
.diff_value .diff_right::before {
|
403
|
+
.diff-right.summary-title::before, .diff-right.simple-value::before{
|
465
404
|
content: '🇷';
|
466
405
|
}
|
467
|
-
.
|
468
|
-
background-color: #ccffcc;
|
469
|
-
}
|
470
|
-
.diff_value .diff_right > details {
|
406
|
+
.diff-right {
|
471
407
|
background-color: #ccffcc;
|
472
408
|
}
|
473
|
-
</style>
|
474
409
|
"""
|
475
410
|
)
|
476
411
|
|
@@ -478,7 +413,7 @@ class DiffTest(unittest.TestCase):
|
|
478
413
|
assert_content(
|
479
414
|
pg_diff(1, 1).to_html(),
|
480
415
|
"""
|
481
|
-
<details open class="pyglove diff"><summary><div class="
|
416
|
+
<details open class="pyglove diff no-diff"><summary><div class="summary-title no-diff">Diff</div><span class="tooltip no-diff">No diff</span></summary><span class="diff-empty"></span></details>
|
482
417
|
"""
|
483
418
|
)
|
484
419
|
|
@@ -486,7 +421,7 @@ class DiffTest(unittest.TestCase):
|
|
486
421
|
assert_content(
|
487
422
|
pg_diff(1, 1, mode='both').to_html(),
|
488
423
|
"""
|
489
|
-
<
|
424
|
+
<span class="simple-value int no-diff">1</span>
|
490
425
|
"""
|
491
426
|
)
|
492
427
|
# No diff complex value (diff only)
|
@@ -499,7 +434,7 @@ class DiffTest(unittest.TestCase):
|
|
499
434
|
enable_key_tooltip=False,
|
500
435
|
),
|
501
436
|
"""
|
502
|
-
<details open class="pyglove diff"><summary><div class="
|
437
|
+
<details open class="pyglove diff no-diff"><summary><div class="summary-title no-diff">Diff</div></summary><span class="diff-empty"></span></details>
|
503
438
|
"""
|
504
439
|
)
|
505
440
|
# No diff complex value.
|
@@ -512,7 +447,7 @@ class DiffTest(unittest.TestCase):
|
|
512
447
|
enable_key_tooltip=False,
|
513
448
|
),
|
514
449
|
"""
|
515
|
-
<details open class="pyglove diff"><summary><div class="
|
450
|
+
<details open class="pyglove diff no-diff"><summary><div class="summary-title no-diff">Foo(...)</div></summary><div class="complex-value foo no-diff"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details><details class="pyglove list"><summary><div class="summary-name">y</div><div class="summary-title">List(...)</div></summary><div class="complex-value list"><table><tr><td><span class="object-key int">0</span></td><td><details class="pyglove foo"><summary><div class="summary-title">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details></div></details></td></tr></table></div></details></div></details>
|
516
451
|
"""
|
517
452
|
)
|
518
453
|
|
@@ -520,7 +455,7 @@ class DiffTest(unittest.TestCase):
|
|
520
455
|
assert_content(
|
521
456
|
pg_diff(1, 2).to_html(),
|
522
457
|
"""
|
523
|
-
<div class="
|
458
|
+
<div class="diff-value"><span class="simple-value int diff-left">1</span><span class="simple-value int diff-right">2</span></div>
|
524
459
|
"""
|
525
460
|
)
|
526
461
|
|
@@ -531,7 +466,7 @@ class DiffTest(unittest.TestCase):
|
|
531
466
|
enable_key_tooltip=False,
|
532
467
|
),
|
533
468
|
"""
|
534
|
-
<details open class="pyglove diff"><summary><div class="
|
469
|
+
<details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">List</div></summary><div class="complex-value list-class"><table><tr><td><span class="object-key int no-diff">0</span><span class="tooltip">[0]</span></td><td><span class="simple-value int no-diff">0</span></td></tr><tr><td><span class="object-key int">1</span><span class="tooltip">[1]</span></td><td><div class="diff-value"><span class="simple-value int diff-left">1</span><span class="simple-value int diff-right">2</span></div></td></tr><tr><td><span class="object-key int">2</span><span class="tooltip">[2]</span></td><td><div class="diff-value"><span class="simple-value int diff-left">2</span></div></td></tr></table></div></details>
|
535
470
|
"""
|
536
471
|
)
|
537
472
|
|
@@ -542,7 +477,7 @@ class DiffTest(unittest.TestCase):
|
|
542
477
|
enable_key_tooltip=False,
|
543
478
|
),
|
544
479
|
"""
|
545
|
-
<details open class="pyglove diff"><summary><div class="
|
480
|
+
<details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">dict</div></summary><div class="complex-value dict-class"><table><tr><td><span class="object-key str no-diff">x</span><span class="tooltip">x</span></td><td><span class="simple-value int no-diff">1</span></td></tr><tr><td><span class="object-key str">y</span><span class="tooltip">y</span></td><td><div class="diff-value"><span class="simple-value int diff-left">2</span><span class="simple-value int diff-right">3</span></div></td></tr><tr><td><span class="object-key str">z</span><span class="tooltip">z</span></td><td><div class="diff-value"><span class="simple-value int diff-left">3</span></div></td></tr><tr><td><span class="object-key str">w</span><span class="tooltip">w</span></td><td><div class="diff-value"><span class="simple-value int diff-right">4</span></div></td></tr></table></div></details>
|
546
481
|
"""
|
547
482
|
)
|
548
483
|
|
@@ -557,7 +492,7 @@ class DiffTest(unittest.TestCase):
|
|
557
492
|
enable_key_tooltip=False,
|
558
493
|
),
|
559
494
|
"""
|
560
|
-
<details open class="pyglove diff"><summary><div class="
|
495
|
+
<details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">Foo</div></summary><div class="complex-value foo-class"><table><tr><td><span class="object-key str">x</span><span class="tooltip">x</span></td><td><div class="diff-value"><span class="simple-value int diff-left">2</span><span class="simple-value int diff-right">1</span></div></td></tr><tr><td><span class="object-key str">y</span><span class="tooltip">y</span></td><td><details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">Foo</div></summary><div class="complex-value foo-class"><table><tr><td><span class="object-key str">x</span><span class="tooltip">y.x</span></td><td><div class="diff-value"><span class="simple-value int diff-left">3</span><span class="simple-value int diff-right">2</span></div></td></tr><tr><td><span class="object-key str no-diff">y</span><span class="tooltip">y.y</span></td><td><span class="simple-value int no-diff">3</span></td></tr></table></div></details></td></tr></table></div></details>
|
561
496
|
"""
|
562
497
|
)
|
563
498
|
|
@@ -572,7 +507,7 @@ class DiffTest(unittest.TestCase):
|
|
572
507
|
enable_key_tooltip=False,
|
573
508
|
),
|
574
509
|
"""
|
575
|
-
<div class="
|
510
|
+
<div class="diff-value"><details open class="pyglove foo diff-left"><summary><div class="summary-title diff-left">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details><details class="pyglove foo"><summary><div class="summary-name">y</div><div class="summary-title">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details></div></details></div></details><details open class="pyglove bar diff-right"><summary><div class="summary-title diff-right">Bar(...)</div></summary><div class="complex-value bar"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details><details class="pyglove foo"><summary><div class="summary-name">y</div><div class="summary-title">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details></div></details></div></details></div>
|
576
511
|
"""
|
577
512
|
)
|
578
513
|
|
@@ -587,7 +522,7 @@ class DiffTest(unittest.TestCase):
|
|
587
522
|
enable_key_tooltip=False,
|
588
523
|
),
|
589
524
|
"""
|
590
|
-
<details open class="pyglove diff"><summary><div class="
|
525
|
+
<details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">Foo | Bar</div></summary><div class="complex-value foo-class"><table><tr><td><span class="object-key str no-diff">x</span><span class="tooltip">x</span></td><td><span class="simple-value int no-diff">2</span></td></tr><tr><td><span class="object-key str">y</span><span class="tooltip">y</span></td><td><details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">Foo | Bar</div></summary><div class="complex-value foo-class"><table><tr><td><span class="object-key str no-diff">x</span><span class="tooltip">y.x</span></td><td><span class="simple-value int no-diff">3</span></td></tr><tr><td><span class="object-key str no-diff">y</span><span class="tooltip">y.y</span></td><td><span class="simple-value int no-diff">3</span></td></tr></table></div></details></td></tr></table></div></details>
|
591
526
|
"""
|
592
527
|
)
|
593
528
|
|
@@ -602,7 +537,7 @@ class DiffTest(unittest.TestCase):
|
|
602
537
|
enable_key_tooltip=False,
|
603
538
|
),
|
604
539
|
"""
|
605
|
-
<details open class="pyglove diff"><summary><div class="
|
540
|
+
<details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">Foo | Bar</div></summary><div class="complex-value foo-class"><table><tr><td><span class="object-key str">x</span><span class="tooltip">x</span></td><td><div class="diff-value"><span class="simple-value int diff-left">2</span><span class="simple-value int diff-right">3</span></div></td></tr><tr><td><span class="object-key str">y</span><span class="tooltip">y</span></td><td><details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">Foo | Bar</div></summary><div class="complex-value foo-class"><table><tr><td><span class="object-key str">x</span><span class="tooltip">y.x</span></td><td><div class="diff-value"><span class="simple-value int diff-left">3</span><span class="simple-value int diff-right">2</span></div></td></tr><tr><td><span class="object-key str no-diff">y</span><span class="tooltip">y.y</span></td><td><span class="simple-value int no-diff">3</span></td></tr></table></div></details></td></tr></table></div></details>
|
606
541
|
"""
|
607
542
|
)
|
608
543
|
|
@@ -624,7 +559,7 @@ class DiffTest(unittest.TestCase):
|
|
624
559
|
uncollapse=['[0]', '[1].right', '[3].left.y'],
|
625
560
|
),
|
626
561
|
"""
|
627
|
-
<details open class="pyglove diff"><summary><div class="
|
562
|
+
<details open class="pyglove diff has-diff"><summary><div class="summary-title has-diff">List</div></summary><div class="complex-value list-class"><table><tr><td><span class="object-key int no-diff">0</span><span class="tooltip">[0]</span></td><td><details open class="pyglove diff no-diff"><summary><div class="summary-title no-diff">Foo(...)</div></summary><div class="complex-value foo no-diff"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details></div></details></td></tr><tr><td><span class="object-key int">1</span><span class="tooltip">[1]</span></td><td><div class="diff-value"><details open class="pyglove foo diff-left"><summary><div class="summary-title diff-left">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details></div></details><details open class="pyglove bar diff-right"><summary><div class="summary-title diff-right">Bar(...)</div></summary><div class="complex-value bar"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details></div></details></div></td></tr><tr><td><span class="object-key int">2</span><span class="tooltip">[2]</span></td><td><div class="diff-value"><span class="simple-value none-type diff-left">None</span><details open class="pyglove dict diff-right"><summary><div class="summary-title diff-right">Dict(...)</div></summary><div class="complex-value dict"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details></div></details></div></td></tr><tr><td><span class="object-key int">3</span><span class="tooltip">[3]</span></td><td><div class="diff-value"><details open class="pyglove foo diff-left"><summary><div class="summary-title diff-left">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details><details open class="pyglove foo"><summary><div class="summary-name">y</div><div class="summary-title">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details></div></details></div></details><details open class="pyglove list diff-right"><summary><div class="summary-title diff-right">List(...)</div></summary><div class="complex-value list"><table><tr><td><span class="object-key int">0</span></td><td><span class="simple-value int">1</span></td></tr><tr><td><span class="object-key int">1</span></td><td><span class="simple-value int">2</span></td></tr></table></div></details></div></td></tr><tr><td><span class="object-key int">4</span><span class="tooltip">[4]</span></td><td><div class="diff-value"><details open class="pyglove list diff-left"><summary><div class="summary-title diff-left">List(...)</div></summary><div class="complex-value list"><table><tr><td><span class="object-key int">0</span></td><td><details class="pyglove dict"><summary><div class="summary-title">Dict(...)</div></summary><div class="complex-value dict"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details></div></details></td></tr></table></div></details><details open class="pyglove foo diff-right"><summary><div class="summary-title diff-right">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details><details class="pyglove foo"><summary><div class="summary-name">y</div><div class="summary-title">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">2</span></details><details open class="pyglove int"><summary><div class="summary-name">y</div><div class="summary-title">int</div></summary><span class="simple-value int">4</span></details></div></details></div></details></div></td></tr><tr><td><span class="object-key int">5</span><span class="tooltip">[5]</span></td><td><div class="diff-value"><details open class="pyglove list diff-right"><summary><div class="summary-title diff-right">List(...)</div></summary><div class="complex-value list"><table><tr><td><span class="object-key int">0</span></td><td><details class="pyglove dict"><summary><div class="summary-title">Dict(...)</div></summary><div class="complex-value dict"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">3</span></details></div></details></td></tr></table></div></details></div></td></tr></table></div></details>
|
628
563
|
"""
|
629
564
|
)
|
630
565
|
|
pyglove/core/symbolic/ref.py
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
"""Symbolic reference."""
|
15
15
|
|
16
|
+
import functools
|
16
17
|
import numbers
|
17
18
|
from typing import Any, Callable, List, Optional, Tuple
|
18
19
|
from pyglove.core import object_utils
|
@@ -184,10 +185,23 @@ class Ref(Object, base.Inferential):
|
|
184
185
|
**kwargs
|
185
186
|
)
|
186
187
|
|
187
|
-
|
188
|
-
|
188
|
+
@classmethod
|
189
|
+
@functools.cache
|
190
|
+
def _html_tree_view_config(cls) -> dict[str, Any]:
|
191
|
+
return html.HtmlTreeView.get_kwargs(
|
192
|
+
super()._html_tree_view_config(),
|
193
|
+
dict(
|
194
|
+
css_classes=['ref'],
|
195
|
+
)
|
196
|
+
)
|
197
|
+
|
198
|
+
@classmethod
|
199
|
+
@functools.cache
|
200
|
+
def _html_tree_view_css_styles(cls) -> List[str]:
|
201
|
+
return super()._html_tree_view_css_styles() + [
|
189
202
|
"""
|
190
|
-
|
203
|
+
/* Ref styles. */
|
204
|
+
.ref.summary-title::before {
|
191
205
|
content: 'ref: ';
|
192
206
|
color: #aaa;
|
193
207
|
}
|
@@ -160,9 +160,9 @@ class RefTest(unittest.TestCase):
|
|
160
160
|
def assert_style(html, expected):
|
161
161
|
expected = inspect.cleandoc(expected).strip()
|
162
162
|
actual = html.style_section.strip()
|
163
|
-
if
|
163
|
+
if expected not in actual:
|
164
164
|
print(actual)
|
165
|
-
self.
|
165
|
+
self.assertIn(expected, actual)
|
166
166
|
|
167
167
|
def assert_content(html, expected):
|
168
168
|
expected = inspect.cleandoc(expected).strip()
|
@@ -177,124 +177,23 @@ class RefTest(unittest.TestCase):
|
|
177
177
|
assert_style(
|
178
178
|
Foo(ref.Ref(Foo(1))).to_html(),
|
179
179
|
"""
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
visibility: hidden;
|
184
|
-
white-space: pre-wrap;
|
185
|
-
font-weight: normal;
|
186
|
-
background-color: #484848;
|
187
|
-
color: #fff;
|
188
|
-
padding: 10px;
|
189
|
-
border-radius: 6px;
|
190
|
-
position: absolute;
|
191
|
-
z-index: 1;
|
192
|
-
}
|
193
|
-
/* Summary styles. */
|
194
|
-
details.pyglove summary {
|
195
|
-
font-weight: bold;
|
196
|
-
margin: -0.5em -0.5em 0;
|
197
|
-
padding: 0.5em;
|
198
|
-
}
|
199
|
-
.summary_name {
|
200
|
-
display: inline;
|
201
|
-
padding: 0 5px;
|
202
|
-
}
|
203
|
-
.summary_title {
|
204
|
-
display: inline;
|
205
|
-
}
|
206
|
-
.summary_name + div.summary_title {
|
207
|
-
display: inline;
|
180
|
+
/* Ref styles. */
|
181
|
+
.ref.summary-title::before {
|
182
|
+
content: 'ref: ';
|
208
183
|
color: #aaa;
|
209
184
|
}
|
210
|
-
.summary_title:hover + span.tooltip {
|
211
|
-
visibility: visible;
|
212
|
-
}
|
213
|
-
/* Type-specific styles. */
|
214
|
-
.pyglove.str .summary_title {
|
215
|
-
color: darkred;
|
216
|
-
font-style: italic;
|
217
|
-
}
|
218
|
-
/* Object key styles. */
|
219
|
-
.object_key {
|
220
|
-
margin-right: 0.25em;
|
221
|
-
}
|
222
|
-
.object_key:hover + .tooltip {
|
223
|
-
visibility: visible;
|
224
|
-
background-color: darkblue;
|
225
|
-
}
|
226
|
-
.object_key.str {
|
227
|
-
color: gray;
|
228
|
-
border: 1px solid lightgray;
|
229
|
-
background-color: ButtonFace;
|
230
|
-
border-radius: 0.2em;
|
231
|
-
padding: 0.3em;
|
232
|
-
}
|
233
|
-
.object_key.int::before{
|
234
|
-
content: '[';
|
235
|
-
}
|
236
|
-
.object_key.int::after{
|
237
|
-
content: ']';
|
238
|
-
}
|
239
|
-
.object_key.int{
|
240
|
-
border: 0;
|
241
|
-
color: lightgray;
|
242
|
-
background-color: transparent;
|
243
|
-
border-radius: 0;
|
244
|
-
padding: 0;
|
245
|
-
}
|
246
|
-
/* Simple value styles. */
|
247
|
-
.simple_value {
|
248
|
-
color: blue;
|
249
|
-
display: inline-block;
|
250
|
-
white-space: pre-wrap;
|
251
|
-
padding: 0.2em;
|
252
|
-
margin-top: 0.15em;
|
253
|
-
}
|
254
|
-
.simple_value.str {
|
255
|
-
color: darkred;
|
256
|
-
font-style: italic;
|
257
|
-
}
|
258
|
-
.simple_value.int, .simple_value.float {
|
259
|
-
color: darkblue;
|
260
|
-
}
|
261
|
-
/* Complex value styles. */
|
262
|
-
span.empty_container::before {
|
263
|
-
content: '(empty)';
|
264
|
-
font-style: italic;
|
265
|
-
margin-left: 0.5em;
|
266
|
-
color: #aaa;
|
267
|
-
}
|
268
|
-
/* Value details styles. */
|
269
|
-
details.pyglove {
|
270
|
-
border: 1px solid #aaa;
|
271
|
-
border-radius: 4px;
|
272
|
-
padding: 0.5em 0.5em 0;
|
273
|
-
margin: 0.1em 0;
|
274
|
-
}
|
275
|
-
details.pyglove.special_value {
|
276
|
-
margin-bottom: 0.75em;
|
277
|
-
}
|
278
|
-
details.pyglove[open] {
|
279
|
-
padding: 0.5em 0.5em 0.5em;
|
280
|
-
}
|
281
|
-
.highlight {
|
282
|
-
background-color: Mark;
|
283
|
-
}
|
284
|
-
.lowlight {
|
285
|
-
opacity: 0.2;
|
286
|
-
}
|
287
|
-
</style>
|
288
185
|
"""
|
289
186
|
)
|
290
187
|
assert_content(
|
291
188
|
Foo(ref.Ref(Foo(1))).to_html(
|
292
|
-
|
189
|
+
extra_flags=dict(
|
190
|
+
use_inferred=False,
|
191
|
+
),
|
293
192
|
enable_summary_tooltip=False,
|
294
193
|
enable_key_tooltip=False,
|
295
194
|
),
|
296
195
|
"""
|
297
|
-
<details open class="pyglove foo"><summary><div class="
|
196
|
+
<details open class="pyglove foo"><summary><div class="summary-title">Foo(...)</div></summary><div class="complex-value foo"><details class="pyglove ref"><summary><div class="summary-name ref">x</div><div class="summary-title ref">Foo(...)</div></summary><div class="complex-value foo"><details open class="pyglove int"><summary><div class="summary-name">x</div><div class="summary-title">int</div></summary><span class="simple-value int">1</span></details></div></details></div></details>
|
298
197
|
"""
|
299
198
|
)
|
300
199
|
|