briefing 0.4.0__tar.gz → 0.5.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.4.0 → briefing-0.5.0}/CHANGELOG.md +87 -1
- {briefing-0.4.0 → briefing-0.5.0}/PKG-INFO +1 -1
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/__init__.py +10 -0
- briefing-0.5.0/src/briefing/_colors.py +39 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/_version.py +1 -1
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/__init__.py +8 -1
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/asset.py +9 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/banner.py +7 -0
- briefing-0.5.0/src/briefing/blocks/chips.py +91 -0
- briefing-0.5.0/src/briefing/blocks/header.py +150 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/layout.py +190 -3
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/text.py +86 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/_blocks.py +99 -24
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/_render_calendar.py +51 -95
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/_render_timeheatmap.py +2 -1
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/static/calendar.js +13 -17
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/reference.md +34 -2
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/copy_embed.py +3 -2
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/formatting.py +15 -5
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/fragment.py +2 -7
- briefing-0.5.0/src/briefing/renderers/header.py +71 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/html.py +137 -28
- briefing-0.5.0/src/briefing/renderers/inline.py +79 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/normalize.py +1 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/plot.py +2 -1
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/table.py +17 -7
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/schema/v1.json +526 -4
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_check.py +3 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_convert.py +7 -1
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_model.py +48 -2
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/report.css +130 -24
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/report.js +15 -6
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/templates/report.html.j2 +2 -5
- {briefing-0.4.0 → briefing-0.5.0}/tests/compat_reports.py +8 -1
- {briefing-0.4.0 → briefing-0.5.0}/tests/scenarios.py +35 -10
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/alert.html +6 -4
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/attachment.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/banner.html +6 -4
- briefing-0.5.0/tests/snapshots/golden/bignumber.html +48 -0
- briefing-0.5.0/tests/snapshots/golden/calendar-diverging.html +46 -0
- briefing-0.5.0/tests/snapshots/golden/calendar.html +46 -0
- briefing-0.5.0/tests/snapshots/golden/card.html +47 -0
- briefing-0.5.0/tests/snapshots/golden/chips.html +46 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/code.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/copy-embed.html +6 -4
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datadive-df_all_null.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datadive-df_constant.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datadive-df_empty.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datadive-df_mixed.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datadive-df_single_row.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datadive-infinite.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/dataprofile-df_all_null.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/dataprofile-df_constant.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/dataprofile-df_empty.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/dataprofile-df_mixed.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/dataprofile-df_single_row.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/dataprofile-infinite.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-big.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-df_all_null.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-df_constant.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-df_empty.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-df_mixed.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-df_single_row.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-formats.html +6 -4
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/datatable-infinite.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/everything.html +7 -5
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/export-menu.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/formula.html +5 -3
- briefing-0.4.0/tests/snapshots/golden/bignumber.html → briefing-0.5.0/tests/snapshots/golden/group-fit.html +10 -6
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/group-widths.html +5 -3
- briefing-0.5.0/tests/snapshots/golden/header.html +48 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/html.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/image.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/links.html +7 -5
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/nested-layout.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/pages.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/plot-altair.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/plot-matplotlib.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/plot-plotly.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/select-dropdown.html +7 -5
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/select-tabs.html +5 -3
- briefing-0.5.0/tests/snapshots/golden/tab-style.html +48 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-df_all_null.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-df_constant.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-df_empty.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-df_mixed.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-df_single_row.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-infinite.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/table-styler.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/text-markdown-table.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/text.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/time-heatmap-months.html +6 -4
- briefing-0.5.0/tests/snapshots/golden/time-heatmap.html +46 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/toggle.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/two-matplotlib-plots.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/golden/two-table-stylers.html +5 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/strategies.py +9 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_blocks/test_banner.py +26 -0
- briefing-0.5.0/tests/test_blocks/test_bignumber_trend.py +98 -0
- briefing-0.5.0/tests/test_blocks/test_card.py +72 -0
- briefing-0.5.0/tests/test_blocks/test_chips.py +77 -0
- briefing-0.5.0/tests/test_blocks/test_header.py +118 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_blocks/test_layout.py +32 -0
- briefing-0.5.0/tests/test_blocks/test_tab_style.py +96 -0
- briefing-0.5.0/tests/test_browser/test_alert_colours.py +45 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_banner.py +15 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_big_tables.py +7 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_bignumber.py +12 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_calendar.py +32 -34
- briefing-0.5.0/tests/test_browser/test_card.py +62 -0
- briefing-0.5.0/tests/test_browser/test_chips.py +37 -0
- briefing-0.5.0/tests/test_browser/test_dropdown_a11y.py +68 -0
- briefing-0.5.0/tests/test_browser/test_group_breakpoints.py +58 -0
- briefing-0.5.0/tests/test_browser/test_header.py +39 -0
- briefing-0.5.0/tests/test_browser/test_overflow.py +28 -0
- briefing-0.5.0/tests/test_browser/test_tab_style.py +78 -0
- briefing-0.5.0/tests/test_browser/test_table_wrap.py +20 -0
- briefing-0.5.0/tests/test_browser/test_theme_tables.py +27 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_timeheatmap.py +10 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_contract.py +1 -4
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_deprecations.py +7 -8
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_fragments.py +1 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_golden.py +1 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_lab/test_calendar.py +145 -40
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_lab/test_timeheatmap.py +14 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_properties.py +14 -1
- briefing-0.5.0/tests/test_renderers/test_formatting.py +62 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_html.py +17 -0
- briefing-0.5.0/tests/test_renderers/test_inline.py +97 -0
- briefing-0.5.0/tests/test_renderers/test_table_wrap.py +50 -0
- briefing-0.5.0/tests/test_renderers/test_theme_colours.py +28 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_round_trip.py +1 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_schema.py +1 -3
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_validate.py +16 -6
- briefing-0.4.0/tests/snapshots/golden/calendar-diverging.html +0 -44
- briefing-0.4.0/tests/snapshots/golden/calendar.html +0 -44
- briefing-0.4.0/tests/snapshots/golden/time-heatmap.html +0 -44
- briefing-0.4.0/tests/test_renderers/test_formatting.py +0 -17
- {briefing-0.4.0 → briefing-0.5.0}/.gitignore +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/LICENSE +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/README.md +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/noxfile.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/pyproject.toml +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/__main__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/_cli.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/_error.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/_frames.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/_preview.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/base.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/blocks/files.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/export/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/export/_image.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/export/_pdf.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/export/_render.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/_render_datadive.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/_render_profile.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/lab/static/lab.js +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/py.typed +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/css_scope.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/formula.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/links.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/markup.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/pack.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/registry.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/script_json.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/renderers/size.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/__main__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_data.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_diagnostic.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_reference.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/spec/_validate.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/copy-embed.css +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/copy-embed.js +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/embed-reset.css +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/embed.css +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/export.css +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/export.js +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/static/unpack.js +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/src/briefing/templates/fragment.html.j2 +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/banner_images.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/conftest.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/contract.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/golden.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/html_helpers.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/image_helpers.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/pdf_reader.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/compat_0_1_2/blocks.body.html +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/snapshots/compat_0_1_2/pages.body.html +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_blocks/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_blocks/test_base.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_blocks/test_files.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_blocks/test_text.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/conftest.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_cli_export.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_code.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_copy_embed.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_datadive.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_datatable.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_export_image.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_export_menu.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_export_pdf.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_files.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_formula.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_fragments.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_layout.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_links.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_notebook.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_packed_runtimes.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_plots.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_print.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_roots.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_spacing.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_table_cells.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_table_csv.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_text.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_browser/test_toggle_theme.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_cli.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_compat.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_copy_embed.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_docs_gallery.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_docstrings.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_export.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_frames.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_install.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_lab/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_lab/test_datadive.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_lab/test_lab_boundary.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_lab/test_profile.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_no_viz_deps.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_pdf_reader.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_preview.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_readme.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_big_tables.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_css_scope.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_export_menu.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_files.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_formula.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_links.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_markup.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_normalize.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_plot.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_registry.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_reproducible.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_size.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_table.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_table_cells.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_renderers/test_table_csv.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/__init__.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_from_spec.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_reference.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_spec_properties.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_spec/test_to_spec.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_static_scripts.py +0 -0
- {briefing-0.4.0 → briefing-0.5.0}/tests/test_version.py +0 -0
|
@@ -10,6 +10,90 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.5.0] - 2026-11-22
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `DataTable(wrap=["Note"])` (or `wrap=True`): long text wraps within a readable width
|
|
18
|
+
instead of making the table scroll sideways (#151).
|
|
19
|
+
- `CalendarHeatmap` events take an optional `color` column (any CSS colour) for their dot,
|
|
20
|
+
band, outline and legend entry; without it they keep the theme's accent (#152).
|
|
21
|
+
- `CalendarHeatmap(start=, end=)`: the first and last day shown, whatever the data covers,
|
|
22
|
+
so calendars side by side line up week for week. Rows outside the span are left out with
|
|
23
|
+
a warning naming how many; events outside it aren't drawn (#153).
|
|
24
|
+
- `group_order=[...]` on `CalendarHeatmap` and `TimeHeatmap`: the listed groups first, in
|
|
25
|
+
that order, then the others by name (#154).
|
|
26
|
+
- `Banner(kicker="Data through Nov 20, 2026")`: one short muted line of plain text above
|
|
27
|
+
the banner's text (#155).
|
|
28
|
+
- `bf.TabStyle(layout=, full_width=, sticky=, size=, variant=)`: how tabs look, for the
|
|
29
|
+
page tabs (`Briefing(tabs=...)`) or one Select (`Select(style=...)`). Tabs can be
|
|
30
|
+
centred or stretched to equal shares, run their line edge to edge, stay at the top while
|
|
31
|
+
scrolling, come in three sizes, and be underlined, pills or boxed. Reports that set no
|
|
32
|
+
style render as before (#22).
|
|
33
|
+
- `Briefing(header=bf.Header(subtitle=, author=, logo=, as_of=, tz=))`: a subtitle with
|
|
34
|
+
inline Markdown, an author, an embedded logo, a "Data as of" date beside the render time,
|
|
35
|
+
and a time zone for the times shown (#25).
|
|
36
|
+
- `BigNumber(prev_value=, change_as=, higher_is_better=, format=, sparkline=)`: the change,
|
|
37
|
+
its arrow and its colour computed from the previous value (as a percent, an absolute
|
|
38
|
+
difference or percentage points), the numbers formatted, and a small trend line (#35).
|
|
39
|
+
- `Group(min_width="16rem")`: as many cells per row as fit, each at least that wide, up to
|
|
40
|
+
`columns` (#27).
|
|
41
|
+
- `bf.Chips([...])`: a wrapping row of pills, each text or a `bf.Chip(text, tooltip=, color=)`;
|
|
42
|
+
`BigNumber(accent=)` puts a colour stripe on the card. Both take `"up"`, `"down"`,
|
|
43
|
+
`"accent"` or a CSS colour; `Formatting(up_color=, down_color=)` set the theme's up and
|
|
44
|
+
down colours, which a BigNumber's ▲ and ▼ now use too (#27).
|
|
45
|
+
- `bf.Card(*blocks, title=, icon=, tags=, link=)`: a framed box with a heading line around
|
|
46
|
+
blocks stacked in one column; with `link=` the whole card leads to a block or heading
|
|
47
|
+
(#27).
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- Captions, `Alert` titles and messages, and `BigNumber` headings render inline Markdown
|
|
52
|
+
(bold, italics, code, links); raw HTML in them stays escaped, and block syntax stays text.
|
|
53
|
+
A caption that already holds `*`, backticks or `[…](…)` may now be formatted: write `\*`
|
|
54
|
+
to keep it literal (#26).
|
|
55
|
+
- The default report name, "Report", is no longer shown as a title: a report with an export
|
|
56
|
+
menu and no name shows only the date and the menu (#25).
|
|
57
|
+
- On tablets (641–960 px wide, on screen), a `Group` of three or more columns shows two per
|
|
58
|
+
row instead of squeezing every column; phones still stack, and print keeps every column
|
|
59
|
+
(#27).
|
|
60
|
+
- Theme presets use only fonts every system has, so a preset looks the same to every reader
|
|
61
|
+
(#28). Inter, DM Sans, IBM Plex Sans and Lora were named but never embedded, so most
|
|
62
|
+
readers saw a fallback. The default is now the system UI font; `corporate()` a
|
|
63
|
+
Helvetica-style sans, `minimal()` a geometric sans (Avenir, Corbel, URW Gothic),
|
|
64
|
+
`ocean()` a humanist sans (Seravek, Calibri, Ubuntu) and `warm()` a serif (Charter,
|
|
65
|
+
Cambria). Each stack names a font from macOS, Windows and Linux.
|
|
66
|
+
|
|
67
|
+
### Removed
|
|
68
|
+
|
|
69
|
+
- `CalendarHeatmap`'s hour view (`views=("hours",)` or `("days", "hours")`), deprecated
|
|
70
|
+
since 0.2.2: it raises an error that points to `bf.lab.TimeHeatmap(df, date=...,
|
|
71
|
+
rows="weekday", columns="hour")`. `views=("days",)` still works (#111).
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- Alerts in dark themes: their backgrounds and text were fixed light colours; each level now
|
|
76
|
+
keeps its hue mixed with the theme's background and text, readable (4.5:1) in every preset
|
|
77
|
+
(#167).
|
|
78
|
+
- Dropdown Selects are accessible: the menu is named after the Select's `label` ("Choose a
|
|
79
|
+
view" without one, not "Select view"), each panel is a region named after its option and
|
|
80
|
+
tied to the menu with `aria-controls`, the keyboard switches panels as it moves through
|
|
81
|
+
the options, and nested dropdowns keep to their own panels (#29).
|
|
82
|
+
- Tables read in dark themes: their stripes and the DataTable header hover were fixed light
|
|
83
|
+
greys (`#fafafa`, `#f0f0f0`); they now take the theme's surface and border colours (#150).
|
|
84
|
+
- `CalendarHeatmap`: a multi-day event no longer outlines every day it covers, which hid the
|
|
85
|
+
data under it; its band says where it runs, and its days still name it in their tooltip (#152).
|
|
86
|
+
|
|
87
|
+
## [0.4.1] - 2026-11-20
|
|
88
|
+
|
|
89
|
+
### Fixed
|
|
90
|
+
|
|
91
|
+
- A wide `DataTable` (long text, many columns) inside a `Group` or a `Page` widened the
|
|
92
|
+
whole report instead of scrolling in its own box, since every page is a `Group`; a
|
|
93
|
+
`Group`'s cells may now shrink below their content's width.
|
|
94
|
+
- `lab.TimeHeatmap`'s legend said "no such date" for grids with no blank cell, such as month
|
|
95
|
+
by year; it now does only when a cell can't exist.
|
|
96
|
+
|
|
13
97
|
## [0.4.0] - 2026-11-20
|
|
14
98
|
|
|
15
99
|
### Added
|
|
@@ -415,7 +499,9 @@ First public release.
|
|
|
415
499
|
inherits its base's renderer.
|
|
416
500
|
- Ships inline type hints (`py.typed`). Python 3.11+.
|
|
417
501
|
|
|
418
|
-
[Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.
|
|
502
|
+
[Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.5.0...HEAD
|
|
503
|
+
[0.5.0]: https://github.com/jeanmidevacc/briefing/compare/v0.4.1...v0.5.0
|
|
504
|
+
[0.4.1]: https://github.com/jeanmidevacc/briefing/compare/v0.4.0...v0.4.1
|
|
419
505
|
[0.4.0]: https://github.com/jeanmidevacc/briefing/compare/v0.3.0...v0.4.0
|
|
420
506
|
[0.3.0]: https://github.com/jeanmidevacc/briefing/compare/v0.2.4...v0.3.0
|
|
421
507
|
[0.2.4]: https://github.com/jeanmidevacc/briefing/compare/v0.2.3...v0.2.4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: briefing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -42,16 +42,21 @@ from briefing.blocks import (
|
|
|
42
42
|
BigNumber,
|
|
43
43
|
Block,
|
|
44
44
|
Briefing,
|
|
45
|
+
Card,
|
|
46
|
+
Chip,
|
|
47
|
+
Chips,
|
|
45
48
|
Code,
|
|
46
49
|
DataTable,
|
|
47
50
|
Formula,
|
|
48
51
|
Group,
|
|
52
|
+
Header,
|
|
49
53
|
Image,
|
|
50
54
|
Page,
|
|
51
55
|
Plot,
|
|
52
56
|
Select,
|
|
53
57
|
SelectType,
|
|
54
58
|
Table,
|
|
59
|
+
TabStyle,
|
|
55
60
|
Text,
|
|
56
61
|
Toggle,
|
|
57
62
|
VAlign,
|
|
@@ -238,6 +243,9 @@ __all__: list[str] = [
|
|
|
238
243
|
"Alert",
|
|
239
244
|
"AlertLevel",
|
|
240
245
|
"BigNumber",
|
|
246
|
+
"Card",
|
|
247
|
+
"Chip",
|
|
248
|
+
"Chips",
|
|
241
249
|
"Code",
|
|
242
250
|
"Formula",
|
|
243
251
|
"HTML",
|
|
@@ -246,9 +254,11 @@ __all__: list[str] = [
|
|
|
246
254
|
"Block",
|
|
247
255
|
"Briefing",
|
|
248
256
|
"Group",
|
|
257
|
+
"Header",
|
|
249
258
|
"Page",
|
|
250
259
|
"Select",
|
|
251
260
|
"SelectType",
|
|
261
|
+
"TabStyle",
|
|
252
262
|
"Toggle",
|
|
253
263
|
"VAlign",
|
|
254
264
|
"wrap_block",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Colours a block may take from its author (#27): a theme token or a plain CSS colour.
|
|
2
|
+
|
|
3
|
+
``"up"``, ``"down"`` and ``"accent"`` name the theme's colours (``--bf-up``, ``--bf-down``,
|
|
4
|
+
``--bf-accent``), so a dark theme sets them once; anything else must be a CSS colour made of
|
|
5
|
+
plain characters, so it can't break out of the ``style`` attribute it lands in.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
|
|
11
|
+
from briefing._error import BriefingError
|
|
12
|
+
|
|
13
|
+
#: A CSS colour: a hex, a name, or rgb()/hsl()/oklch()/oklab() with plain numbers.
|
|
14
|
+
CSS_COLOR = re.compile(
|
|
15
|
+
r"^(?:#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})" # #rgb, #rgba, #rrggbb, #rrggbbaa
|
|
16
|
+
r"|[a-zA-Z]+" # a named colour
|
|
17
|
+
r"|(?:rgb|rgba|hsl|hsla|oklch|oklab)\([0-9.,%\s/-]+\))$" # a colour function of plain numbers
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
#: The theme's colours, by the name an author uses.
|
|
21
|
+
TOKENS = {"up": "var(--bf-up)", "down": "var(--bf-down)", "accent": "var(--bf-accent)"}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def check_color(value: object, where: str) -> str | None:
|
|
25
|
+
"""*value* if it is a theme token or a CSS colour (``None`` stays ``None``); else an error."""
|
|
26
|
+
if value is None:
|
|
27
|
+
return None
|
|
28
|
+
if isinstance(value, str) and (value in TOKENS or CSS_COLOR.match(value.strip())):
|
|
29
|
+
return value.strip()
|
|
30
|
+
raise BriefingError(f"{where} is 'up', 'down', 'accent' or a CSS colour such as '#2dd4bf' or 'teal', "
|
|
31
|
+
f"not {value!r}.")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def css_color(value: str) -> str:
|
|
35
|
+
"""The CSS for a checked colour: a theme token becomes its variable."""
|
|
36
|
+
return TOKENS.get(value, value)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
__all__ = ["CSS_COLOR", "TOKENS", "check_color", "css_color"]
|
|
@@ -5,8 +5,10 @@ Custom-visualisation blocks (DataProfile, DataDive) live in ``briefing.lab``.
|
|
|
5
5
|
from briefing.blocks.asset import DataTable, Plot, Table
|
|
6
6
|
from briefing.blocks.banner import Banner
|
|
7
7
|
from briefing.blocks.base import Block, BlockId, BlockOrPrimitive, ContainerBlock, wrap_block
|
|
8
|
+
from briefing.blocks.chips import Chip, Chips
|
|
8
9
|
from briefing.blocks.files import Attachment, Image
|
|
9
|
-
from briefing.blocks.
|
|
10
|
+
from briefing.blocks.header import Header
|
|
11
|
+
from briefing.blocks.layout import Briefing, Card, Group, Page, Select, SelectType, TabStyle, Toggle, VAlign
|
|
10
12
|
from briefing.blocks.text import HTML, Alert, AlertLevel, BigNumber, Code, Formula, Text
|
|
11
13
|
|
|
12
14
|
__all__: list[str] = [
|
|
@@ -20,6 +22,9 @@ __all__: list[str] = [
|
|
|
20
22
|
"Alert",
|
|
21
23
|
"AlertLevel",
|
|
22
24
|
"BigNumber",
|
|
25
|
+
"Card",
|
|
26
|
+
"Chip",
|
|
27
|
+
"Chips",
|
|
23
28
|
"Code",
|
|
24
29
|
"Formula",
|
|
25
30
|
"HTML",
|
|
@@ -27,9 +32,11 @@ __all__: list[str] = [
|
|
|
27
32
|
# layout
|
|
28
33
|
"Briefing",
|
|
29
34
|
"Group",
|
|
35
|
+
"Header",
|
|
30
36
|
"Page",
|
|
31
37
|
"Select",
|
|
32
38
|
"SelectType",
|
|
39
|
+
"TabStyle",
|
|
33
40
|
"Toggle",
|
|
34
41
|
"VAlign",
|
|
35
42
|
# asset
|
|
@@ -119,6 +119,8 @@ class DataTable(Block):
|
|
|
119
119
|
"{url}"}``, a URL template where ``{}`` is the cell's value and ``{url}`` the value
|
|
120
120
|
of the column ``url`` in the same row. Only ``http(s)://`` and ``mailto:`` URLs
|
|
121
121
|
make links (anything else stays text, with a warning); they open in a new tab.
|
|
122
|
+
wrap: Columns whose text wraps onto several lines, instead of making the table
|
|
123
|
+
scroll sideways: a list of column names, or ``True`` for every column.
|
|
122
124
|
download: Put a "CSV" button above the table: it downloads the rows matching the
|
|
123
125
|
reader's search, in their order, with their raw values (not the formatted
|
|
124
126
|
text), as a file named after the table's ``name`` or caption.
|
|
@@ -148,6 +150,7 @@ class DataTable(Block):
|
|
|
148
150
|
max_rows: int = MAX_ROWS,
|
|
149
151
|
formats: dict[str, str | Callable[[t.Any], str]] | None = None,
|
|
150
152
|
links: dict[str, str] | None = None,
|
|
153
|
+
wrap: bool | list[str] = False,
|
|
151
154
|
download: bool = False,
|
|
152
155
|
name: BlockId | None = None,
|
|
153
156
|
label: str | None = None,
|
|
@@ -156,6 +159,12 @@ class DataTable(Block):
|
|
|
156
159
|
df = to_pandas(df, block="DataTable")
|
|
157
160
|
if not isinstance(download, bool):
|
|
158
161
|
raise BriefingError(f"DataTable: download is True or False, not {download!r}.")
|
|
162
|
+
if not isinstance(wrap, bool):
|
|
163
|
+
if not isinstance(wrap, list | tuple) or not all(isinstance(c, str) for c in wrap):
|
|
164
|
+
raise BriefingError(f"DataTable: wrap is True, False or a list of column names, not {wrap!r}.")
|
|
165
|
+
_columns_named("wrap", wrap, df)
|
|
166
|
+
wrap = list(wrap)
|
|
167
|
+
self.wrap = wrap
|
|
159
168
|
self.download = download
|
|
160
169
|
self.formats = _check_formats(formats, df) if formats else None
|
|
161
170
|
self.links = _check_links(links, df) if links else None
|
|
@@ -56,12 +56,15 @@ class Banner(Block):
|
|
|
56
56
|
height: CSS height such as ``"16rem"`` (default) or a number of pixels.
|
|
57
57
|
focus: ``(x, y)`` in percent: the point of the image kept in view when it is cropped.
|
|
58
58
|
alt: A description of the image; by default it is decorative.
|
|
59
|
+
kicker: One short line of plain text above ``text``, smaller and in the
|
|
60
|
+
theme's muted colour, such as ``"Data through Nov 20, 2026"``. Escaped, never Markdown.
|
|
59
61
|
name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
|
|
60
62
|
label: Tab or dropdown label when the block is inside a ``Select``.
|
|
61
63
|
|
|
62
64
|
Example::
|
|
63
65
|
|
|
64
66
|
bf.Banner("# Q1 2026\\n\\n**Sales briefing**", image="cover.jpg", text_position=55, opacity=80)
|
|
67
|
+
bf.Banner("# Search interest", image="cover.png", kicker="Data through Nov 20, 2026")
|
|
65
68
|
"""
|
|
66
69
|
|
|
67
70
|
embed_noun: t.ClassVar[str | None] = "banner"
|
|
@@ -77,6 +80,7 @@ class Banner(Block):
|
|
|
77
80
|
height: str | int = "16rem",
|
|
78
81
|
focus: tuple[float, float] = (50, 50),
|
|
79
82
|
alt: str | None = None,
|
|
83
|
+
kicker: str | None = None,
|
|
80
84
|
name: BlockId | None = None,
|
|
81
85
|
label: str | None = None,
|
|
82
86
|
) -> None:
|
|
@@ -107,6 +111,9 @@ class Banner(Block):
|
|
|
107
111
|
self.side, self.fade, self.height = side, fade, css_height
|
|
108
112
|
self.focus = (_percent("focus", focus[0]), _percent("focus", focus[1]))
|
|
109
113
|
self.alt = alt
|
|
114
|
+
if kicker is not None and (not isinstance(kicker, str) or "\n" in kicker.strip()):
|
|
115
|
+
raise BriefingError(f"Banner: kicker is one line of plain text, not {kicker!r}.")
|
|
116
|
+
self.kicker = (kicker or "").strip() or None
|
|
110
117
|
|
|
111
118
|
|
|
112
119
|
__all__: list[str] = ["Banner"]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Chips (#27): a wrapping row of labelled pills, such as the searches that rose or fell."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import dataclasses
|
|
5
|
+
import typing as t
|
|
6
|
+
from collections.abc import Mapping, Sequence
|
|
7
|
+
|
|
8
|
+
from briefing._colors import check_color
|
|
9
|
+
from briefing._error import BriefingError
|
|
10
|
+
from briefing.blocks.base import _MAX_CAPTION_LEN, Block, BlockId, _truncate
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclasses.dataclass(frozen=True)
|
|
14
|
+
class Chip:
|
|
15
|
+
"""One pill of a :class:`Chips` row: its text, and an optional tooltip and colour.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
text: What the pill says, as plain text.
|
|
19
|
+
tooltip: Shown when the reader hovers the pill.
|
|
20
|
+
color: ``"up"``, ``"down"`` or ``"accent"`` (the theme's colours) or a CSS colour;
|
|
21
|
+
the pill is tinted with it. Without it the pill is neutral.
|
|
22
|
+
|
|
23
|
+
Example::
|
|
24
|
+
|
|
25
|
+
bf.Chip("Steam +41%", tooltip="Usual level 31, since the release 44", color="up")
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
text: str
|
|
29
|
+
tooltip: str | None = None
|
|
30
|
+
color: str | None = None
|
|
31
|
+
|
|
32
|
+
def __post_init__(self) -> None:
|
|
33
|
+
if not isinstance(self.text, str) or not self.text.strip():
|
|
34
|
+
raise BriefingError(f"Chip: text is a short line such as 'Steam +41%', not {self.text!r}.")
|
|
35
|
+
if self.tooltip is not None and not isinstance(self.tooltip, str):
|
|
36
|
+
raise BriefingError(f"Chip: tooltip is text, not {self.tooltip!r}.")
|
|
37
|
+
object.__setattr__(self, "text", _truncate(self.text.strip(), _MAX_CAPTION_LEN))
|
|
38
|
+
object.__setattr__(self, "tooltip", self.tooltip.strip() or None if self.tooltip else None)
|
|
39
|
+
object.__setattr__(self, "color", check_color(self.color, "Chip: color"))
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def of(cls, item: object) -> Chip:
|
|
43
|
+
"""*item* as a Chip: a Chip, its text, or a dict of its fields (the JSON form)."""
|
|
44
|
+
if isinstance(item, Chip):
|
|
45
|
+
return item
|
|
46
|
+
if isinstance(item, str):
|
|
47
|
+
return cls(item)
|
|
48
|
+
if isinstance(item, Mapping):
|
|
49
|
+
fields = [f.name for f in dataclasses.fields(cls)]
|
|
50
|
+
unknown = [k for k in item if k not in fields]
|
|
51
|
+
if unknown:
|
|
52
|
+
raise BriefingError(f"Chip has no field {unknown[0]!r}; it takes {', '.join(fields)}.")
|
|
53
|
+
return cls(**item)
|
|
54
|
+
raise BriefingError(f"Chips: an item is text, a bf.Chip(...) or a dict of its fields, not {item!r}.")
|
|
55
|
+
|
|
56
|
+
def to_json(self) -> str | dict[str, str]:
|
|
57
|
+
"""The JSON form: the text alone, or an object when there is more."""
|
|
58
|
+
if self.tooltip is None and self.color is None:
|
|
59
|
+
return self.text
|
|
60
|
+
return {k: v for k, v in dataclasses.asdict(self).items() if v is not None}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Chips(Block):
|
|
64
|
+
"""A wrapping row of pills: labels, tags, or values that rose or fell.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
items: The pills: text, or :class:`Chip` for a tooltip or a colour.
|
|
68
|
+
name: Stable block id (letters, digits, ``_`` and ``-``), its link in the report (``#page/name``).
|
|
69
|
+
label: Tab or dropdown label when the block is inside a ``Select``.
|
|
70
|
+
|
|
71
|
+
Example::
|
|
72
|
+
|
|
73
|
+
bf.Chips(["Pizza", "Uber Eats", "DoorDash"])
|
|
74
|
+
bf.Chips([bf.Chip("Steam +41%", color="up"), bf.Chip("Netflix -12%", color="down")])
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
items: Sequence[str | Chip | Mapping[str, t.Any]],
|
|
80
|
+
name: BlockId | None = None,
|
|
81
|
+
label: str | None = None,
|
|
82
|
+
) -> None:
|
|
83
|
+
super().__init__(name=name, label=label)
|
|
84
|
+
if isinstance(items, str | bytes | Mapping) or not isinstance(items, Sequence):
|
|
85
|
+
raise BriefingError(f"Chips: items is a list of texts or bf.Chip(...), not {type(items).__name__}.")
|
|
86
|
+
if not items:
|
|
87
|
+
raise BriefingError("Chips: items holds at least one pill.")
|
|
88
|
+
self.items = [Chip.of(item) for item in items]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
__all__ = ["Chip", "Chips"]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""The report header's extras (#25): a subtitle, an author, a logo, a "data as of" date and a time zone."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import dataclasses
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import typing as t
|
|
7
|
+
from collections.abc import Mapping
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from briefing._error import BriefingError
|
|
11
|
+
from briefing.blocks.banner import _image_type
|
|
12
|
+
from briefing.blocks.base import _MAX_CAPTION_LEN, _truncate
|
|
13
|
+
|
|
14
|
+
_FORMATS = "PNG, JPEG, GIF, WebP or SVG"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclasses.dataclass(frozen=True)
|
|
18
|
+
class Header:
|
|
19
|
+
"""What the report header shows besides the report's name and the time it was rendered.
|
|
20
|
+
|
|
21
|
+
Pass it as ``Briefing(header=...)``; every field is optional.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
subtitle: A line under the title, with inline Markdown as in captions.
|
|
25
|
+
author: Who made the report, shown as "By <author>".
|
|
26
|
+
logo: A PNG, JPEG, GIF, WebP or SVG image (a path, its bytes or a ``data:``
|
|
27
|
+
URI), embedded in the report and drawn beside the title.
|
|
28
|
+
as_of: The date (or date and time) the data runs to, shown as "Data as of …"
|
|
29
|
+
beside the render time: a ``date``, a ``datetime`` or an ISO string.
|
|
30
|
+
tz: An IANA time zone such as ``"America/Montreal"`` for the times shown
|
|
31
|
+
(the render time, and an ``as_of`` with a time); UTC without it.
|
|
32
|
+
|
|
33
|
+
Example::
|
|
34
|
+
|
|
35
|
+
report = bf.Briefing(
|
|
36
|
+
bf.Text("..."),
|
|
37
|
+
header=bf.Header(subtitle="Weekly search interest", author="Analytics team",
|
|
38
|
+
logo="logo.svg", as_of="2026-11-20", tz="America/Montreal"),
|
|
39
|
+
)
|
|
40
|
+
bf.save(report, "report.html", name="Search report")
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
subtitle: str | None = None
|
|
44
|
+
author: str | None = None
|
|
45
|
+
logo: bytes | str | Path | None = None
|
|
46
|
+
as_of: dt.date | dt.datetime | str | None = None
|
|
47
|
+
tz: str | None = None
|
|
48
|
+
|
|
49
|
+
def __post_init__(self) -> None:
|
|
50
|
+
for option in ("subtitle", "author"):
|
|
51
|
+
value = getattr(self, option)
|
|
52
|
+
if value is not None and not isinstance(value, str):
|
|
53
|
+
raise BriefingError(f"Header: {option} is text, not {value!r}.")
|
|
54
|
+
object.__setattr__(self, option, _truncate(value.strip(), _MAX_CAPTION_LEN) if value else None)
|
|
55
|
+
object.__setattr__(self, "logo", _logo(self.logo))
|
|
56
|
+
object.__setattr__(self, "as_of", _as_of(self.as_of))
|
|
57
|
+
if self.tz is not None:
|
|
58
|
+
_zone(self.tz)
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def logo_bytes(self) -> bytes | None:
|
|
62
|
+
"""The logo's bytes (``logo`` is read and checked when the Header is made)."""
|
|
63
|
+
return self.logo if isinstance(self.logo, bytes) else None
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def logo_mime(self) -> str | None:
|
|
67
|
+
"""The logo's MIME type, from its bytes."""
|
|
68
|
+
return _image_type(self.logo) if isinstance(self.logo, bytes) else None
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def of(cls, value: Header | Mapping[str, t.Any] | None) -> Header | None:
|
|
72
|
+
"""*value* as a Header: a Header, a dict of its fields (the JSON form) or ``None``."""
|
|
73
|
+
if value is None or isinstance(value, Header):
|
|
74
|
+
return value
|
|
75
|
+
if isinstance(value, Mapping):
|
|
76
|
+
fields = [f.name for f in dataclasses.fields(cls)]
|
|
77
|
+
unknown = [k for k in value if k not in fields]
|
|
78
|
+
if unknown:
|
|
79
|
+
raise BriefingError(f"Briefing header=: Header has no field {unknown[0]!r}; "
|
|
80
|
+
f"it takes {', '.join(fields)}.")
|
|
81
|
+
return cls(**value)
|
|
82
|
+
raise BriefingError(f"Briefing header= takes a bf.Header(...) or a dict of its fields, not {value!r}.")
|
|
83
|
+
|
|
84
|
+
def to_dict(self) -> dict[str, t.Any]:
|
|
85
|
+
"""The fields that are set, as JSON: the logo as a ``data:`` URI, ``as_of`` in ISO form."""
|
|
86
|
+
from briefing.spec._data import encode_image
|
|
87
|
+
|
|
88
|
+
out: dict[str, t.Any] = {}
|
|
89
|
+
for field in dataclasses.fields(self):
|
|
90
|
+
value = getattr(self, field.name)
|
|
91
|
+
if value is None:
|
|
92
|
+
continue
|
|
93
|
+
if field.name == "logo":
|
|
94
|
+
value = encode_image(value)
|
|
95
|
+
elif field.name == "as_of":
|
|
96
|
+
value = value.isoformat()
|
|
97
|
+
out[field.name] = value
|
|
98
|
+
return out
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _logo(logo: object) -> bytes | None:
|
|
102
|
+
if logo is None:
|
|
103
|
+
return None
|
|
104
|
+
if isinstance(logo, bytes):
|
|
105
|
+
data = logo
|
|
106
|
+
elif isinstance(logo, str) and logo.startswith("data:"):
|
|
107
|
+
from briefing.spec._data import decode_image
|
|
108
|
+
|
|
109
|
+
data = decode_image(logo)
|
|
110
|
+
elif isinstance(logo, str | Path):
|
|
111
|
+
path = Path(logo).expanduser()
|
|
112
|
+
if not path.is_file():
|
|
113
|
+
raise BriefingError(f"Header: logo file not found: {path}")
|
|
114
|
+
data = path.read_bytes()
|
|
115
|
+
else:
|
|
116
|
+
raise BriefingError(f"Header: logo is a {_FORMATS} file's path, its bytes or a data: URI, not {logo!r}.")
|
|
117
|
+
if _image_type(data) is None:
|
|
118
|
+
raise BriefingError(f"Header: the logo must be a {_FORMATS} image.")
|
|
119
|
+
return data
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _as_of(value: object) -> dt.date | None:
|
|
123
|
+
if isinstance(value, dt.datetime) and type(value) is not dt.datetime: # pd.Timestamp and the like
|
|
124
|
+
return dt.datetime.fromisoformat(value.isoformat())
|
|
125
|
+
if value is None or isinstance(value, dt.date): # a datetime is a date too
|
|
126
|
+
return value
|
|
127
|
+
if isinstance(value, str):
|
|
128
|
+
try:
|
|
129
|
+
return dt.date.fromisoformat(value) if len(value.strip()) == 10 else dt.datetime.fromisoformat(value)
|
|
130
|
+
except ValueError:
|
|
131
|
+
pass
|
|
132
|
+
raise BriefingError(f"Header: as_of is a date, a datetime or an ISO string such as '2026-11-20', not {value!r}.")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _zone(tz: str) -> dt.tzinfo:
|
|
136
|
+
import zoneinfo
|
|
137
|
+
|
|
138
|
+
try:
|
|
139
|
+
return zoneinfo.ZoneInfo(tz)
|
|
140
|
+
except (zoneinfo.ZoneInfoNotFoundError, ValueError, TypeError) as exc:
|
|
141
|
+
raise BriefingError(f"Header: unknown time zone {tz!r}; use an IANA name such as 'Europe/Paris'.") from exc
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def local_time(when: dt.datetime, tz: str | None) -> dt.datetime:
|
|
145
|
+
"""*when* in *tz* (UTC without it); a naive *when* is taken as already in that zone."""
|
|
146
|
+
zone = _zone(tz) if tz else dt.UTC
|
|
147
|
+
return when.replace(tzinfo=zone) if when.tzinfo is None else when.astimezone(zone)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
__all__ = ["Header", "local_time"]
|