briefing 0.2.3__tar.gz → 0.3.0__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.
Files changed (184) hide show
  1. {briefing-0.2.3 → briefing-0.3.0}/.gitignore +1 -0
  2. {briefing-0.2.3 → briefing-0.3.0}/CHANGELOG.md +68 -1
  3. {briefing-0.2.3 → briefing-0.3.0}/PKG-INFO +7 -3
  4. {briefing-0.2.3 → briefing-0.3.0}/README.md +6 -2
  5. {briefing-0.2.3 → briefing-0.3.0}/pyproject.toml +1 -1
  6. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/__init__.py +97 -36
  7. briefing-0.3.0/src/briefing/_version.py +4 -0
  8. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/blocks/asset.py +5 -16
  9. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/blocks/banner.py +1 -1
  10. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/blocks/base.py +1 -1
  11. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/blocks/layout.py +45 -17
  12. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/blocks/text.py +11 -8
  13. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/_blocks.py +3 -3
  14. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/_render_profile.py +5 -3
  15. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/static/calendar.js +28 -14
  16. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/static/lab.js +5 -1
  17. briefing-0.3.0/src/briefing/renderers/css_scope.py +131 -0
  18. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/formatting.py +13 -3
  19. briefing-0.3.0/src/briefing/renderers/fragment.py +140 -0
  20. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/html.py +118 -22
  21. briefing-0.3.0/src/briefing/renderers/links.py +47 -0
  22. briefing-0.3.0/src/briefing/renderers/markup.py +116 -0
  23. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/plot.py +18 -10
  24. briefing-0.3.0/src/briefing/renderers/registry.py +170 -0
  25. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/table.py +5 -1
  26. briefing-0.3.0/src/briefing/static/embed-reset.css +33 -0
  27. briefing-0.3.0/src/briefing/static/embed.css +44 -0
  28. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/static/export.js +22 -19
  29. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/static/report.css +35 -0
  30. briefing-0.3.0/src/briefing/static/report.js +405 -0
  31. briefing-0.3.0/src/briefing/templates/fragment.html.j2 +8 -0
  32. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/templates/report.html.j2 +2 -0
  33. {briefing-0.2.3 → briefing-0.3.0}/tests/compat_reports.py +2 -1
  34. {briefing-0.2.3 → briefing-0.3.0}/tests/conftest.py +22 -0
  35. {briefing-0.2.3 → briefing-0.3.0}/tests/contract.py +72 -1
  36. briefing-0.3.0/tests/golden.py +97 -0
  37. briefing-0.3.0/tests/scenarios.py +206 -0
  38. briefing-0.3.0/tests/snapshots/golden/alert.html +43 -0
  39. briefing-0.3.0/tests/snapshots/golden/banner.html +47 -0
  40. briefing-0.3.0/tests/snapshots/golden/bignumber.html +45 -0
  41. briefing-0.3.0/tests/snapshots/golden/calendar-diverging.html +44 -0
  42. briefing-0.3.0/tests/snapshots/golden/calendar.html +44 -0
  43. briefing-0.3.0/tests/snapshots/golden/code.html +43 -0
  44. briefing-0.3.0/tests/snapshots/golden/datadive-df_all_null.html +44 -0
  45. briefing-0.3.0/tests/snapshots/golden/datadive-df_constant.html +44 -0
  46. briefing-0.3.0/tests/snapshots/golden/datadive-df_empty.html +44 -0
  47. briefing-0.3.0/tests/snapshots/golden/datadive-df_mixed.html +44 -0
  48. briefing-0.3.0/tests/snapshots/golden/datadive-df_single_row.html +44 -0
  49. briefing-0.3.0/tests/snapshots/golden/datadive-infinite.html +44 -0
  50. briefing-0.3.0/tests/snapshots/golden/dataprofile-df_all_null.html +43 -0
  51. briefing-0.3.0/tests/snapshots/golden/dataprofile-df_constant.html +43 -0
  52. briefing-0.3.0/tests/snapshots/golden/dataprofile-df_empty.html +43 -0
  53. briefing-0.3.0/tests/snapshots/golden/dataprofile-df_mixed.html +43 -0
  54. briefing-0.3.0/tests/snapshots/golden/dataprofile-df_single_row.html +43 -0
  55. briefing-0.3.0/tests/snapshots/golden/dataprofile-infinite.html +43 -0
  56. briefing-0.3.0/tests/snapshots/golden/datatable-df_all_null.html +43 -0
  57. briefing-0.3.0/tests/snapshots/golden/datatable-df_constant.html +43 -0
  58. briefing-0.3.0/tests/snapshots/golden/datatable-df_empty.html +43 -0
  59. briefing-0.3.0/tests/snapshots/golden/datatable-df_mixed.html +43 -0
  60. briefing-0.3.0/tests/snapshots/golden/datatable-df_single_row.html +43 -0
  61. briefing-0.3.0/tests/snapshots/golden/datatable-infinite.html +43 -0
  62. briefing-0.3.0/tests/snapshots/golden/everything.html +2272 -0
  63. briefing-0.3.0/tests/snapshots/golden/export-menu.html +46 -0
  64. briefing-0.3.0/tests/snapshots/golden/formula.html +43 -0
  65. briefing-0.3.0/tests/snapshots/golden/group-widths.html +46 -0
  66. briefing-0.3.0/tests/snapshots/golden/html.html +43 -0
  67. briefing-0.3.0/tests/snapshots/golden/links.html +55 -0
  68. briefing-0.3.0/tests/snapshots/golden/nested-layout.html +51 -0
  69. briefing-0.3.0/tests/snapshots/golden/pages.html +45 -0
  70. briefing-0.3.0/tests/snapshots/golden/plot-altair.html +43 -0
  71. briefing-0.3.0/tests/snapshots/golden/plot-matplotlib.html +43 -0
  72. briefing-0.3.0/tests/snapshots/golden/plot-plotly.html +43 -0
  73. briefing-0.3.0/tests/snapshots/golden/select-dropdown.html +45 -0
  74. briefing-0.3.0/tests/snapshots/golden/select-tabs.html +45 -0
  75. briefing-0.3.0/tests/snapshots/golden/table-df_all_null.html +64 -0
  76. briefing-0.3.0/tests/snapshots/golden/table-df_constant.html +252 -0
  77. briefing-0.3.0/tests/snapshots/golden/table-df_empty.html +50 -0
  78. briefing-0.3.0/tests/snapshots/golden/table-df_mixed.html +2259 -0
  79. briefing-0.3.0/tests/snapshots/golden/table-df_single_row.html +58 -0
  80. briefing-0.3.0/tests/snapshots/golden/table-infinite.html +72 -0
  81. briefing-0.3.0/tests/snapshots/golden/table-styler.html +309 -0
  82. briefing-0.3.0/tests/snapshots/golden/text-markdown-table.html +57 -0
  83. briefing-0.3.0/tests/snapshots/golden/text.html +45 -0
  84. briefing-0.3.0/tests/snapshots/golden/toggle.html +46 -0
  85. briefing-0.3.0/tests/snapshots/golden/two-matplotlib-plots.html +44 -0
  86. briefing-0.3.0/tests/snapshots/golden/two-table-stylers.html +576 -0
  87. briefing-0.3.0/tests/strategies.py +64 -0
  88. {briefing-0.2.3 → briefing-0.3.0}/tests/test_blocks/test_layout.py +20 -0
  89. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/conftest.py +16 -0
  90. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_export_image.py +2 -2
  91. briefing-0.3.0/tests/test_browser/test_export_menu.py +93 -0
  92. briefing-0.3.0/tests/test_browser/test_fragments.py +171 -0
  93. briefing-0.3.0/tests/test_browser/test_links.py +134 -0
  94. briefing-0.3.0/tests/test_browser/test_roots.py +157 -0
  95. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_text.py +19 -1
  96. {briefing-0.2.3 → briefing-0.3.0}/tests/test_compat.py +4 -1
  97. briefing-0.3.0/tests/test_contract.py +153 -0
  98. briefing-0.3.0/tests/test_deprecations.py +96 -0
  99. {briefing-0.2.3 → briefing-0.3.0}/tests/test_docs_gallery.py +12 -6
  100. briefing-0.3.0/tests/test_fragments.py +195 -0
  101. briefing-0.3.0/tests/test_golden.py +79 -0
  102. {briefing-0.2.3 → briefing-0.3.0}/tests/test_lab/test_profile.py +6 -0
  103. briefing-0.3.0/tests/test_properties.py +83 -0
  104. briefing-0.3.0/tests/test_renderers/test_css_scope.py +65 -0
  105. briefing-0.3.0/tests/test_renderers/test_export_menu.py +74 -0
  106. briefing-0.3.0/tests/test_renderers/test_formatting.py +17 -0
  107. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/test_html.py +53 -1
  108. briefing-0.3.0/tests/test_renderers/test_links.py +106 -0
  109. briefing-0.3.0/tests/test_renderers/test_markup.py +70 -0
  110. briefing-0.3.0/tests/test_renderers/test_registry.py +18 -0
  111. briefing-0.3.0/tests/test_static_scripts.py +53 -0
  112. briefing-0.3.0/tests/test_version.py +28 -0
  113. briefing-0.2.3/src/briefing/renderers/registry.py +0 -102
  114. briefing-0.2.3/src/briefing/static/report.js +0 -257
  115. briefing-0.2.3/tests/test_browser/test_export_menu.py +0 -55
  116. briefing-0.2.3/tests/test_contract.py +0 -331
  117. briefing-0.2.3/tests/test_deprecations.py +0 -94
  118. briefing-0.2.3/tests/test_renderers/test_export_menu.py +0 -46
  119. {briefing-0.2.3 → briefing-0.3.0}/LICENSE +0 -0
  120. {briefing-0.2.3 → briefing-0.3.0}/noxfile.py +0 -0
  121. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/__main__.py +0 -0
  122. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/_cli.py +0 -0
  123. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/_error.py +0 -0
  124. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/_frames.py +0 -0
  125. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/_preview.py +0 -0
  126. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/blocks/__init__.py +0 -0
  127. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/export/__init__.py +0 -0
  128. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/export/_image.py +0 -0
  129. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/export/_pdf.py +0 -0
  130. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/export/_render.py +0 -0
  131. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/__init__.py +0 -0
  132. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/_render_calendar.py +0 -0
  133. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/lab/_render_datadive.py +0 -0
  134. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/py.typed +0 -0
  135. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/__init__.py +0 -0
  136. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/formula.py +0 -0
  137. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/normalize.py +0 -0
  138. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/renderers/script_json.py +0 -0
  139. {briefing-0.2.3 → briefing-0.3.0}/src/briefing/static/export.css +0 -0
  140. {briefing-0.2.3 → briefing-0.3.0}/tests/__init__.py +0 -0
  141. {briefing-0.2.3 → briefing-0.3.0}/tests/banner_images.py +0 -0
  142. {briefing-0.2.3 → briefing-0.3.0}/tests/html_helpers.py +0 -0
  143. {briefing-0.2.3 → briefing-0.3.0}/tests/image_helpers.py +0 -0
  144. {briefing-0.2.3 → briefing-0.3.0}/tests/pdf_reader.py +0 -0
  145. {briefing-0.2.3 → briefing-0.3.0}/tests/snapshots/compat_0_1_2/blocks.body.html +0 -0
  146. {briefing-0.2.3 → briefing-0.3.0}/tests/snapshots/compat_0_1_2/pages.body.html +0 -0
  147. {briefing-0.2.3 → briefing-0.3.0}/tests/test_blocks/__init__.py +0 -0
  148. {briefing-0.2.3 → briefing-0.3.0}/tests/test_blocks/test_banner.py +0 -0
  149. {briefing-0.2.3 → briefing-0.3.0}/tests/test_blocks/test_base.py +0 -0
  150. {briefing-0.2.3 → briefing-0.3.0}/tests/test_blocks/test_text.py +0 -0
  151. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/__init__.py +0 -0
  152. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_banner.py +0 -0
  153. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_bignumber.py +0 -0
  154. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_calendar.py +0 -0
  155. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_cli_export.py +0 -0
  156. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_code.py +0 -0
  157. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_datadive.py +0 -0
  158. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_datatable.py +0 -0
  159. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_export_pdf.py +0 -0
  160. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_formula.py +0 -0
  161. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_layout.py +0 -0
  162. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_notebook.py +0 -0
  163. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_plots.py +0 -0
  164. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_print.py +0 -0
  165. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_spacing.py +0 -0
  166. {briefing-0.2.3 → briefing-0.3.0}/tests/test_browser/test_toggle_theme.py +0 -0
  167. {briefing-0.2.3 → briefing-0.3.0}/tests/test_cli.py +0 -0
  168. {briefing-0.2.3 → briefing-0.3.0}/tests/test_docstrings.py +0 -0
  169. {briefing-0.2.3 → briefing-0.3.0}/tests/test_export.py +0 -0
  170. {briefing-0.2.3 → briefing-0.3.0}/tests/test_frames.py +0 -0
  171. {briefing-0.2.3 → briefing-0.3.0}/tests/test_lab/__init__.py +0 -0
  172. {briefing-0.2.3 → briefing-0.3.0}/tests/test_lab/test_calendar.py +0 -0
  173. {briefing-0.2.3 → briefing-0.3.0}/tests/test_lab/test_datadive.py +0 -0
  174. {briefing-0.2.3 → briefing-0.3.0}/tests/test_lab/test_lab_boundary.py +0 -0
  175. {briefing-0.2.3 → briefing-0.3.0}/tests/test_no_viz_deps.py +0 -0
  176. {briefing-0.2.3 → briefing-0.3.0}/tests/test_pdf_reader.py +0 -0
  177. {briefing-0.2.3 → briefing-0.3.0}/tests/test_preview.py +0 -0
  178. {briefing-0.2.3 → briefing-0.3.0}/tests/test_readme.py +0 -0
  179. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/__init__.py +0 -0
  180. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/test_formula.py +0 -0
  181. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/test_normalize.py +0 -0
  182. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/test_plot.py +0 -0
  183. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/test_reproducible.py +0 -0
  184. {briefing-0.2.3 → briefing-0.3.0}/tests/test_renderers/test_table.py +0 -0
