staticdash 2025.21__py3-none-any.whl → 2025.22__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.
- staticdash/dashboard.py +45 -14
- {staticdash-2025.21.dist-info → staticdash-2025.22.dist-info}/METADATA +1 -1
- staticdash-2025.22.dist-info/RECORD +8 -0
- staticdash-2025.21.dist-info/RECORD +0 -8
- {staticdash-2025.21.dist-info → staticdash-2025.22.dist-info}/WHEEL +0 -0
- {staticdash-2025.21.dist-info → staticdash-2025.22.dist-info}/top_level.txt +0 -0
staticdash/dashboard.py
CHANGED
|
@@ -56,7 +56,7 @@ class Page(AbstractPage):
|
|
|
56
56
|
self.page_width = page_width
|
|
57
57
|
self.marking = marking # Page-specific marking
|
|
58
58
|
self.children = []
|
|
59
|
-
self.add_header(title, level=1)
|
|
59
|
+
# self.add_header(title, level=1)
|
|
60
60
|
|
|
61
61
|
def add_subpage(self, page):
|
|
62
62
|
self.children.append(page)
|
|
@@ -395,16 +395,41 @@ class Dashboard:
|
|
|
395
395
|
self._outline_idx = 0
|
|
396
396
|
super().__init__(*args, **kwargs)
|
|
397
397
|
|
|
398
|
+
|
|
398
399
|
def afterFlowable(self, flowable):
|
|
399
|
-
|
|
400
|
+
from reportlab.platypus import Paragraph
|
|
401
|
+
if isinstance(flowable, Paragraph):
|
|
400
402
|
style_name = flowable.style.name
|
|
401
|
-
if style_name.startswith(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
403
|
+
if style_name.startswith('Heading'):
|
|
404
|
+
try:
|
|
405
|
+
level = int(style_name.replace("Heading", ""))
|
|
406
|
+
except ValueError:
|
|
407
|
+
return # Not a valid heading style
|
|
408
|
+
|
|
409
|
+
# Convert to outline level (0 = H1, 1 = H2, etc.)
|
|
410
|
+
outline_level = level - 1
|
|
411
|
+
|
|
412
|
+
# Clamp max to 2 for PDF outline safety
|
|
413
|
+
outline_level = max(0, min(outline_level, 2))
|
|
414
|
+
|
|
415
|
+
# Prevent skipping levels: ensure intermediates exist
|
|
416
|
+
# Track previous levels (add this as a class attribute if needed)
|
|
417
|
+
if not hasattr(self, "_last_outline_level"):
|
|
418
|
+
self._last_outline_level = -1
|
|
419
|
+
|
|
420
|
+
if outline_level > self._last_outline_level + 1:
|
|
421
|
+
outline_level = self._last_outline_level + 1 # prevent jump
|
|
422
|
+
|
|
423
|
+
self._last_outline_level = outline_level
|
|
424
|
+
|
|
425
|
+
text = flowable.getPlainText()
|
|
426
|
+
key = 'heading_%s' % self.seq.nextf('heading')
|
|
405
427
|
self.canv.bookmarkPage(key)
|
|
406
|
-
self.canv.addOutlineEntry(text, key, level=
|
|
407
|
-
|
|
428
|
+
self.canv.addOutlineEntry(text, key, level=outline_level, closed=False)
|
|
429
|
+
|
|
430
|
+
self.notify('TOCEntry', (outline_level, text, self.page))
|
|
431
|
+
|
|
432
|
+
|
|
408
433
|
|
|
409
434
|
def add_marking(canvas, doc, marking):
|
|
410
435
|
if marking:
|
|
@@ -442,8 +467,11 @@ class Dashboard:
|
|
|
442
467
|
|
|
443
468
|
def render_page(page, level=0, sec_prefix=[]):
|
|
444
469
|
heading_style = styles['Heading1'] if level == 0 else styles['Heading2']
|
|
445
|
-
|
|
446
|
-
|
|
470
|
+
|
|
471
|
+
# Only add the page.title as a real heading if it's a top-level page
|
|
472
|
+
if level == 0:
|
|
473
|
+
story.append(Paragraph(page.title, heading_style))
|
|
474
|
+
story.append(Spacer(1, 12))
|
|
447
475
|
|
|
448
476
|
for kind, content, _ in page.elements:
|
|
449
477
|
if kind == "text":
|
|
@@ -452,7 +480,8 @@ class Dashboard:
|
|
|
452
480
|
|
|
453
481
|
elif kind == "header":
|
|
454
482
|
text, lvl = content
|
|
455
|
-
|
|
483
|
+
safe_lvl = max(1, min(lvl + 1, 4)) # Clamp to Heading1–Heading4
|
|
484
|
+
style = styles[f'Heading{safe_lvl}']
|
|
456
485
|
story.append(Paragraph(text, style))
|
|
457
486
|
story.append(Spacer(1, 8))
|
|
458
487
|
|
|
@@ -516,15 +545,17 @@ class Dashboard:
|
|
|
516
545
|
elif kind == "minipage":
|
|
517
546
|
render_page(content, level=level + 1, sec_prefix=sec_prefix)
|
|
518
547
|
|
|
519
|
-
for child in getattr(page, "children", []):
|
|
520
|
-
|
|
521
|
-
|
|
548
|
+
# for child in getattr(page, "children", []):
|
|
549
|
+
# story.append(PageBreak())
|
|
550
|
+
# render_page(child, level=level + 2, sec_prefix=sec_prefix + [1])
|
|
522
551
|
|
|
523
552
|
story.append(PageBreak())
|
|
524
553
|
|
|
525
554
|
for page in self.pages:
|
|
526
555
|
render_page(page)
|
|
527
556
|
|
|
557
|
+
|
|
558
|
+
|
|
528
559
|
doc = MyDocTemplate(
|
|
529
560
|
output_path,
|
|
530
561
|
pagesize=page_size,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
staticdash/__init__.py,sha256=UN_-h8wFGfTPHYjnEb7N9CsxqXo-DQVo0cmREOtvRXE,244
|
|
2
|
+
staticdash/dashboard.py,sha256=YPpfUFHwMo0olakaviFdJFDRnMHbTeR5XtXz9yUsxGU,27120
|
|
3
|
+
staticdash/assets/css/style.css,sha256=RVqNdwBsaDv8izdOQjGmUZ4NROWF8uZhiq8DTNvUB1M,5962
|
|
4
|
+
staticdash/assets/js/script.js,sha256=7xBRlz_19wybbNVwAcfuKNXtDEojGB4EB0Yj4klsoTA,6998
|
|
5
|
+
staticdash-2025.22.dist-info/METADATA,sha256=KpCDLsvS8fGjFe_AZ6zZyjUl2LICSNb5lFCdTuQIGZk,1960
|
|
6
|
+
staticdash-2025.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
staticdash-2025.22.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
|
|
8
|
+
staticdash-2025.22.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
staticdash/__init__.py,sha256=UN_-h8wFGfTPHYjnEb7N9CsxqXo-DQVo0cmREOtvRXE,244
|
|
2
|
-
staticdash/dashboard.py,sha256=b6xx5-zdSCzbcaBTe52flSXrK_cdAo3vzGfIeR2MsNQ,25950
|
|
3
|
-
staticdash/assets/css/style.css,sha256=RVqNdwBsaDv8izdOQjGmUZ4NROWF8uZhiq8DTNvUB1M,5962
|
|
4
|
-
staticdash/assets/js/script.js,sha256=7xBRlz_19wybbNVwAcfuKNXtDEojGB4EB0Yj4klsoTA,6998
|
|
5
|
-
staticdash-2025.21.dist-info/METADATA,sha256=qKcshAi26kzpuRYjYpUppRTQW3F3ZsoKiKjHxIAbfWQ,1960
|
|
6
|
-
staticdash-2025.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
-
staticdash-2025.21.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
|
|
8
|
-
staticdash-2025.21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|