Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TOML for example readme frontmatter #4553

Merged
merged 27 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5beee75
update example readmes and manifest
jprochazk Dec 15, 2023
553c68d
update all readme frontmatter to toml
jprochazk Dec 15, 2023
37e47f6
update frontmatter parsing to use toml
jprochazk Dec 15, 2023
4506843
support HTML comment frontmatter in python
jprochazk Dec 15, 2023
cf4a4f8
support HTML comment frontmatter in rust
jprochazk Dec 15, 2023
bedfe49
update example READMEs to use HTML comment frontmatter
jprochazk Dec 15, 2023
26ba4d5
Merge branch 'main' into jan/toml-manifest
jprochazk Dec 15, 2023
4fb66a7
sort import block
jprochazk Dec 15, 2023
1bdb02f
fix lint
jprochazk Dec 15, 2023
ad98944
fix newlines
jprochazk Dec 15, 2023
b969fbb
fix duplicate toml_edit dependency
jprochazk Dec 15, 2023
72047ad
check for `None`
jprochazk Dec 15, 2023
3281544
remove `manifest.yml`
jprochazk Dec 15, 2023
ef0d9f3
try to fix linkinator
jprochazk Dec 15, 2023
2e0be05
try skip the link instead
jprochazk Dec 15, 2023
77e78ab
ignore `static.rerun.io` links
jprochazk Dec 15, 2023
fc8528b
undo ignoring `static.rerun.io` links
jprochazk Dec 15, 2023
e9ab955
skip more links...
jprochazk Dec 15, 2023
f8ad8ad
update `metadata` to be an actual html comment
jprochazk Dec 16, 2023
a650197
add `order` to manifest
jprochazk Dec 16, 2023
6eae5b2
Merge branch 'main' into jan/toml-manifest
jprochazk Dec 16, 2023
08ffc77
Merge branch 'main' into jan/toml-manifest
emilk Dec 19, 2023
da186c5
Remove dependencies on python-frontmatter
emilk Dec 19, 2023
80ff3fe
Better error message
emilk Dec 19, 2023
e4e086c
Remove default features for `toml` crate
emilk Dec 19, 2023
394ad54
Reuse the same `load_frontmatter` function
emilk Dec 19, 2023
7588e64
fix importing of frontmatter.py
emilk Dec 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/contrib_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ jobs:
- name: Install dependencies
shell: bash
run: |
pip install gitignore_parser python-frontmatter
pip install gitignore_parser
pip install -r ./scripts/ci/requirements.txt

- name: Rerun lints
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:

# Avoid crates.io rate-limiting, skip changelog PR links (so many), and skip speculative links
# TODO(#4085): https://rerun-io.github.io/rerun/dev/bench/ often 404:s for unknown reasons
linksToSkip: "https://crates.io/crates/.*, https://github.com/rerun-io/rerun/pull/.*, .*?speculative-link, https://rerun-io.github.io/rerun/dev/bench/"
# TODO(#4556): remove the `static.rerun.io` and `github.com` skips
linksToSkip: "https://static.rerun.io/.*, https://github.com/.*, https://crates.io/crates/.*, https://github.com/rerun-io/rerun/pull/.*, .*?speculative-link, https://rerun-io.github.io/rerun/dev/bench/"
retry: true
retryErrors: true
retryErrorsCount: 5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ jobs:
- name: Install dependencies
shell: bash
run: |
pip install gitignore_parser python-frontmatter
pip install gitignore_parser
pip install -r ./scripts/ci/requirements.txt

- name: Rerun lints
Expand Down
56 changes: 32 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ serde = "1"
serde_bytes = "0.11"
serde_json = { version = "1", default-features = false, features = ["std"] }
serde_test = "1"
serde_yaml = { version = "0.9.21", default-features = false }
sha2 = "0.10"
similar-asserts = "1.4.2"
slotmap = { version = "1.0.6", features = ["serde"] }
Expand All @@ -213,6 +212,7 @@ tinyvec = { version = "1.6", features = ["alloc", "rustc_1_55"] }
tobj = "4.0"
tokio = { version = "1.24", default-features = false }
tokio-tungstenite = { version = "0.17.1", default-features = false }
toml = { version = "0.7.8", default-features = false }
tracing = { version = "0.1", default-features = false }
tungstenite = { version = "0.17", default-features = false }
type-map = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion crates/re_build_examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ argh.workspace = true
indicatif.workspace = true
rayon.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_yaml.workspace = true
serde_json.workspace = true
toml = { workspace = true, features = ["parse", "preserve_order"] }
26 changes: 16 additions & 10 deletions crates/re_build_examples/src/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,28 @@ struct Frontmatter {
}