@@ -17,6 +17,7 @@ env/
17
17
  .coverage.*
18
18
  htmlcov/
19
19
  coverage.xml
20
+ .hypothesis/
20
21
 
21
22
  # Tooling caches
22
23
  .mypy_cache/
@@ -10,6 +10,71 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.3.0] - 2026-11-20
14
+
15
+ ### Added
16
+
17
+ - Every report says which version of briefing made it: a footer line, "Made with briefing
18
+ 0.3.0", and `<meta name="generator">` in the page head. `Briefing(footer="Analytics team")`
19
+ puts text before that line; the line itself can't be turned off (#23).
20
+ - Fragments to embed in other pages, like Plotly's `full_html=False` (#122).
21
+ `bf.stringify(chart, full_html=False)` (and `bf.save(..., full_html=False)`) gives one
22
+ `<div class="bf-embed">` that carries its theme, scopes every CSS rule to itself, starts
23
+ every id with its `embed_id` and initialises only its own scripts, so several fragments,
24
+ dark and light, share a page. `include_assets=False` with `bf.embed_assets(blocks)` sends
25
+ the CSS, scripts and chart runtimes once. A host's rules for plain elements and a changed
26
+ root font size don't reach the fragment. New guide: "Embed in other pages".
27
+ - Links to pages, tabs and headings (#24). A block's `name=` is now its link:
28
+ `report.html#detail` opens the page named `detail`, `#detail/by-region` a tab or block
29
+ named `by-region` in it, and `## Methodology {#methodology}` names a heading
30
+ (`#detail/methodology`). Opening a link selects its page and tab, opens any toggle around it
31
+ and scrolls to it, also offline. Choosing a tab puts its link in the address bar without a
32
+ history entry, so a reload keeps it open. Named headings show a copy-link icon on hover. A
33
+ name used twice in one page raises an error.
34
+ - `Formatting.to_css_vars(selector=":root")` takes the selector to put the theme on, so a
35
+ theme can apply to one element instead of the whole page (#123).
36
+
37
+ ### Changed
38
+
39
+ - The report's scripts now work inside the root they are given instead of on the whole page:
40
+ `window.briefing.init(root)` wires up tabs, toggles, tables, calendars and the export menu
41
+ in that root, once. A full report calls `briefing.init(document)`, so it behaves as before;
42
+ this lets two briefing outputs share a page later (#123).
43
+
44
+ ### Removed
45
+
46
+ - The names deprecated in 0.2 are gone, as their warnings announced: `bf.Blocks`,
47
+ `bf.BaseBlock`, `bf.save_report` and `bf.stringify_report` (use `bf.Briefing`, `bf.Block`,
48
+ `bf.save` and `bf.stringify`), and `bf.DataProfile` / `bf.DataDive` at the top level (use
49
+ `bf.lab.DataProfile` / `bf.lab.DataDive`). Each old name now raises an `AttributeError` that
50
+ says what to use instead. `Plot(scale=...)`, which had no effect, is removed too: size the
51
+ figure in its plotting library.
52
+
53
+ ### Fixed
54
+
55
+ - A `Text` or `HTML` block that leaves a comment, a tag or a `<script>`, `<style>` or
56
+ `<textarea>` open, such as a line starting with `<!-- draft note`, no longer hides
57
+ everything after it: the later blocks, the footer and the report's script, so tabs stopped
58
+ working. briefing closes what is left open at the end of the block. Found by the new
59
+ property tests (#45).
60
+ - `bf.lab.DataProfile` no longer fails with "cannot convert float NaN to integer" on a
61
+ numeric column whose values span more than the largest float, such as -1e308 and 1e308.
62
+ The new property tests found it (#45).
63
+
64
+ ## [0.2.4] - 2026-11-17
65
+
66
+ ### Fixed
67
+
68
+ - The export menu's "Save as PNG" keeps a 32 px margin of page background around the report,
69
+ so content no longer touches the edge of the image (#119).
70
+
71
+ ### Deprecated
72
+
73
+ - `bf.Briefing(..., export="pdf")` no longer adds a "Print" button: it only opened the
74
+ browser's print dialog, which Ctrl+P / ⌘P opens with the same print layout. It still runs,
75
+ with a `DeprecationWarning`; from 0.4.0 it raises an error. Use `export="png"` for the
76
+ "Save as PNG" button, and `bf.save_pdf` for a PDF file (#119).
77
+
13
78
  ## [0.2.3] - 2026-11-07
14
79
 
15
80
  ### Fixed
@@ -251,7 +316,9 @@ First public release.
251
316
  inherits its base's renderer.
252
317
  - Ships inline type hints (`py.typed`). Python 3.11+.
253
318
 
254
- [Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.2.3...HEAD
319
+ [Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.3.0...HEAD
320
+ [0.3.0]: https://github.com/jeanmidevacc/briefing/compare/v0.2.4...v0.3.0
321
+ [0.2.4]: https://github.com/jeanmidevacc/briefing/compare/v0.2.3...v0.2.4
255
322
  [0.2.3]: https://github.com/jeanmidevacc/briefing/compare/v0.2.2...v0.2.3
256
323
  [0.2.2]: https://github.com/jeanmidevacc/briefing/compare/v0.2.1...v0.2.2
257
324
  [0.2.1]: https://github.com/jeanmidevacc/briefing/compare/v0.2.0...v0.2.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: briefing
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Build beautiful self-contained HTML reports from Python analysis
5
5
  Project-URL: Homepage, https://github.com/jeanmidevacc/briefing
6
6
  Project-URL: Documentation, https://briefing.readthedocs.io
@@ -139,11 +139,15 @@ previews itself as the last expression of a cell.
139
139
  With `briefing[image]`, `bf.save_image(report, "q1.png", size="og")` renders a 1200×630 social
140
140
  card and `bf.save_pdf(report, "q1.pdf")` a PDF of every page, both offline in headless Chromium.
141
141
 
142
+ To put a chart, a table or a whole report into another page (a docs site, a notebook, a wiki),
143
+ `bf.stringify(report, full_html=False)` gives one self-contained `<div>`, like Plotly's
144
+ `to_html(full_html=False)`: it keeps its look and interactivity, and several share a page.
145
+
142
146
  ## Documentation
143
147
 
144
148
  **[briefing.readthedocs.io](https://briefing.readthedocs.io)** has a guide for each block family
145
- with live examples, themes, notebooks, printing and export, the `briefing.lab` blocks, recipes and
146
- the full API reference.
149
+ with live examples, themes, notebooks, printing and export, embedding in other pages, the
150
+ `briefing.lab` blocks, recipes and the full API reference.
147
151
 
148
152
  - [Changelog](CHANGELOG.md)
149
153
  - [`examples/notebook_walkthrough.ipynb`](examples/notebook_walkthrough.ipynb): build a report
@@ -63,11 +63,15 @@ previews itself as the last expression of a cell.
63
63
  With `briefing[image]`, `bf.save_image(report, "q1.png", size="og")` renders a 1200×630 social
64
64
  card and `bf.save_pdf(report, "q1.pdf")` a PDF of every page, both offline in headless Chromium.
65
65
 
66
+ To put a chart, a table or a whole report into another page (a docs site, a notebook, a wiki),
67
+ `bf.stringify(report, full_html=False)` gives one self-contained `<div>`, like Plotly's
68
+ `to_html(full_html=False)`: it keeps its look and interactivity, and several share a page.
69
+
66
70
  ## Documentation
67
71
 
68
72
  **[briefing.readthedocs.io](https://briefing.readthedocs.io)** has a guide for each block family
69
- with live examples, themes, notebooks, printing and export, the `briefing.lab` blocks, recipes and
70
- the full API reference.
73
+ with live examples, themes, notebooks, printing and export, embedding in other pages, the
74
+ `briefing.lab` blocks, recipes and the full API reference.
71
75
 
72
76
  - [Changelog](CHANGELOG.md)
73
77
  - [`examples/notebook_walkthrough.ipynb`](examples/notebook_walkthrough.ipynb): build a report
@@ -5,7 +5,7 @@ requires = ["hatchling>=1.21,<1.27"]
5
5
  build-backend = "hatchling.build"
6
6
 
7
7
  [tool.hatch.version]
8
- path = "src/briefing/__init__.py"
8
+ path = "src/briefing/_version.py"
9
9
 
10
10
  [tool.hatch.build.targets.wheel]
11
11
  packages = ["src/briefing"]
@@ -20,7 +20,6 @@ Quick start::
20
20
  bf.save(report, "analysis.html")
21
21
  """
22
22
  import typing as t
23
- import warnings
24
23
  import webbrowser
25
24
  from datetime import datetime
26
25
  from pathlib import Path
@@ -31,6 +30,7 @@ from pathlib import Path
31
30
  from briefing import lab
32
31
  from briefing._error import BriefingError
33
32
  from briefing._preview import Preview, preview
33
+ from briefing._version import __version__
34
34
 
35
35
  # ── blocks ────────────────────────────────────────────────────────────────────
36
36
  from briefing.blocks import (
@@ -63,11 +63,38 @@ from briefing.export import save_image, save_pdf
63
63
  from briefing.renderers.formatting import Formatting, TextAlignment, Width
64
64
 
65
65
  # ── renderer ──────────────────────────────────────────────────────────────────
66
+ from briefing.renderers.fragment import render_embed_assets, render_fragment
66
67
  from briefing.renderers.html import render_report
67
68
 
68
69
  # ── public API ────────────────────────────────────────────────────────────────
69
70
 
70
71
 
72
+ def _render(
73
+ blocks: Briefing | list[t.Any] | object,
74
+ name: str,
75
+ formatting: Formatting | None,
76
+ now: datetime | None,
77
+ full_html: bool,
78
+ include_assets: bool,
79
+ embed_id: str | None,
80
+ header: bool | None,
81
+ ) -> str:
82
+ """A full report, or with ``full_html=False`` a fragment (#122)."""
83
+ wrapped = Briefing.wrap(blocks)
84
+ if full_html:
85
+ options = {"include_assets": not include_assets, "embed_id": embed_id, "header": header}
86
+ given = [option for option, set_ in options.items() if set_]
87
+ if given:
88
+ raise BriefingError(
89
+ f"{', '.join(given)} only apply to a fragment: pass full_html=False as well, or leave them out."
90
+ )
91
+ return render_report(wrapped, name=name, formatting=formatting, now=now)
92
+ return render_fragment(
93
+ wrapped, name=name, formatting=formatting, now=now,
94
+ include_assets=include_assets, embed_id=embed_id, header=bool(header),
95
+ )
96
+
97
+
71
98
  def save(
72
99
  blocks: Briefing | list[t.Any] | object,
73
100
  path: str,
@@ -76,8 +103,12 @@ def save(
76
103
  name: str = "Report",
77
104
  formatting: Formatting | None = None,
78
105
  now: datetime | None = None,
106
+ full_html: bool = True,
107
+ include_assets: bool = True,
108
+ embed_id: str | None = None,
109
+ header: bool | None = None,
79
110
  ) -> None:
80
- """Save *blocks* as a self-contained HTML file at *path*.
111
+ """Save *blocks* as a self-contained HTML file at *path*, or as a fragment to embed.
81
112
 
82
113
  Args:
83
114
  blocks: A :class:`~briefing.Briefing` instance, a list of blocks, or a
@@ -88,13 +119,20 @@ def save(
88
119
  formatting: A :class:`~briefing.Formatting` instance controlling the theme.
89
120
  now: Pin the header timestamp for byte-reproducible output (see also the
90
121
  ``SOURCE_DATE_EPOCH`` environment variable).
122
+ full_html: ``False`` saves a fragment, one ``<div>`` to put into another page,
123
+ as :func:`stringify` describes.
124
+ include_assets: With ``full_html=False``: ``False`` leaves out the CSS and
125
+ scripts, for a page that loads :func:`embed_assets` once.
126
+ embed_id: With ``full_html=False``: the fragment's id, which starts every id
127
+ in it. Defaults to the name of its only block, else a hash of it.
128
+ header: With ``full_html=False``: ``True`` shows *name* and the date above it.
91
129
 
92
130
  Example::
93
131
 
94
132
  bf.save(report, "analysis.html", name="Q1 Analysis", open=True)
133
+ bf.save(chart, "revenue-embed.html", full_html=False)
95
134
  """
96
- wrapped = Briefing.wrap(blocks)
97
- html = render_report(wrapped, name=name, formatting=formatting, now=now)
135
+ html = _render(blocks, name, formatting, now, full_html, include_assets, embed_id, header)
98
136
  dest = Path(path)
99
137
  dest.write_text(html, encoding="utf-8")
100
138
  if open:
@@ -107,34 +145,72 @@ def stringify(
107
145
  name: str = "Report",
108
146
  formatting: Formatting | None = None,
109
147
  now: datetime | None = None,
148
+ full_html: bool = True,
149
+ include_assets: bool = True,
150
+ embed_id: str | None = None,
151
+ header: bool | None = None,
110
152
  ) -> str:
111
- """Render *blocks* to a self-contained HTML string.
153
+ """Render *blocks* to a self-contained HTML string, or to a fragment to embed.
112
154
 
113
155
  In a notebook you don't need this: a block or a ``Briefing`` displays itself
114
156
  as an isolated preview, and :func:`preview` adds a name or a theme.
115
157
 
116
158
  Pass *now* (or set ``SOURCE_DATE_EPOCH``) for byte-reproducible output.
117
159
 
160
+ With ``full_html=False`` the result is a fragment, like Plotly's
161
+ ``to_html(full_html=False)``: one ``<div class="bf-embed">`` to put into another
162
+ page (a docs site, a notebook, a Confluence HTML macro). It carries its theme,
163
+ keeps its CSS and scripts to itself, and works next to other fragments.
164
+
118
165
  Args:
119
166
  blocks: A :class:`Briefing`, a list of blocks, or a single block.
120
167
  name: Report title, shown in the browser tab and the header.
121
168
  formatting: A :class:`Formatting` instance controlling the theme.
122
169
  now: Pin the header timestamp for byte-reproducible output (see also
123
170
  the ``SOURCE_DATE_EPOCH`` environment variable).
171
+ full_html: ``False`` returns a fragment instead of a whole document.
172
+ include_assets: With ``full_html=False``: ``False`` leaves out the CSS and
173
+ scripts, for a page that loads :func:`embed_assets` once in its ``<head>``.
174
+ embed_id: With ``full_html=False``: the fragment's id, which starts every id
175
+ in it. Defaults to the name of its only block, else ``bf-e`` and 8 hex
176
+ digits of a hash of the fragment. Two fragments on a page need two ids.
177
+ header: With ``full_html=False``: ``True`` shows *name* and the date above it.
124
178
 
125
179
  Returns:
126
- The complete HTML document.
180
+ The complete HTML document, or the fragment.
127
181
 
128
182
  Example::
129
183
 
130
184
  html = bf.stringify(bf.Text("# Hello"), name="Greeting")
131
185
  email_body = html # or write it anywhere a string goes
186
+ fragment = bf.stringify(bf.Plot(fig, name="revenue"), full_html=False) # <div id="revenue" …>
132
187
  """
133
- wrapped = Briefing.wrap(blocks)
134
- return render_report(wrapped, name=name, formatting=formatting, now=now)
188
+ return _render(blocks, name, formatting, now, full_html, include_assets, embed_id, header)
189
+
135
190
 
191
+ def embed_assets(blocks: Briefing | list[t.Any] | object) -> str:
192
+ """The CSS and scripts of fragments, once, for the ``<head>`` of a page that holds several.
193
+
194
+ Like Plotly's ``get_plotlyjs()``: put it in the page once, then render each
195
+ fragment with ``include_assets=False``. It holds briefing's CSS scoped to
196
+ fragments, ``report.js``, the scripts of lab blocks and the chart runtimes
197
+ (Plotly, Vega) that *blocks* need.
198
+
199
+ Args:
200
+ blocks: The blocks the page's fragments hold: a block, a :class:`Briefing`,
201
+ or a list of either.
202
+
203
+ Returns:
204
+ ``<style>`` and ``<script>`` tags.
205
+
206
+ Example::
207
+
208
+ head = bf.embed_assets([chart, table])
209
+ parts = [bf.stringify(b, full_html=False, include_assets=False) for b in (chart, table)]
210
+ """
211
+ items = blocks if isinstance(blocks, list) else [blocks]
212
+ return render_embed_assets(Briefing.wrap(item) for item in items)
136
213
 
137
- __version__ = "0.2.3"
138
214
 
139
215
  __all__: list[str] = [
140
216
  # error
@@ -170,6 +246,7 @@ __all__: list[str] = [
170
246
  "Width",
171
247
  # api
172
248
  "Preview",
249
+ "embed_assets",
173
250
  "preview",
174
251
  "save",
175
252
  "save_image",
@@ -180,36 +257,20 @@ __all__: list[str] = [
180
257
  ]
181
258
 
182
259
 
183
- # ── deprecated aliases (removed after 0.2) ───────────────────────────────────
260
+ # ── names removed in 0.3.0, deprecated since 0.2 ──────────────────────────────
184
261
 
185
- #: old name -> (new name, object)
186
- _RENAMED: dict[str, tuple[str, object]] = {
187
- "Blocks": ("Briefing", Briefing),
188
- "BaseBlock": ("Block", Block),
189
- "save_report": ("save", save),
190
- "stringify_report": ("stringify", stringify),
262
+ #: old name -> what to use instead
263
+ _REMOVED: dict[str, str] = {
264
+ "Blocks": "Briefing",
265
+ "BaseBlock": "Block",
266
+ "save_report": "save",
267
+ "stringify_report": "stringify",
268
+ "DataProfile": "lab.DataProfile",
269
+ "DataDive": "lab.DataDive",
191
270
  }
192
271
 
193
- #: names that moved into the briefing.lab subpackage
194
- _MOVED_TO_LAB: frozenset[str] = frozenset({"DataProfile", "DataDive"})
195
-
196
272
 
197
273
  def __getattr__(name: str) -> t.Any:
198
- if name in _RENAMED:
199
- new, obj = _RENAMED[name]
200
- warnings.warn(
201
- f"briefing.{name} is deprecated and will be removed after 0.2 — "
202
- f"use briefing.{new}.",
203
- DeprecationWarning,
204
- stacklevel=2,
205
- )
206
- return obj
207
- if name in _MOVED_TO_LAB:
208
- warnings.warn(
209
- f"briefing.{name} moved to briefing.lab.{name} (pip install briefing[lab]) "
210
- f"and will be removed after 0.2 — use briefing.lab.{name}.",
211
- DeprecationWarning,
212
- stacklevel=2,
213
- )
214
- return getattr(lab, name)
274
+ if name in _REMOVED:
275
+ raise AttributeError(f"briefing.{name} was removed in 0.3.0: use briefing.{_REMOVED[name]}.")
215
276
  raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,4 @@
1
+ """The package version, kept apart so the renderers can import it without a cycle."""
2
+ from __future__ import annotations
3
+
4
+ __version__ = "0.3.0"
@@ -33,10 +33,9 @@ class Plot(Block):
33
33
  Args:
34
34
  figure: A Plotly, Altair, Matplotlib (or Seaborn / Plotnine) or Bokeh figure.
35
35
  caption: Optional caption shown below the chart.
36
- responsive: Let the chart fill the width of its container.
37
- scale: Deprecated, has no effect, and is removed after 0.2. Size the figure
38
- in its plotting library instead, e.g. Matplotlib's ``figsize=(w, h)``.
39
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
36
+ responsive: Let the chart fill the width of its container. Size the figure in
37
+ its plotting library, e.g. Matplotlib's ``figsize=(w, h)``.
38
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
40
39
  label: Tab or dropdown label when the block is inside a ``Select``.
41
40
 
42
41
  Example::
@@ -50,23 +49,13 @@ class Plot(Block):
50
49
  figure: t.Any,
51
50
  caption: str | None = None,
52
51
  responsive: bool = True,
53
- scale: float | None = None,
54
52
  name: BlockId | None = None,
55
53
  label: str | None = None,
56
54
  ) -> None:
57
- if scale is not None:
58
- warnings.warn(
59
- "Plot(scale=...) is deprecated, has no effect, and will be removed after 0.2. "
60
- "Size the figure in its plotting library instead, e.g. Matplotlib's figsize=(w, h); "
61
- "responsive=True already makes it fill its container.",
62
- DeprecationWarning,
63
- stacklevel=2,
64
- )
65
55
  super().__init__(name=name, label=label)
66
56
  self.figure = figure
67
57
  self.caption = _truncate(caption, _MAX_CAPTION_LEN) if caption else caption
68
58
  self.responsive = responsive
69
- self.scale = 1.0 if scale is None else scale
70
59
 
71
60
 
72
61
  class Table(Block):
@@ -79,7 +68,7 @@ class Table(Block):
79
68
  Args:
80
69
  data: A dataframe (as for :class:`DataTable`) or a pandas ``Styler``, kept as-is.
81
70
  caption: Optional caption below the table.
82
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
71
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
83
72
  label: Tab or dropdown label when the block is inside a ``Select``.
84
73
 
85
74
  Example::
@@ -116,7 +105,7 @@ class DataTable(Block):
116
105
  interchange protocol, or a dict of columns.
117
106
  caption: Optional caption below the table.
118
107
  max_rows: Rows beyond this are dropped with a warning.
119
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
108
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
120
109
  label: Tab or dropdown label when the block is inside a ``Select``.
121
110
 
122
111
  Example::
@@ -57,7 +57,7 @@ class Banner(Block):
57
57
  height: CSS height such as ``"16rem"`` (default) or a number of pixels.
58
58
  focus: ``(x, y)`` in percent: the point of the image kept in view when it is cropped.
59
59
  alt: A description of the image; by default it is decorative.
60
- name: Stable block id.
60
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
61
61
  label: Tab or dropdown label when the block is inside a ``Select``.
62
62
 
63
63
  Example::
@@ -23,7 +23,7 @@ class Block:
23
23
  e.g. as a tab title inside a Select).
24
24
 
25
25
  Args:
26
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
26
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
27
27
  label: Tab or dropdown label when the block is inside a ``Select``.
28
28
 
29
29
  Example::
@@ -9,7 +9,7 @@ from collections.abc import Sequence
9
9
  from enum import StrEnum
10
10
 
11
11
  from briefing._error import BriefingError
12
- from briefing.blocks.base import BlockId, BlockOrPrimitive, ContainerBlock
12
+ from briefing.blocks.base import _MAX_CAPTION_LEN, BlockId, BlockOrPrimitive, ContainerBlock, _truncate
13
13
 
14
14
  # ── enums ─────────────────────────────────────────────────────────────────────
15
15
 
@@ -60,7 +60,7 @@ class Group(ContainerBlock):
60
60
  columns: Number of grid columns, a whole number of 1 or more.
61
61
  widths: Relative column widths, positive numbers, one per column (e.g. ``[2, 1]``).
62
62
  valign: Vertical alignment of the cells: ``"top"``, ``"center"`` or ``"bottom"``.
63
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
63
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
64
64
  label: Tab or dropdown label when the block is inside a ``Select``.
65
65
 
66
66
  Example::
@@ -107,7 +107,7 @@ class Select(ContainerBlock):
107
107
  *arg_blocks: The panels; each child's ``label`` is its tab or option title.
108
108
  blocks: The panels as a list, instead of positional arguments.
109
109
  type: ``"tabs"`` (default) or ``"dropdown"`` (or a :class:`SelectType`).
110
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
110
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
111
111
  label: Tab or dropdown label when the block is inside a ``Select``.
112
112
 
113
113
  Example::
@@ -144,7 +144,7 @@ class Toggle(ContainerBlock):
144
144
  Args:
145
145
  *arg_blocks: The hidden content; several blocks are wrapped in a ``Group``.
146
146
  blocks: The content as a list, instead of positional arguments.
147
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
147
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
148
148
  label: The clickable title (``"Details"`` when omitted).
149
149
 
150
150
  Example::
@@ -204,6 +204,14 @@ class Page(ContainerBlock):
204
204
  self.title = title
205
205
 
206
206
 
207
+ EXPORT_PDF_DEPRECATION = (
208
+ "Briefing(export='pdf') is deprecated and no longer adds a 'Print' button: it only opened the browser's "
209
+ "print dialog, which Ctrl+P (Cmd+P on a Mac) opens with the same print layout. For a PDF file, use "
210
+ "bf.save_pdf(report, 'report.pdf'). From 0.4.0, export='pdf' raises an error; pass export='png' for the "
211
+ "'Save as PNG' button, or leave export out."
212
+ )
213
+
214
+
207
215
  class Briefing(ContainerBlock):
208
216
  """Root document container.
209
217
 
@@ -213,19 +221,26 @@ class Briefing(ContainerBlock):
213
221
  *arg_blocks: The report's blocks, in order.
214
222
  blocks: The blocks as a list, instead of positional arguments.
215
223
  export: Opt-in export menu in the report header: ``"png"`` adds "Save as
216
- PNG" (the open page, drawn in the reader's browser at 2×) and ``"pdf"``
217
- adds "Print" (the print dialog, which can save a PDF). Reports without
218
- it contain no export code. "Save as PNG" is best effort: charts
219
- drawn in iframes (Bokeh) and WebGL Plotly traces come out blank, and
220
- fonts are whatever the reader's machine has. For exact, reproducible
221
- files use :func:`~briefing.save_image` / :func:`~briefing.save_pdf`.
224
+ PNG" (the open page with a margin around it, drawn in the reader's
225
+ browser at 2×). Reports without it contain no export code. "Save as
226
+ PNG" is best effort: charts drawn in iframes (Bokeh) and WebGL Plotly
227
+ traces come out blank, and fonts are whatever the reader's machine
228
+ has. For exact, reproducible files use :func:`~briefing.save_image` /
229
+ :func:`~briefing.save_pdf`. To print, use the browser's own print
230
+ (Ctrl+P or ⌘P): it gets the same print layout. *Deprecated:*
231
+ ``"pdf"`` (the "Print" button) raises a ``DeprecationWarning`` and
232
+ adds nothing; it will be rejected from 0.4.0.
233
+ footer: Text to put before the report's footer line, such as a team name. Every
234
+ report ends with "Made with briefing" and its version; that line can't be
235
+ turned off.
222
236
 
223
237
  Example::
224
238
 
225
239
  report = bf.Briefing(
226
240
  bf.Text("# My report"),
227
241
  bf.Plot(fig),
228
- export=("png", "pdf"),
242
+ export="png",
243
+ footer="Analytics team", # "Analytics team · Made with briefing 0.3.0"
229
244
  )
230
245
  bf.save(report, "report.html")
231
246
  """
@@ -233,30 +248,43 @@ class Briefing(ContainerBlock):
233
248
  min_blocks: t.ClassVar[int] = 1
234
249
 
235
250
  #: The actions export= accepts, in menu order.
236
- EXPORTS: t.ClassVar[tuple[str, ...]] = ("png", "pdf")
251
+ EXPORTS: t.ClassVar[tuple[str, ...]] = ("png",)
252
+ #: Accepted with a DeprecationWarning, and dropped: they add no button.
253
+ DEPRECATED_EXPORTS: t.ClassVar[dict[str, str]] = {"pdf": EXPORT_PDF_DEPRECATION}
237
254
  export: tuple[str, ...]
255
+ footer: str | None
238
256
 
239
257
  def __init__(
240
258
  self,
241
259
  *arg_blocks: BlockOrPrimitive,
242
260
  blocks: Sequence[BlockOrPrimitive] | None = None,
243
261
  export: str | Sequence[str] = (),
262
+ footer: str | None = None,
244
263
  ) -> None:
245
264
  # Unwrap if a single Briefing is passed directly (avoids double-wrapping).
246
265
  if len(arg_blocks) == 1 and isinstance(arg_blocks[0], Briefing):
247
266
  export = export or arg_blocks[0].export
267
+ footer = footer or arg_blocks[0].footer
248
268
  arg_blocks = tuple(arg_blocks[0].blocks)
269
+ if footer is not None and not isinstance(footer, str):
270
+ raise BriefingError(f"Briefing 'footer' must be text such as 'Analytics team', not {footer!r}.")
249
271
  super().__init__(*arg_blocks, blocks=blocks)
250
272
  self.export = self._check_export(export)
273
+ self.footer = _truncate(footer, _MAX_CAPTION_LEN) if footer else None
251
274
 
252
275
  @classmethod
253
276
  def _check_export(cls, export: object) -> tuple[str, ...]:
254
277
  actions = (export,) if isinstance(export, str) else export
255
- if not isinstance(actions, Sequence) or any(a not in cls.EXPORTS for a in actions):
256
- raise BriefingError(
257
- f"export accepts 'png' and/or 'pdf', for example export=('png', 'pdf'); got {export!r}."
258
- )
259
- return tuple(dict.fromkeys(t.cast("Sequence[str]", actions)))
278
+ if not isinstance(actions, Sequence) or any(
279
+ a not in cls.EXPORTS and a not in cls.DEPRECATED_EXPORTS for a in actions
280
+ ):
281
+ raise BriefingError(f"export accepts 'png', for example export='png'; got {export!r}.")
282
+ unique = tuple(dict.fromkeys(t.cast("Sequence[str]", actions)))
283
+ for action in unique:
284
+ if action in cls.DEPRECATED_EXPORTS:
285
+ # stacklevel 3: _check_export <- __init__ <- the caller's bf.Briefing(...)
286
+ warnings.warn(cls.DEPRECATED_EXPORTS[action], DeprecationWarning, stacklevel=3)
287
+ return tuple(a for a in unique if a in cls.EXPORTS)
260
288
 
261
289
  @classmethod
262
290
  def wrap(
@@ -31,12 +31,13 @@ class EmbeddedTextBlock(Block):
31
31
  class Text(EmbeddedTextBlock):
32
32
  """Markdown text block (CommonMark plus pipe tables).
33
33
 
34
- Raw HTML inside the markdown is passed through as-is, like :class:`HTML`.
34
+ Raw HTML inside the markdown is passed through as-is, like :class:`HTML`
35
+ (and, like it, closed at the end of the block if left open).
35
36
 
36
37
  Args:
37
38
  text: Markdown; common leading indentation is removed.
38
39
  file: Path to a ``.md`` file to read instead of ``text``.
39
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
40
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
40
41
  label: Tab or dropdown label when the block is inside a ``Select``.
41
42
 
42
43
  Example::
@@ -79,11 +80,13 @@ class HTML(EmbeddedTextBlock):
79
80
 
80
81
  The content is injected into the report verbatim, inside a plain
81
82
  ``<div>`` — it is **not** sandboxed or sanitised. Only pass HTML you
82
- trust; any ``<script>`` it contains will run.
83
+ trust; any ``<script>`` it contains will run. A comment, tag or
84
+ ``<script>``/``<style>`` element left open at its end is closed there,
85
+ so it can't hide the blocks after it.
83
86
 
84
87
  Args:
85
88
  html: The HTML fragment, inserted as-is.
86
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
89
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
87
90
  label: Tab or dropdown label when the block is inside a ``Select``.
88
91
 
89
92
  Example::
@@ -108,7 +111,7 @@ class Code(EmbeddedTextBlock):
108
111
  language: Language for syntax highlighting (any Pygments lexer name, e.g.
109
112
  ``"python"``, ``"sql"``); an unknown language is shown as plain text.
110
113
  caption: Optional caption below the block.
111
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
114
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
112
115
  label: Tab or dropdown label when the block is inside a ``Select``.
113
116
 
114
117
  Example::
@@ -139,7 +142,7 @@ class Formula(EmbeddedTextBlock):
139
142
  Args:
140
143
  formula: A LaTeX expression, without ``$`` or ``\\(`` delimiters.
141
144
  caption: Optional caption below the formula.
142
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
145
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
143
146
  label: Tab or dropdown label when the block is inside a ``Select``.
144
147
 
145
148
  Example::
@@ -174,7 +177,7 @@ class BigNumber(Block):
174
177
  is red (bad news). Leave it ``None`` and the colour follows the arrow
175
178
  (▲ green, ▼ red); with neither flag the change is shown neutral, in
176
179
  the theme's muted colour.
177
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
180
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
178
181
  label: Tab or dropdown label when the block is inside a ``Select``.
179
182
 
180
183
  Example::
@@ -224,7 +227,7 @@ class Alert(Block):
224
227
  message: The alert's text.
225
228
  level: ``"info"``, ``"success"``, ``"warning"`` or ``"error"`` (or an :class:`AlertLevel`).
226
229
  title: Optional bold title above the message.
227
- name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
230
+ name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
228
231
  label: Tab or dropdown label when the block is inside a ``Select``.
229
232
 
230
233
  Example::