staticdash 2025.21__tar.gz → 2025.22__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: staticdash
3
- Version: 2025.21
3
+ Version: 2025.22
4
4
  Summary: A lightweight static HTML dashboard generator with Plotly and pandas support.
5
5
  Author-email: Brian Day <brian.day1@gmail.com>
6
6
  License: CC0-1.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "staticdash"
7
- version = "2025.21"
7
+ version = "2025.22"
8
8
  description = "A lightweight static HTML dashboard generator with Plotly and pandas support."
9
9
  authors = [
10
10
  { name = "Brian Day", email = "brian.day1@gmail.com" }
@@ -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
- if hasattr(flowable, 'style') and hasattr(flowable, 'getPlainText'):
400
+ from reportlab.platypus import Paragraph
401
+ if isinstance(flowable, Paragraph):
400
402
  style_name = flowable.style.name
401
- if style_name.startswith("Heading"):
402
- level = int(style_name.replace("Heading", ""))
403
- text = flowable.getPlainText().strip()
404
- key = f"heading_{uuid.uuid4().hex}"
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=level-1, closed=False)
407
- self.notify('TOCEntry', (level, text, self.page))
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
- story.append(Paragraph(page.title, heading_style))
446
- story.append(Spacer(1, 12))
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
- style = styles['Heading{}'.format(min(lvl + 1, 4))]
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
- story.append(PageBreak())
521
- render_page(child, level=level + 1, sec_prefix=sec_prefix + [1])
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: staticdash
3
- Version: 2025.21
3
+ Version: 2025.22
4
4
  Summary: A lightweight static HTML dashboard generator with Plotly and pandas support.
5
5
  Author-email: Brian Day <brian.day1@gmail.com>
6
6
  License: CC0-1.0
File without changes
File without changes