fn parse_frontmatter<P: AsRef<Path>>(path: P) -> anyhow::Result<Option<Frontmatter>> {
const START: &str = "<!--[metadata]";
const END: &str = "-->";

let path = path.as_ref();
let content = std::fs::read_to_string(path)?;
let content = content.replace('\r', ""); // Windows, god damn you
re_build_tools::rerun_if_changed(path);
let Some(content) = content.strip_prefix("---\n") else {

let Some(start) = content.find(START) else {
return Ok(None);
};
let Some(end) = content.find("---") else {
anyhow::bail!("{:?} has invalid frontmatter: missing --- terminator", path);
let start = start + START.len();

let Some(end) = content[start..].find(END) else {
anyhow::bail!("{:?} has invalid frontmatter: missing --> terminator", path);
};
Ok(Some(serde_yaml::from_str(&content[..end]).map_err(
|err| {
let end = start + end;

toml::from_str(content[start..end].trim())
.map(Some)
.map_err(|err| {
anyhow::anyhow!(
"failed to read {:?}: {err}",
"Failed to parse TOML metadata of {:?}: {err}",
path.parent().unwrap().file_name().unwrap()
)
},
)?))
})
}
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ tags: [2D, huggingface, object-detection, object-tracking, opencv]

The contents of this `README.md` file and its frontmatter are used to render the examples in [the documentation](https://rerun.io/examples). Individual examples are currently "stitched together" to form one large markdown file for every category of examples (`artificial-data`, `real-data`).

The `manifest.yml` file describes the structure of the examples contained in this repository. Only the examples which appear in the manifest are included in the [generated documentation](https://rerun.io/examples). The file contains a description of its own format.
The `manifest.toml` file describes the structure of the examples contained in this repository. Only the examples which appear in the manifest are included in the [generated documentation](https://rerun.io/examples). The file contains a description of its own format.

## Adding a new example

You can base your example off of `python/template` or `rust/template`.
Once it's ready to be displayed in the docs, add it to the [manifest](./manifest.yml).
Once it's ready to be displayed in the docs, add it to the [manifest](./manifest.toml).

If you want to run the example on CI and include it in the in-viewer example page,
add a `channel` entry to its README frontmatter. The available channels right now are:
Expand Down
12 changes: 5 additions & 7 deletions examples/c/spawn_viewer/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
title: Spawn Viewer
tags: [spawn]
c: https://github.com/rerun-io/rerun/tree/latest/examples/c/spawn_viewer/main.c
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/spawn_viewer/main.cpp
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/spawn_viewer/src/main.rs
---
<!--[metadata]
title = "Spawn Viewer"
tags = ["spawn"]
-->


Shows how to spawn a new Rerun Viewer process ready to listen for TCP connections using an executable available in PATH.

Expand Down
12 changes: 5 additions & 7 deletions examples/cpp/clock/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
title: Clock
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/clock/main.py
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/clock/src/main.rs
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/clock/main.cpp
thumbnail: https://static.rerun.io/clock/ae4b8970edba8480431cb71e57b8cddd9e1769c7/480w.png
---
<!--[metadata]
title = "Clock"
thumbnail = "https://static.rerun.io/clock/ae4b8970edba8480431cb71e57b8cddd9e1769c7/480w.png"
-->


<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/clock/05e69dc20c9a28005f1ffe7f0f2ac9eeaa95ba3b/480w.png">
Expand Down
20 changes: 9 additions & 11 deletions examples/cpp/dna/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
title: Helix
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/dna/main.py
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/dna/src/main.rs
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/dna/main.cpp
tags: [3d, api-example]
description: "Simple example of logging point and line primitives to draw a 3D helix."
thumbnail: https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png
thumbnail_dimensions: [480, 285]
channel: main
---
<!--[metadata]
title = "Helix"
tags = ["3d", "api-example"]
description = "Simple example of logging point and line primitives to draw a 3D helix."
thumbnail = "https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png"
thumbnail_dimensions = [480, 285]
channel = "main"
-->


<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png">
Expand Down
15 changes: 8 additions & 7 deletions examples/cpp/eigen_opencv/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: "Eigen and OpenCV C++ Integration"
cpp: https://github.com/rerun-io/cpp-example-opencv-eigen
tags: [2D, 3D, C++, Eigen, OpenCV]
thumbnail: https://static.rerun.io/cpp-example-opencv-eigen/2fc6355fd87fbb4d07cda384ee8805edb68b5e01/480w.png
thumbnail_dimensions: [480, 267]
---
<!--[metadata]
title = "Eigen and OpenCV C++ Integration"
source = "https://github.com/rerun-io/cpp-example-opencv-eigen"
tags = ["2D", "3D", "C++", "Eigen", "OpenCV"]
thumbnail = "https://static.rerun.io/cpp-example-opencv-eigen/2fc6355fd87fbb4d07cda384ee8805edb68b5e01/480w.png"
thumbnail_dimensions = [480, 267]
-->


This is a minimal CMake project that shows how to use Rerun in your code in conjunction with [Eigen](https://eigen.tuxfamily.org/) and [OpenCV](https://opencv.org/).

Expand Down
12 changes: 5 additions & 7 deletions examples/cpp/minimal/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
title: Minimal example
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/minimal/main.py
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/minimal/src/main.rs
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/minimal/main.cpp
thumbnail: https://static.rerun.io/minimal/0e47ac513ab25d56cf2b493128097d499a07e5e8/480w.png
---
<!--[metadata]
title = "Minimal example"
thumbnail = "https://static.rerun.io/minimal/0e47ac513ab25d56cf2b493128097d499a07e5e8/480w.png"
-->


<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/minimal/0e47ac513ab25d56cf2b493128097d499a07e5e8/480w.png">
Expand Down
9 changes: 4 additions & 5 deletions examples/cpp/shared_recording/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
title: Shared Recording
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/shared_recording/src/main.rs?speculative-link
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/shared_recording/main.cpp?speculative-link
---
<!--[metadata]
title = "Shared Recording"
-->


<picture>
<img src="https://static.rerun.io/shared_recording/c3da85f1d4c158b8c7afb6bd3278db000b58049d/full.png" alt="">
Expand Down
12 changes: 5 additions & 7 deletions examples/cpp/spawn_viewer/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
title: Spawn Viewer
tags: [spawn]
c: https://github.com/rerun-io/rerun/tree/latest/examples/c/spawn_viewer/main.c
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/spawn_viewer/main.cpp
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/spawn_viewer/src/main.rs
---
<!--[metadata]
title = "Spawn Viewer"
tags = ["spawn"]
-->


Shows how to spawn a new Rerun Viewer process ready to listen for TCP connections using an executable available in PATH.

Expand Down
12 changes: 5 additions & 7 deletions examples/cpp/stdio/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
title: Standard Input/Output example
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/stdio/main.py?speculative-link
rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/stdio/src/main.rs?speculative-link
cpp: https://github.com/rerun-io/rerun/tree/latest/examples/cpp/stdio/main.cpp?speculative-link
thumbnail: https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/480w.png
---
<!--[metadata]
title = "Standard Input/Output example"
thumbnail = "https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/480w.png"
-->


<picture>
<img src="https://static.rerun.io/stdio/25c5aba992d4c8b3861386d8d9539a4823dca117/full.png" alt="">
Expand Down
15 changes: 8 additions & 7 deletions examples/cpp/vrs/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: "VRS Viewer"
cpp: https://github.com/rerun-io/cpp-example-vrs
tags: [2D, 3D, vrs, viewer, C++]
thumbnail: https://static.rerun.io/cpp-example-vrs/c765460d4448da27bb9ee2a2a15f092f82a402d2/480w.png
thumbnail_dimensions: [480, 286]
---
<!--[metadata]
title = "VRS Viewer"
source = "https://github.com/rerun-io/cpp-example-vrs"
tags = ["2D", "3D", "vrs", "viewer", "C++"]
thumbnail = "https://static.rerun.io/cpp-example-vrs/c765460d4448da27bb9ee2a2a15f092f82a402d2/480w.png"
thumbnail_dimensions = [480, 286]
-->


This is an example that shows how to use [Rerun](https://github.com/rerun-io/rerun)'s C++ API to log and view [VRS](https://github.com/facebookresearch/vrs) files.

Expand Down
Loading
Loading