briefing 0.2.4__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.
- {briefing-0.2.4 → briefing-0.3.0}/.gitignore +1 -0
- {briefing-0.2.4 → briefing-0.3.0}/CHANGELOG.md +53 -1
- {briefing-0.2.4 → briefing-0.3.0}/PKG-INFO +7 -3
- {briefing-0.2.4 → briefing-0.3.0}/README.md +6 -2
- {briefing-0.2.4 → briefing-0.3.0}/pyproject.toml +1 -1
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/__init__.py +97 -36
- briefing-0.3.0/src/briefing/_version.py +4 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/blocks/asset.py +5 -16
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/blocks/banner.py +1 -1
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/blocks/base.py +1 -1
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/blocks/layout.py +14 -4
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/blocks/text.py +11 -8
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/_blocks.py +3 -3
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/_render_profile.py +5 -3
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/static/calendar.js +28 -14
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/static/lab.js +5 -1
- briefing-0.3.0/src/briefing/renderers/css_scope.py +131 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/formatting.py +13 -3
- briefing-0.3.0/src/briefing/renderers/fragment.py +140 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/html.py +117 -21
- briefing-0.3.0/src/briefing/renderers/links.py +47 -0
- briefing-0.3.0/src/briefing/renderers/markup.py +116 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/plot.py +18 -10
- briefing-0.3.0/src/briefing/renderers/registry.py +170 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/table.py +5 -1
- briefing-0.3.0/src/briefing/static/embed-reset.css +33 -0
- briefing-0.3.0/src/briefing/static/embed.css +44 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/static/export.js +16 -13
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/static/report.css +35 -0
- briefing-0.3.0/src/briefing/static/report.js +405 -0
- briefing-0.3.0/src/briefing/templates/fragment.html.j2 +8 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/templates/report.html.j2 +2 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/compat_reports.py +2 -1
- {briefing-0.2.4 → briefing-0.3.0}/tests/conftest.py +22 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/contract.py +72 -1
- briefing-0.3.0/tests/golden.py +97 -0
- briefing-0.3.0/tests/scenarios.py +206 -0
- briefing-0.3.0/tests/snapshots/golden/alert.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/banner.html +47 -0
- briefing-0.3.0/tests/snapshots/golden/bignumber.html +45 -0
- briefing-0.3.0/tests/snapshots/golden/calendar-diverging.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/calendar.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/code.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datadive-df_all_null.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/datadive-df_constant.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/datadive-df_empty.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/datadive-df_mixed.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/datadive-df_single_row.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/datadive-infinite.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/dataprofile-df_all_null.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/dataprofile-df_constant.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/dataprofile-df_empty.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/dataprofile-df_mixed.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/dataprofile-df_single_row.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/dataprofile-infinite.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datatable-df_all_null.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datatable-df_constant.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datatable-df_empty.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datatable-df_mixed.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datatable-df_single_row.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/datatable-infinite.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/everything.html +2272 -0
- briefing-0.3.0/tests/snapshots/golden/export-menu.html +46 -0
- briefing-0.3.0/tests/snapshots/golden/formula.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/group-widths.html +46 -0
- briefing-0.3.0/tests/snapshots/golden/html.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/links.html +55 -0
- briefing-0.3.0/tests/snapshots/golden/nested-layout.html +51 -0
- briefing-0.3.0/tests/snapshots/golden/pages.html +45 -0
- briefing-0.3.0/tests/snapshots/golden/plot-altair.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/plot-matplotlib.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/plot-plotly.html +43 -0
- briefing-0.3.0/tests/snapshots/golden/select-dropdown.html +45 -0
- briefing-0.3.0/tests/snapshots/golden/select-tabs.html +45 -0
- briefing-0.3.0/tests/snapshots/golden/table-df_all_null.html +64 -0
- briefing-0.3.0/tests/snapshots/golden/table-df_constant.html +252 -0
- briefing-0.3.0/tests/snapshots/golden/table-df_empty.html +50 -0
- briefing-0.3.0/tests/snapshots/golden/table-df_mixed.html +2259 -0
- briefing-0.3.0/tests/snapshots/golden/table-df_single_row.html +58 -0
- briefing-0.3.0/tests/snapshots/golden/table-infinite.html +72 -0
- briefing-0.3.0/tests/snapshots/golden/table-styler.html +309 -0
- briefing-0.3.0/tests/snapshots/golden/text-markdown-table.html +57 -0
- briefing-0.3.0/tests/snapshots/golden/text.html +45 -0
- briefing-0.3.0/tests/snapshots/golden/toggle.html +46 -0
- briefing-0.3.0/tests/snapshots/golden/two-matplotlib-plots.html +44 -0
- briefing-0.3.0/tests/snapshots/golden/two-table-stylers.html +576 -0
- briefing-0.3.0/tests/strategies.py +64 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_blocks/test_layout.py +20 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/conftest.py +16 -0
- briefing-0.3.0/tests/test_browser/test_fragments.py +171 -0
- briefing-0.3.0/tests/test_browser/test_links.py +134 -0
- briefing-0.3.0/tests/test_browser/test_roots.py +157 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_text.py +19 -1
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_compat.py +4 -1
- briefing-0.3.0/tests/test_contract.py +153 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_deprecations.py +21 -45
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_docs_gallery.py +12 -6
- briefing-0.3.0/tests/test_fragments.py +195 -0
- briefing-0.3.0/tests/test_golden.py +79 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_lab/test_profile.py +6 -0
- briefing-0.3.0/tests/test_properties.py +83 -0
- briefing-0.3.0/tests/test_renderers/test_css_scope.py +65 -0
- briefing-0.3.0/tests/test_renderers/test_formatting.py +17 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_html.py +53 -1
- briefing-0.3.0/tests/test_renderers/test_links.py +106 -0
- briefing-0.3.0/tests/test_renderers/test_markup.py +70 -0
- briefing-0.3.0/tests/test_renderers/test_registry.py +18 -0
- briefing-0.3.0/tests/test_static_scripts.py +53 -0
- briefing-0.3.0/tests/test_version.py +28 -0
- briefing-0.2.4/src/briefing/renderers/registry.py +0 -102
- briefing-0.2.4/src/briefing/static/report.js +0 -257
- briefing-0.2.4/tests/test_contract.py +0 -331
- {briefing-0.2.4 → briefing-0.3.0}/LICENSE +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/noxfile.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/__main__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/_cli.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/_error.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/_frames.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/_preview.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/blocks/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/export/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/export/_image.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/export/_pdf.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/export/_render.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/_render_calendar.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/lab/_render_datadive.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/py.typed +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/formula.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/normalize.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/renderers/script_json.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/src/briefing/static/export.css +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/banner_images.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/html_helpers.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/image_helpers.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/pdf_reader.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/snapshots/compat_0_1_2/blocks.body.html +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/snapshots/compat_0_1_2/pages.body.html +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_blocks/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_blocks/test_banner.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_blocks/test_base.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_blocks/test_text.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_banner.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_bignumber.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_calendar.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_cli_export.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_code.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_datadive.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_datatable.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_export_image.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_export_menu.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_export_pdf.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_formula.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_layout.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_notebook.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_plots.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_print.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_spacing.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_browser/test_toggle_theme.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_cli.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_docstrings.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_export.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_frames.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_lab/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_lab/test_calendar.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_lab/test_datadive.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_lab/test_lab_boundary.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_no_viz_deps.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_pdf_reader.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_preview.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_readme.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/__init__.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_export_menu.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_formula.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_normalize.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_plot.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_reproducible.py +0 -0
- {briefing-0.2.4 → briefing-0.3.0}/tests/test_renderers/test_table.py +0 -0
|
@@ -10,6 +10,57 @@ 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
|
+
|
|
13
64
|
## [0.2.4] - 2026-11-17
|
|
14
65
|
|
|
15
66
|
### Fixed
|
|
@@ -265,7 +316,8 @@ First public release.
|
|
|
265
316
|
inherits its base's renderer.
|
|
266
317
|
- Ships inline type hints (`py.typed`). Python 3.11+.
|
|
267
318
|
|
|
268
|
-
[Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.
|
|
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
|
|
269
321
|
[0.2.4]: https://github.com/jeanmidevacc/briefing/compare/v0.2.3...v0.2.4
|
|
270
322
|
[0.2.3]: https://github.com/jeanmidevacc/briefing/compare/v0.2.2...v0.2.3
|
|
271
323
|
[0.2.2]: https://github.com/jeanmidevacc/briefing/compare/v0.2.1...v0.2.2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: briefing
|
|
3
|
-
Version: 0.
|
|
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,
|
|
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,
|
|
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
|
|
@@ -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
|
-
|
|
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
|
-
|
|
134
|
-
|
|
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.4"
|
|
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
|
-
# ──
|
|
260
|
+
# ── names removed in 0.3.0, deprecated since 0.2 ──────────────────────────────
|
|
184
261
|
|
|
185
|
-
#: old name ->
|
|
186
|
-
|
|
187
|
-
"Blocks":
|
|
188
|
-
"BaseBlock":
|
|
189
|
-
"save_report":
|
|
190
|
-
"stringify_report":
|
|
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
|
|
199
|
-
|
|
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}")
|
|
@@ -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
|
-
|
|
38
|
-
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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::
|
|
@@ -230,6 +230,9 @@ class Briefing(ContainerBlock):
|
|
|
230
230
|
(Ctrl+P or ⌘P): it gets the same print layout. *Deprecated:*
|
|
231
231
|
``"pdf"`` (the "Print" button) raises a ``DeprecationWarning`` and
|
|
232
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.
|
|
233
236
|
|
|
234
237
|
Example::
|
|
235
238
|
|
|
@@ -237,6 +240,7 @@ class Briefing(ContainerBlock):
|
|
|
237
240
|
bf.Text("# My report"),
|
|
238
241
|
bf.Plot(fig),
|
|
239
242
|
export="png",
|
|
243
|
+
footer="Analytics team", # "Analytics team · Made with briefing 0.3.0"
|
|
240
244
|
)
|
|
241
245
|
bf.save(report, "report.html")
|
|
242
246
|
"""
|
|
@@ -248,19 +252,25 @@ class Briefing(ContainerBlock):
|
|
|
248
252
|
#: Accepted with a DeprecationWarning, and dropped: they add no button.
|
|
249
253
|
DEPRECATED_EXPORTS: t.ClassVar[dict[str, str]] = {"pdf": EXPORT_PDF_DEPRECATION}
|
|
250
254
|
export: tuple[str, ...]
|
|
255
|
+
footer: str | None
|
|
251
256
|
|
|
252
257
|
def __init__(
|
|
253
258
|
self,
|
|
254
259
|
*arg_blocks: BlockOrPrimitive,
|
|
255
260
|
blocks: Sequence[BlockOrPrimitive] | None = None,
|
|
256
261
|
export: str | Sequence[str] = (),
|
|
262
|
+
footer: str | None = None,
|
|
257
263
|
) -> None:
|
|
258
264
|
# Unwrap if a single Briefing is passed directly (avoids double-wrapping).
|
|
259
265
|
if len(arg_blocks) == 1 and isinstance(arg_blocks[0], Briefing):
|
|
260
266
|
export = export or arg_blocks[0].export
|
|
267
|
+
footer = footer or arg_blocks[0].footer
|
|
261
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}.")
|
|
262
271
|
super().__init__(*arg_blocks, blocks=blocks)
|
|
263
272
|
self.export = self._check_export(export)
|
|
273
|
+
self.footer = _truncate(footer, _MAX_CAPTION_LEN) if footer else None
|
|
264
274
|
|
|
265
275
|
@classmethod
|
|
266
276
|
def _check_export(cls, export: object) -> tuple[str, ...]:
|
|
@@ -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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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 ``-``),
|
|
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::
|
|
@@ -38,7 +38,7 @@ class DataProfile(Block):
|
|
|
38
38
|
missing_threshold: Share of missing values (0–1) above which a column's
|
|
39
39
|
missing count is highlighted in red.
|
|
40
40
|
max_categories: Most frequent values shown for categorical columns.
|
|
41
|
-
name: Stable block id (letters, digits, ``_`` and ``-``),
|
|
41
|
+
name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
|
|
42
42
|
label: Tab or dropdown label when the block is inside a ``Select``.
|
|
43
43
|
|
|
44
44
|
Example::
|
|
@@ -85,7 +85,7 @@ class DataDive(Block):
|
|
|
85
85
|
facet_col: Accepted but not drawn yet (a warning says so); planned for DataDive v2.
|
|
86
86
|
layout: ``"scatter"`` (two axes) or ``"tile"`` (packed dots per cell).
|
|
87
87
|
max_rows: Larger frames are sampled down to this many rows, with a warning.
|
|
88
|
-
name: Stable block id (letters, digits, ``_`` and ``-``),
|
|
88
|
+
name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
|
|
89
89
|
label: Tab or dropdown label when the block is inside a ``Select``.
|
|
90
90
|
|
|
91
91
|
Example::
|
|
@@ -202,7 +202,7 @@ class CalendarHeatmap(Block):
|
|
|
202
202
|
on_click: ``"rows"`` lists the rows behind a day or an hour in a panel
|
|
203
203
|
when it is clicked (up to ``ROWS_PER_CELL`` rows per cell, embedded in
|
|
204
204
|
the report); ``None`` (default) for no click action.
|
|
205
|
-
name: Stable block id.
|
|
205
|
+
name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
|
|
206
206
|
label: Tab or dropdown label when the block is inside a ``Select``.
|
|
207
207
|
|
|
208
208
|
Example::
|
|
@@ -89,11 +89,13 @@ def _histogram_svg(series: t.Any) -> str:
|
|
|
89
89
|
bar = f'<rect x="0" y="0" width="{_SVG_W}" height="{_SVG_H}" fill="var(--bf-accent)" fill-opacity="0.65"/>'
|
|
90
90
|
return f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {_SVG_W} {_SVG_H}">{bar}</svg>'
|
|
91
91
|
|
|
92
|
-
# Bucket counts without numpy
|
|
93
|
-
|
|
92
|
+
# Bucket counts without numpy. A range wider than the largest float (-1e308 … 1e308)
|
|
93
|
+
# would overflow to inf, so such values are halved before subtracting.
|
|
94
|
+
scale = 1.0 if math.isfinite(mx - mn) else 0.5
|
|
95
|
+
low, span = mn * scale, mx * scale - mn * scale
|
|
94
96
|
counts = [0] * _HIST_BINS
|
|
95
97
|
for v in valid:
|
|
96
|
-
idx = min(int((float(v) -
|
|
98
|
+
idx = min(int((float(v) * scale - low) / span * _HIST_BINS), _HIST_BINS - 1)
|
|
97
99
|
counts[idx] += 1
|
|
98
100
|
|
|
99
101
|
max_count = max(counts)
|