Skip to content

Commit

Permalink
Add source URL to example manifest (#5703)
Browse files Browse the repository at this point in the history
### What

- Fixes #5701 
- Follow-up to #5699 

### 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 newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5703/index.html) - **LINKS SHOULD
WORK _ONLY_ HERE**
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5703/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5703/index.html?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)!

- [PR Build Summary](https://build.rerun.io/pr/5703)
- [Docs
preview](https://rerun.io/preview/0530608694da108802e9898c85ea22905aadb3c5/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/0530608694da108802e9898c85ea22905aadb3c5/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 authored Mar 27, 2024
1 parent 8cf3f92 commit 88f2156
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions crates/re_build_examples/src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::path::PathBuf;

use re_build_tools::Environment;

use crate::{Channel, Example};
use std::path::PathBuf;

/// Collect examples in the repository and produce a manifest file.
///
Expand Down Expand Up @@ -36,12 +37,14 @@ impl Manifest {
}
};

let base_source_url = get_base_source_url(build_env)?;

let workspace_root = re_build_tools::cargo_metadata()?.workspace_root;
let manifest = self
.channel
.examples(workspace_root)?
.into_iter()
.map(|example| ManifestEntry::new(example, &base_url))
.map(|example| ManifestEntry::new(example, &base_url, &base_source_url))
.collect::<Vec<_>>();

if manifest.is_empty() {
Expand All @@ -62,10 +65,11 @@ struct ManifestEntry {
tags: Vec<String>,
rrd_url: String,
thumbnail: Thumbnail,
source_url: String,
}

impl ManifestEntry {
fn new(example: Example, base_url: &str) -> Self {
fn new(example: Example, base_url: &str, base_source_url: &str) -> Self {
let name = example.name;
Self {
title: example.title,
Expand All @@ -77,6 +81,11 @@ impl ManifestEntry {
width: example.thumbnail_dimensions[0],
height: example.thumbnail_dimensions[1],
},
source_url: format!(
"{base_source_url}/examples/{}/{name}/{}",
example.language.examples_dir().to_string_lossy(),
example.language.entrypoint_path().to_string_lossy()
),
name,
}
}
Expand Down Expand Up @@ -124,6 +133,17 @@ fn get_base_url(build_env: Environment) -> anyhow::Result<String> {
Ok(format!("https://app.rerun.io/commit/{sha}"))
}

fn get_base_source_url(build_env: Environment) -> anyhow::Result<String> {
if build_env == Environment::DeveloperInWorkspace {
// There is a high chance the current commit isn't pushed to the remote, so we use main
// instead.
Ok("https://github.com/rerun-io/rerun/blob/main".to_owned())
} else {
let commit = re_build_tools::git_commit_short_hash()?;
Ok(format!("https://github.com/rerun-io/rerun/tree/{commit}"))
}
}

fn parse_release_version(branch: &str) -> Option<&str> {
// release-\d+.\d+.\d+(-alpha.\d+)?

Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/welcome_screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl WelcomeScreen {
inner_margin: egui::Margin {
left: 40.0,
right: 40.0,
top: 32.0,
top: 50.0,
bottom: 8.0,
},
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/welcome_screen/welcome_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(super) fn welcome_section_ui(ui: &mut egui::Ui) {
.wrap(true),
);

ui.add_space(29.0);
ui.add_space(18.0);

let bullet_text = |ui: &mut Ui, text: &str| {
ui.horizontal(|ui| {
Expand Down

0 comments on commit 88f2156

Please sign in to comment.