Skip to content

Commit

Permalink
Remove the "markdown" feature of the re_space_view_text_document cr…
Browse files Browse the repository at this point in the history
…ate (rerun-io#7581)

### What

☝🏻 

Why?
- At this point, we would no longer "back off" using `egui_commonmark`.
Worst case we'd fork it (but the author has proved extremely
collaborative and responsive, so that's a very unlikely outcome).
- We already depend on `egui_commonmark` all over the place (mainly via
`UiExt::markdown()`, used eg in tootlips and view help texts).

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7581?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7581?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7581)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
abey79 authored Oct 3, 2024
1 parent 60ce5dc commit 6ffcc4f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
12 changes: 2 additions & 10 deletions crates/viewer/re_space_view_text_document/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ workspace = true
all-features = true

[features]
default = ["markdown"]
## Show `text/markdown` as Markdown.
markdown = ["dep:egui_commonmark"]
default = []

[dependencies]
re_chunk_store.workspace = true
Expand All @@ -33,10 +31,4 @@ re_ui.workspace = true
re_viewer_context.workspace = true

egui.workspace = true

# Optional dependencies:

# egui_commonmark is a 3rd party crate.
# By making it an optional dependency we can easily drop it if we need to,
# e.g. if a new version isn't released quickly enough after an egui release.
egui_commonmark = { workspace = true, optional = true, default-features = false }
egui_commonmark.workspace = true
39 changes: 14 additions & 25 deletions crates/viewer/re_space_view_text_document/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ use crate::visualizer_system::{TextDocumentEntry, TextDocumentSystem};
pub struct TextDocumentSpaceViewState {
monospace: bool,
word_wrap: bool,

#[cfg(feature = "markdown")]
commonmark_cache: egui_commonmark::CommonMarkCache,
}

Expand All @@ -28,8 +26,6 @@ impl Default for TextDocumentSpaceViewState {
Self {
monospace: false,
word_wrap: true,

#[cfg(feature = "markdown")]
commonmark_cache: Default::default(),
}
}
Expand Down Expand Up @@ -145,27 +141,20 @@ Displays text from a text component, as raw text or markdown."
let TextDocumentEntry { body, media_type } =
&text_document.text_entries[0];

#[cfg(feature = "markdown")]
{
if media_type == &re_types::components::MediaType::markdown() {
re_tracing::profile_scope!("egui_commonmark");

// Make sure headers are big:
ui.style_mut()
.text_styles
.entry(egui::TextStyle::Heading)
.or_insert(egui::FontId::proportional(32.0))
.size = 24.0;

egui_commonmark::CommonMarkViewer::new()
.max_image_width(Some(ui.available_width().floor() as _))
.show(ui, &mut state.commonmark_cache, body);
return;
}
}
#[cfg(not(feature = "markdown"))]
{
_ = media_type;
if media_type == &re_types::components::MediaType::markdown() {
re_tracing::profile_scope!("egui_commonmark");

// Make sure headers are big:
ui.style_mut()
.text_styles
.entry(egui::TextStyle::Heading)
.or_insert(egui::FontId::proportional(32.0))
.size = 24.0;

egui_commonmark::CommonMarkViewer::new()
.max_image_width(Some(ui.available_width().floor() as _))
.show(ui, &mut state.commonmark_cache, body);
return;
}

let mut text = egui::RichText::new(body.as_str());
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ re_space_view_bar_chart.workspace = true
re_space_view_dataframe.workspace = true
re_space_view_spatial.workspace = true
re_space_view_tensor.workspace = true
re_space_view_text_document = { workspace = true, features = ["markdown"] }
re_space_view_text_document.workspace = true
re_space_view_text_log.workspace = true
re_space_view_time_series.workspace = true
re_time_panel.workspace = true
Expand Down

0 comments on commit 6ffcc4f

Please sign in to comment.