diff --git a/Cargo.lock b/Cargo.lock index 933521edd77c..f177d5ce317b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5434,6 +5434,13 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "template" +version = "0.7.0-alpha.0" +dependencies = [ + "rerun", +] + [[package]] name = "termcolor" version = "1.2.0" diff --git a/examples/README.md b/examples/README.md index cea065d6adcc..9cbb53dd8292 100644 --- a/examples/README.md +++ b/examples/README.md @@ -41,3 +41,8 @@ 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. + +## 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). diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt index 7d1e104a8477..4859da7e8a65 100644 --- a/examples/python/requirements.txt +++ b/examples/python/requirements.txt @@ -23,4 +23,5 @@ -r segment_anything_model/requirements.txt -r signed_distance_fields/requirements.txt -r structure_from_motion/requirements.txt --r text_logging/requirements.txt +-r template/requirements.txt +-r text_logging/requirements.txt \ No newline at end of file diff --git a/examples/python/template/README.md b/examples/python/template/README.md new file mode 100644 index 000000000000..e7f5a34757ec --- /dev/null +++ b/examples/python/template/README.md @@ -0,0 +1,18 @@ +--- +title: Template +tags: [kebab-case, comma, separated] +python: https://github.com/rerun-io/rerun/tree/latest/examples/python/template/main.py +rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/template/src/main.rs +--- + + + +This is an example example. It is not a real example. You can duplicate the directory and use it as a starting point for writing a real example. + +```bash +pip install -r examples/python/template/requirements.txt +python examples/python/template/main.py +``` diff --git a/examples/python/template/main.py b/examples/python/template/main.py new file mode 100755 index 000000000000..5172aa9fb596 --- /dev/null +++ b/examples/python/template/main.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +""" +Example template. + +Run: +```sh +pip install -r examples/python/template/requirements.txt +python examples/python/template/main.py +``` +""" +from __future__ import annotations + +import argparse + +import rerun as rr # pip install rerun-sdk + + +def main() -> None: + parser = argparse.ArgumentParser(description="Example of using the Rerun visualizer") + rr.script_add_args(parser) + args = parser.parse_args() + + rr.script_setup(args, "my_example_name") + + # ... example code + + rr.script_teardown(args) + + +if __name__ == "__main__": + main() diff --git a/examples/python/template/requirements.txt b/examples/python/template/requirements.txt new file mode 100644 index 000000000000..ebb847ff0d2d --- /dev/null +++ b/examples/python/template/requirements.txt @@ -0,0 +1 @@ +rerun-sdk diff --git a/examples/rust/template/Cargo.toml b/examples/rust/template/Cargo.toml new file mode 100644 index 000000000000..abe1f0e0b1ff --- /dev/null +++ b/examples/rust/template/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "template" +version = "0.7.0-alpha.0" +edition = "2021" +rust-version = "1.69" +license = "MIT OR Apache-2.0" +publish = false + +[dependencies] +rerun = { path = "../../../crates/rerun", features = ["native_viewer"] } diff --git a/examples/rust/template/README.md b/examples/rust/template/README.md new file mode 100644 index 000000000000..689500534e5d --- /dev/null +++ b/examples/rust/template/README.md @@ -0,0 +1,18 @@ +--- +title: Template +tags: [kebab-case, comma, separated] +python: https://github.com/rerun-io/rerun/tree/latest/examples/python/template/main.py +rust: https://github.com/rerun-io/rerun/tree/latest/examples/rust/template/src/main.rs +--- + + + +This is an example example. It is not a real example. You can duplicate the directory and use it as a starting point for writing a real example. + +```bash +cargo run --release -p template +``` + diff --git a/examples/rust/template/src/main.rs b/examples/rust/template/src/main.rs new file mode 100644 index 000000000000..b82da327fb85 --- /dev/null +++ b/examples/rust/template/src/main.rs @@ -0,0 +1,15 @@ +//! Example template. + +use rerun::RecordingStreamBuilder; + +fn main() -> Result<(), Box> { + let (rec_stream, storage) = RecordingStreamBuilder::new("my_example_name").memory()?; + + let _ = rec_stream; + + // ... example code + + rerun::native_viewer::show(storage.take())?; + + Ok(()) +}