From 2a41e5ff719ecf2b100e0cddb8012b2784cfdb32 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 10 Jan 2024 15:58:49 +0100 Subject: [PATCH] Combine all Rust `code-examples` into one binary (#4767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What * Part of https://github.com/rerun-io/rerun/issues/4623 * Sibling PR: https://github.com/rerun-io/landing/pull/611 This reduces the number of binaries in our workspace from 99 to 55. We do this by joining all `docs/code-examples` into one binary, with a little help from some `build.rs` codegen. This will any compiler error messages to the wrong file though, so it is not a perfect solution by any means. I also decided to put all the code examples in their own folder (`docs/code-examples/all`), with the control structures (`Cargo.toml`, `CMakeLists`, …) in the parent folder (`docs/code-examples`). If you have a better idea for a name than "all" I'm all ears. ### 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/4767/index.html) * Using examples from latest `main` build: [app.rerun.io](https://app.rerun.io/pr/4767/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/4767/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 - [PR Build Summary](https://build.rerun.io/pr/4767) - [Docs preview](https://rerun.io/preview/84e36319d1a5ff181c1b436bc6e75e7be42bc05d/docs) - [Examples preview](https://rerun.io/preview/84e36319d1a5ff181c1b436bc6e75e7be42bc05d/examples) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) --------- Co-authored-by: Andreas Reich --- .github/workflows/contrib_rerun_py.yml | 4 + .github/workflows/reusable_test_wheels.yml | 4 + Cargo.lock | 3 + crates/re_types/src/lib.rs | 2 +- .../src/bin/build_re_types.rs | 2 +- crates/re_types_builder/src/codegen/common.rs | 2 +- .../quick_start_connect.cpp | 2 +- .../quick_start_guides/quick_start_connect.py | 2 +- .../quick_start_guides/quick_start_connect.rs | 2 +- .../quick_start_guides/quick_start_spawn.py | 2 +- .../quick_start_guides/quick_start_spawn.rs | 2 +- docs/README.md | 11 +- docs/code-examples/CMakeLists.txt | 4 +- docs/code-examples/Cargo.toml | 186 +----------------- docs/code-examples/README.md | 9 +- .../{ => all}/annotation-context/example.py | 0 .../{ => all}/annotation-context/example.rs | 0 .../annotation_context_connections.cpp | 0 .../annotation_context_connections.py | 0 .../annotation_context_connections.rs | 0 .../{ => all}/annotation_context_rects.cpp | 0 .../{ => all}/annotation_context_rects.py | 0 .../{ => all}/annotation_context_rects.rs | 0 .../annotation_context_segmentation.cpp | 0 .../annotation_context_segmentation.py | 0 .../annotation_context_segmentation.rs | 0 docs/code-examples/{ => all}/any_values.py | 0 .../{ => all}/arrow2d_simple.cpp | 0 .../code-examples/{ => all}/arrow2d_simple.py | 0 .../code-examples/{ => all}/arrow2d_simple.rs | 0 .../{ => all}/arrow3d_simple.cpp | 0 .../code-examples/{ => all}/arrow3d_simple.py | 0 .../code-examples/{ => all}/arrow3d_simple.rs | 0 .../{ => all}/asset3d_out_of_tree.cpp | 0 .../{ => all}/asset3d_out_of_tree.py | 0 .../{ => all}/asset3d_out_of_tree.rs | 0 .../{ => all}/asset3d_simple.cpp | 0 .../code-examples/{ => all}/asset3d_simple.py | 0 .../code-examples/{ => all}/asset3d_simple.rs | 0 docs/code-examples/{ => all}/bar_chart.cpp | 0 docs/code-examples/{ => all}/bar_chart.py | 0 docs/code-examples/{ => all}/bar_chart.rs | 0 docs/code-examples/{ => all}/box2d_simple.cpp | 0 docs/code-examples/{ => all}/box2d_simple.py | 0 docs/code-examples/{ => all}/box2d_simple.rs | 0 docs/code-examples/{ => all}/box3d_batch.cpp | 0 docs/code-examples/{ => all}/box3d_batch.py | 0 docs/code-examples/{ => all}/box3d_batch.rs | 0 docs/code-examples/{ => all}/box3d_simple.cpp | 0 docs/code-examples/{ => all}/box3d_simple.py | 0 docs/code-examples/{ => all}/box3d_simple.rs | 0 .../{ => all}/clear_recursive.cpp | 0 .../{ => all}/clear_recursive.py | 0 .../{ => all}/clear_recursive.rs | 0 docs/code-examples/{ => all}/clear_simple.cpp | 0 docs/code-examples/{ => all}/clear_simple.py | 0 docs/code-examples/{ => all}/clear_simple.rs | 0 .../{ => all}/custom-recording-id/example.cpp | 0 .../{ => all}/custom-recording-id/example.py | 0 .../{ => all}/custom-recording-id/example.rs | 0 docs/code-examples/{ => all}/custom_data.cpp | 0 docs/code-examples/{ => all}/custom_data.py | 0 docs/code-examples/{ => all}/custom_data.rs | 0 .../{ => all}/default-off-session/example.py | 0 .../{ => all}/default-off-session/example.rs | 0 .../{ => all}/depth_image_3d.cpp | 0 .../code-examples/{ => all}/depth_image_3d.py | 0 .../code-examples/{ => all}/depth_image_3d.rs | 0 .../{ => all}/depth_image_simple.cpp | 0 .../{ => all}/depth_image_simple.py | 0 .../{ => all}/depth_image_simple.rs | 0 .../{ => all}/disconnected_space.cpp | 0 .../{ => all}/disconnected_space.py | 0 .../{ => all}/disconnected_space.rs | 0 docs/code-examples/{ => all}/entity_path.cpp | 0 docs/code-examples/{ => all}/entity_path.py | 0 docs/code-examples/{ => all}/entity_path.rs | 0 docs/code-examples/{ => all}/extra_values.py | 0 .../code-examples/{ => all}/image_advanced.py | 0 docs/code-examples/{ => all}/image_simple.cpp | 0 docs/code-examples/{ => all}/image_simple.py | 0 docs/code-examples/{ => all}/image_simple.rs | 0 .../{ => all}/line_segments2d_simple.cpp | 0 .../{ => all}/line_segments2d_simple.py | 0 .../{ => all}/line_segments2d_simple.rs | 0 .../{ => all}/line_segments3d_simple.cpp | 0 .../{ => all}/line_segments3d_simple.py | 0 .../{ => all}/line_segments3d_simple.rs | 0 .../{ => all}/line_strip2d_batch.cpp | 0 .../{ => all}/line_strip2d_batch.py | 0 .../{ => all}/line_strip2d_batch.rs | 0 .../{ => all}/line_strip2d_simple.cpp | 0 .../{ => all}/line_strip2d_simple.py | 0 .../{ => all}/line_strip2d_simple.rs | 0 .../{ => all}/line_strip3d_batch.cpp | 0 .../{ => all}/line_strip3d_batch.py | 0 .../{ => all}/line_strip3d_batch.rs | 0 .../{ => all}/line_strip3d_simple.cpp | 0 .../{ => all}/line_strip3d_simple.py | 0 .../{ => all}/line_strip3d_simple.rs | 0 docs/code-examples/{ => all}/log_line.py | 0 docs/code-examples/{ => all}/log_line.rs | 0 .../{ => all}/manual_indicator.cpp | 0 .../{ => all}/manual_indicator.py | 0 .../{ => all}/manual_indicator.rs | 0 .../{ => all}/mesh3d_indexed.cpp | 0 .../code-examples/{ => all}/mesh3d_indexed.py | 0 .../code-examples/{ => all}/mesh3d_indexed.rs | 0 .../{ => all}/mesh3d_partial_updates.cpp | 0 .../{ => all}/mesh3d_partial_updates.py | 0 .../{ => all}/mesh3d_partial_updates.rs | 0 .../code-examples/{ => all}/mesh3d_simple.cpp | 0 docs/code-examples/{ => all}/mesh3d_simple.py | 0 docs/code-examples/{ => all}/mesh3d_simple.rs | 0 .../{ => all}/pinhole_simple.cpp | 0 .../code-examples/{ => all}/pinhole_simple.py | 0 .../code-examples/{ => all}/pinhole_simple.rs | 0 .../{ => all}/point2d_random.cpp | 0 .../code-examples/{ => all}/point2d_random.py | 0 .../code-examples/{ => all}/point2d_random.rs | 0 .../{ => all}/point2d_simple.cpp | 0 .../code-examples/{ => all}/point2d_simple.py | 0 .../code-examples/{ => all}/point2d_simple.rs | 0 .../{ => all}/point3d_random.cpp | 0 .../code-examples/{ => all}/point3d_random.py | 0 .../code-examples/{ => all}/point3d_random.rs | 0 .../{ => all}/point3d_simple.cpp | 0 .../code-examples/{ => all}/point3d_simple.py | 0 .../code-examples/{ => all}/point3d_simple.rs | 0 .../{ => all}/quick_start_connect.cpp | 0 .../{ => all}/quick_start_connect.py | 0 .../{ => all}/quick_start_connect.rs | 0 .../{ => all}/quick_start_spawn.cpp | 0 .../{ => all}/quick_start_spawn.py | 0 .../{ => all}/quick_start_spawn.rs | 0 .../{ => all}/scalar_multiple_plots.cpp | 0 .../{ => all}/scalar_multiple_plots.py | 0 .../{ => all}/scalar_multiple_plots.rs | 0 .../code-examples/{ => all}/scalar_simple.cpp | 0 docs/code-examples/{ => all}/scalar_simple.py | 0 docs/code-examples/{ => all}/scalar_simple.rs | 0 .../{ => all}/segmentation_image_simple.cpp | 0 .../{ => all}/segmentation_image_simple.py | 0 .../{ => all}/segmentation_image_simple.rs | 0 .../code-examples/{ => all}/tensor_simple.cpp | 0 docs/code-examples/{ => all}/tensor_simple.py | 0 docs/code-examples/{ => all}/tensor_simple.rs | 0 .../code-examples/{ => all}/text_document.cpp | 0 docs/code-examples/{ => all}/text_document.py | 0 docs/code-examples/{ => all}/text_document.rs | 0 docs/code-examples/{ => all}/text_log.cpp | 0 docs/code-examples/{ => all}/text_log.py | 0 docs/code-examples/{ => all}/text_log.rs | 0 .../{ => all}/text_log_integration.cpp | 0 .../{ => all}/text_log_integration.py | 0 .../{ => all}/text_log_integration.rs | 0 .../{ => all}/timelines_example.cpp | 0 .../{ => all}/timelines_example.py | 0 .../{ => all}/timelines_example.rs | 0 .../{ => all}/transform3d_simple.cpp | 0 .../{ => all}/transform3d_simple.py | 0 .../{ => all}/transform3d_simple.rs | 0 .../{ => all}/view_coordinates_simple.cpp | 0 .../{ => all}/view_coordinates_simple.py | 0 .../{ => all}/view_coordinates_simple.rs | 0 docs/code-examples/build.rs | 119 +++++++++++ docs/code-examples/roundtrips.py | 31 ++- docs/code-examples/src/examples/.gitignore | 1 + docs/code-examples/src/lib.rs | 5 + docs/code-examples/src/main.rs | 6 + rerun_cpp/src/rerun/c/rerun.h | 2 +- rerun_py/pyproject.toml | 6 +- 172 files changed, 185 insertions(+), 222 deletions(-) rename docs/code-examples/{ => all}/annotation-context/example.py (100%) rename docs/code-examples/{ => all}/annotation-context/example.rs (100%) rename docs/code-examples/{ => all}/annotation_context_connections.cpp (100%) rename docs/code-examples/{ => all}/annotation_context_connections.py (100%) rename docs/code-examples/{ => all}/annotation_context_connections.rs (100%) rename docs/code-examples/{ => all}/annotation_context_rects.cpp (100%) rename docs/code-examples/{ => all}/annotation_context_rects.py (100%) rename docs/code-examples/{ => all}/annotation_context_rects.rs (100%) rename docs/code-examples/{ => all}/annotation_context_segmentation.cpp (100%) rename docs/code-examples/{ => all}/annotation_context_segmentation.py (100%) rename docs/code-examples/{ => all}/annotation_context_segmentation.rs (100%) rename docs/code-examples/{ => all}/any_values.py (100%) rename docs/code-examples/{ => all}/arrow2d_simple.cpp (100%) rename docs/code-examples/{ => all}/arrow2d_simple.py (100%) rename docs/code-examples/{ => all}/arrow2d_simple.rs (100%) rename docs/code-examples/{ => all}/arrow3d_simple.cpp (100%) rename docs/code-examples/{ => all}/arrow3d_simple.py (100%) rename docs/code-examples/{ => all}/arrow3d_simple.rs (100%) rename docs/code-examples/{ => all}/asset3d_out_of_tree.cpp (100%) rename docs/code-examples/{ => all}/asset3d_out_of_tree.py (100%) rename docs/code-examples/{ => all}/asset3d_out_of_tree.rs (100%) rename docs/code-examples/{ => all}/asset3d_simple.cpp (100%) rename docs/code-examples/{ => all}/asset3d_simple.py (100%) rename docs/code-examples/{ => all}/asset3d_simple.rs (100%) rename docs/code-examples/{ => all}/bar_chart.cpp (100%) rename docs/code-examples/{ => all}/bar_chart.py (100%) rename docs/code-examples/{ => all}/bar_chart.rs (100%) rename docs/code-examples/{ => all}/box2d_simple.cpp (100%) rename docs/code-examples/{ => all}/box2d_simple.py (100%) rename docs/code-examples/{ => all}/box2d_simple.rs (100%) rename docs/code-examples/{ => all}/box3d_batch.cpp (100%) rename docs/code-examples/{ => all}/box3d_batch.py (100%) rename docs/code-examples/{ => all}/box3d_batch.rs (100%) rename docs/code-examples/{ => all}/box3d_simple.cpp (100%) rename docs/code-examples/{ => all}/box3d_simple.py (100%) rename docs/code-examples/{ => all}/box3d_simple.rs (100%) rename docs/code-examples/{ => all}/clear_recursive.cpp (100%) rename docs/code-examples/{ => all}/clear_recursive.py (100%) rename docs/code-examples/{ => all}/clear_recursive.rs (100%) rename docs/code-examples/{ => all}/clear_simple.cpp (100%) rename docs/code-examples/{ => all}/clear_simple.py (100%) rename docs/code-examples/{ => all}/clear_simple.rs (100%) rename docs/code-examples/{ => all}/custom-recording-id/example.cpp (100%) rename docs/code-examples/{ => all}/custom-recording-id/example.py (100%) rename docs/code-examples/{ => all}/custom-recording-id/example.rs (100%) rename docs/code-examples/{ => all}/custom_data.cpp (100%) rename docs/code-examples/{ => all}/custom_data.py (100%) rename docs/code-examples/{ => all}/custom_data.rs (100%) rename docs/code-examples/{ => all}/default-off-session/example.py (100%) rename docs/code-examples/{ => all}/default-off-session/example.rs (100%) rename docs/code-examples/{ => all}/depth_image_3d.cpp (100%) rename docs/code-examples/{ => all}/depth_image_3d.py (100%) rename docs/code-examples/{ => all}/depth_image_3d.rs (100%) rename docs/code-examples/{ => all}/depth_image_simple.cpp (100%) rename docs/code-examples/{ => all}/depth_image_simple.py (100%) rename docs/code-examples/{ => all}/depth_image_simple.rs (100%) rename docs/code-examples/{ => all}/disconnected_space.cpp (100%) rename docs/code-examples/{ => all}/disconnected_space.py (100%) rename docs/code-examples/{ => all}/disconnected_space.rs (100%) rename docs/code-examples/{ => all}/entity_path.cpp (100%) rename docs/code-examples/{ => all}/entity_path.py (100%) rename docs/code-examples/{ => all}/entity_path.rs (100%) rename docs/code-examples/{ => all}/extra_values.py (100%) rename docs/code-examples/{ => all}/image_advanced.py (100%) rename docs/code-examples/{ => all}/image_simple.cpp (100%) rename docs/code-examples/{ => all}/image_simple.py (100%) rename docs/code-examples/{ => all}/image_simple.rs (100%) rename docs/code-examples/{ => all}/line_segments2d_simple.cpp (100%) rename docs/code-examples/{ => all}/line_segments2d_simple.py (100%) rename docs/code-examples/{ => all}/line_segments2d_simple.rs (100%) rename docs/code-examples/{ => all}/line_segments3d_simple.cpp (100%) rename docs/code-examples/{ => all}/line_segments3d_simple.py (100%) rename docs/code-examples/{ => all}/line_segments3d_simple.rs (100%) rename docs/code-examples/{ => all}/line_strip2d_batch.cpp (100%) rename docs/code-examples/{ => all}/line_strip2d_batch.py (100%) rename docs/code-examples/{ => all}/line_strip2d_batch.rs (100%) rename docs/code-examples/{ => all}/line_strip2d_simple.cpp (100%) rename docs/code-examples/{ => all}/line_strip2d_simple.py (100%) rename docs/code-examples/{ => all}/line_strip2d_simple.rs (100%) rename docs/code-examples/{ => all}/line_strip3d_batch.cpp (100%) rename docs/code-examples/{ => all}/line_strip3d_batch.py (100%) rename docs/code-examples/{ => all}/line_strip3d_batch.rs (100%) rename docs/code-examples/{ => all}/line_strip3d_simple.cpp (100%) rename docs/code-examples/{ => all}/line_strip3d_simple.py (100%) rename docs/code-examples/{ => all}/line_strip3d_simple.rs (100%) rename docs/code-examples/{ => all}/log_line.py (100%) rename docs/code-examples/{ => all}/log_line.rs (100%) rename docs/code-examples/{ => all}/manual_indicator.cpp (100%) rename docs/code-examples/{ => all}/manual_indicator.py (100%) rename docs/code-examples/{ => all}/manual_indicator.rs (100%) rename docs/code-examples/{ => all}/mesh3d_indexed.cpp (100%) rename docs/code-examples/{ => all}/mesh3d_indexed.py (100%) rename docs/code-examples/{ => all}/mesh3d_indexed.rs (100%) rename docs/code-examples/{ => all}/mesh3d_partial_updates.cpp (100%) rename docs/code-examples/{ => all}/mesh3d_partial_updates.py (100%) rename docs/code-examples/{ => all}/mesh3d_partial_updates.rs (100%) rename docs/code-examples/{ => all}/mesh3d_simple.cpp (100%) rename docs/code-examples/{ => all}/mesh3d_simple.py (100%) rename docs/code-examples/{ => all}/mesh3d_simple.rs (100%) rename docs/code-examples/{ => all}/pinhole_simple.cpp (100%) rename docs/code-examples/{ => all}/pinhole_simple.py (100%) rename docs/code-examples/{ => all}/pinhole_simple.rs (100%) rename docs/code-examples/{ => all}/point2d_random.cpp (100%) rename docs/code-examples/{ => all}/point2d_random.py (100%) rename docs/code-examples/{ => all}/point2d_random.rs (100%) rename docs/code-examples/{ => all}/point2d_simple.cpp (100%) rename docs/code-examples/{ => all}/point2d_simple.py (100%) rename docs/code-examples/{ => all}/point2d_simple.rs (100%) rename docs/code-examples/{ => all}/point3d_random.cpp (100%) rename docs/code-examples/{ => all}/point3d_random.py (100%) rename docs/code-examples/{ => all}/point3d_random.rs (100%) rename docs/code-examples/{ => all}/point3d_simple.cpp (100%) rename docs/code-examples/{ => all}/point3d_simple.py (100%) rename docs/code-examples/{ => all}/point3d_simple.rs (100%) rename docs/code-examples/{ => all}/quick_start_connect.cpp (100%) rename docs/code-examples/{ => all}/quick_start_connect.py (100%) rename docs/code-examples/{ => all}/quick_start_connect.rs (100%) rename docs/code-examples/{ => all}/quick_start_spawn.cpp (100%) rename docs/code-examples/{ => all}/quick_start_spawn.py (100%) rename docs/code-examples/{ => all}/quick_start_spawn.rs (100%) rename docs/code-examples/{ => all}/scalar_multiple_plots.cpp (100%) rename docs/code-examples/{ => all}/scalar_multiple_plots.py (100%) rename docs/code-examples/{ => all}/scalar_multiple_plots.rs (100%) rename docs/code-examples/{ => all}/scalar_simple.cpp (100%) rename docs/code-examples/{ => all}/scalar_simple.py (100%) rename docs/code-examples/{ => all}/scalar_simple.rs (100%) rename docs/code-examples/{ => all}/segmentation_image_simple.cpp (100%) rename docs/code-examples/{ => all}/segmentation_image_simple.py (100%) rename docs/code-examples/{ => all}/segmentation_image_simple.rs (100%) rename docs/code-examples/{ => all}/tensor_simple.cpp (100%) rename docs/code-examples/{ => all}/tensor_simple.py (100%) rename docs/code-examples/{ => all}/tensor_simple.rs (100%) rename docs/code-examples/{ => all}/text_document.cpp (100%) rename docs/code-examples/{ => all}/text_document.py (100%) rename docs/code-examples/{ => all}/text_document.rs (100%) rename docs/code-examples/{ => all}/text_log.cpp (100%) rename docs/code-examples/{ => all}/text_log.py (100%) rename docs/code-examples/{ => all}/text_log.rs (100%) rename docs/code-examples/{ => all}/text_log_integration.cpp (100%) rename docs/code-examples/{ => all}/text_log_integration.py (100%) rename docs/code-examples/{ => all}/text_log_integration.rs (100%) rename docs/code-examples/{ => all}/timelines_example.cpp (100%) rename docs/code-examples/{ => all}/timelines_example.py (100%) rename docs/code-examples/{ => all}/timelines_example.rs (100%) rename docs/code-examples/{ => all}/transform3d_simple.cpp (100%) rename docs/code-examples/{ => all}/transform3d_simple.py (100%) rename docs/code-examples/{ => all}/transform3d_simple.rs (100%) rename docs/code-examples/{ => all}/view_coordinates_simple.cpp (100%) rename docs/code-examples/{ => all}/view_coordinates_simple.py (100%) rename docs/code-examples/{ => all}/view_coordinates_simple.rs (100%) create mode 100644 docs/code-examples/build.rs create mode 100644 docs/code-examples/src/examples/.gitignore create mode 100644 docs/code-examples/src/lib.rs create mode 100644 docs/code-examples/src/main.rs diff --git a/.github/workflows/contrib_rerun_py.yml b/.github/workflows/contrib_rerun_py.yml index 18758db6d6ce..d960a1c2932c 100644 --- a/.github/workflows/contrib_rerun_py.yml +++ b/.github/workflows/contrib_rerun_py.yml @@ -40,6 +40,10 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: prefix-dev/setup-pixi@v0.4.1 + with: + pixi-version: v0.6.0 + # These should already be in the docker container, but run for good measure. A no-op install # should be fast, and this way things don't break if we add new packages without rebuilding # docker diff --git a/.github/workflows/reusable_test_wheels.yml b/.github/workflows/reusable_test_wheels.yml index edd7ae534543..5fef8d6fca9e 100644 --- a/.github/workflows/reusable_test_wheels.yml +++ b/.github/workflows/reusable_test_wheels.yml @@ -121,6 +121,10 @@ jobs: workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} + - uses: prefix-dev/setup-pixi@v0.4.1 + with: + pixi-version: v0.6.0 + # The pip-cache setup logic doesn't work in the ubuntu docker container # That's probably fine since we bake these deps into the container already - name: Setup python diff --git a/Cargo.lock b/Cargo.lock index d937239588d9..a4a8cf9c1ac4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1130,9 +1130,12 @@ dependencies = [ name = "code_examples" version = "0.13.0-alpha.1+dev" dependencies = [ + "itertools 0.12.0", "ndarray", "rand", + "re_build_tools", "rerun", + "rust-format", ] [[package]] diff --git a/crates/re_types/src/lib.rs b/crates/re_types/src/lib.rs index d59bc5c6e5cb..c78ed6f89a2e 100644 --- a/crates/re_types/src/lib.rs +++ b/crates/re_types/src/lib.rs @@ -100,7 +100,7 @@ //! //! ### Examples //! -//! You can add an example to `docs/code-examples`, and then include its source code in +//! You can add an example to `docs/code-examples/all`, and then include its source code in //! the docs using the `\example` tag. The example will also be included in the list of //! examples for type's generated docs. //! diff --git a/crates/re_types_builder/src/bin/build_re_types.rs b/crates/re_types_builder/src/bin/build_re_types.rs index 7bc030e6b8dc..56e44f8e6a63 100644 --- a/crates/re_types_builder/src/bin/build_re_types.rs +++ b/crates/re_types_builder/src/bin/build_re_types.rs @@ -13,7 +13,7 @@ use camino::Utf8Path; const RE_TYPES_SOURCE_HASH_PATH: &str = "crates/re_types/source_hash.txt"; const DEFINITIONS_DIR_PATH: &str = "crates/re_types/definitions"; const ENTRYPOINT_PATH: &str = "crates/re_types/definitions/rerun/archetypes.fbs"; -const DOC_EXAMPLES_DIR_PATH: &str = "docs/code-examples"; +const DOC_EXAMPLES_DIR_PATH: &str = "docs/code-examples/all"; const CPP_OUTPUT_DIR_PATH: &str = "rerun_cpp"; const PYTHON_OUTPUT_DIR_PATH: &str = "rerun_py/rerun_sdk/rerun"; const PYTHON_TESTING_OUTPUT_DIR_PATH: &str = "rerun_py/tests/test_types"; diff --git a/crates/re_types_builder/src/codegen/common.rs b/crates/re_types_builder/src/codegen/common.rs index f7b0cfeafec4..b6c87199ae85 100644 --- a/crates/re_types_builder/src/codegen/common.rs +++ b/crates/re_types_builder/src/codegen/common.rs @@ -250,7 +250,7 @@ pub fn collect_examples_for_api_docs<'a>( let mut out = Vec::new(); if let Some(examples) = docs.tagged_docs.get("example") { - let base_path = crate::rerun_workspace_path().join("docs/code-examples"); + let base_path = crate::rerun_workspace_path().join("docs/code-examples/all"); for base @ ExampleInfo { name, diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp b/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp index 2b9e140cfbfc..6e50ed1f948e 120000 --- a/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp +++ b/crates/re_viewer/data/quick_start_guides/quick_start_connect.cpp @@ -1 +1 @@ -../../../../docs/code-examples/quick_start_connect.cpp \ No newline at end of file +../../../../docs/code-examples/all/quick_start_connect.cpp \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_connect.py b/crates/re_viewer/data/quick_start_guides/quick_start_connect.py index b64a5733fea1..f319284a41ce 120000 --- a/crates/re_viewer/data/quick_start_guides/quick_start_connect.py +++ b/crates/re_viewer/data/quick_start_guides/quick_start_connect.py @@ -1 +1 @@ -../../../../docs/code-examples/quick_start_connect.py \ No newline at end of file +../../../../docs/code-examples/all/quick_start_connect.py \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs b/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs index 8458ae676f31..f6e9d25d3ac9 120000 --- a/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs +++ b/crates/re_viewer/data/quick_start_guides/quick_start_connect.rs @@ -1 +1 @@ -../../../../docs/code-examples/quick_start_connect.rs \ No newline at end of file +../../../../docs/code-examples/all/quick_start_connect.rs \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_spawn.py b/crates/re_viewer/data/quick_start_guides/quick_start_spawn.py index e8205384be6b..f6eb369d0a16 120000 --- a/crates/re_viewer/data/quick_start_guides/quick_start_spawn.py +++ b/crates/re_viewer/data/quick_start_guides/quick_start_spawn.py @@ -1 +1 @@ -../../../../docs/code-examples/quick_start_spawn.py \ No newline at end of file +../../../../docs/code-examples/all/quick_start_spawn.py \ No newline at end of file diff --git a/crates/re_viewer/data/quick_start_guides/quick_start_spawn.rs b/crates/re_viewer/data/quick_start_guides/quick_start_spawn.rs index aa48865aa700..36e9929496ed 120000 --- a/crates/re_viewer/data/quick_start_guides/quick_start_spawn.rs +++ b/crates/re_viewer/data/quick_start_guides/quick_start_spawn.rs @@ -1 +1 @@ -../../../../docs/code-examples/quick_start_spawn.rs \ No newline at end of file +../../../../docs/code-examples/all/quick_start_spawn.rs \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 1bd25f322b48..e12be7f6f3fd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,14 +14,15 @@ The site documentation lives in Markdown files inside [`/content`](./content). The entry point to the documentation is [`/content/index.md`](./content/index.md) -Code examples can be rendered in multiple languages by placing them in `code-examples`, like so: +Code examples can be rendered in multiple languages by placing them in `code-examples/all`, like so: ``` /docs - /code-examples - /my-example - /example.py - /example.rs + /code-examples + /all + /my-example + /example.py + /example.rs ``` ## Special syntax diff --git a/docs/code-examples/CMakeLists.txt b/docs/code-examples/CMakeLists.txt index 2b207eb46b3b..fc91f67ec1b0 100644 --- a/docs/code-examples/CMakeLists.txt +++ b/docs/code-examples/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.16...3.27) # Setup builds for examples -file(GLOB sources_list true ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file(GLOB sources_list true ${CMAKE_CURRENT_SOURCE_DIR}/all/*.cpp) # TODO(ab): incomplete code, need hideable stubs, see https://github.com/rerun-io/landing/issues/515 -list(REMOVE_ITEM sources_list ${CMAKE_CURRENT_SOURCE_DIR}/timelines_example.cpp) +list(REMOVE_ITEM sources_list ${CMAKE_CURRENT_SOURCE_DIR}/all/timelines_example.cpp) add_custom_target(doc_examples) diff --git a/docs/code-examples/Cargo.toml b/docs/code-examples/Cargo.toml index 822f7b0e3b33..6b185db8136e 100644 --- a/docs/code-examples/Cargo.toml +++ b/docs/code-examples/Cargo.toml @@ -6,188 +6,12 @@ rust-version.workspace = true license.workspace = true publish = false - -[[bin]] -name = "annotation_context_connections" -path = "annotation_context_connections.rs" - -[[bin]] -name = "annotation_context_rects" -path = "annotation_context_rects.rs" - -[[bin]] -name = "annotation_context_segmentation" -path = "annotation_context_segmentation.rs" - -[[bin]] -name = "arrow2d_simple" -path = "arrow2d_simple.rs" - -[[bin]] -name = "arrow3d_simple" -path = "arrow3d_simple.rs" - -[[bin]] -name = "bar_chart" -path = "bar_chart.rs" - -[[bin]] -name = "asset3d_simple" -path = "asset3d_simple.rs" - -[[bin]] -name = "asset3d_out_of_tree" -path = "asset3d_out_of_tree.rs" - -[[bin]] -name = "box2d_simple" -path = "box2d_simple.rs" - -[[bin]] -name = "box3d_simple" -path = "box3d_simple.rs" - -[[bin]] -name = "box3d_batch" -path = "box3d_batch.rs" - -[[bin]] -name = "clear_recursive" -path = "clear_recursive.rs" - -[[bin]] -name = "clear_simple" -path = "clear_simple.rs" - -[[bin]] -name = "custom_data" -path = "custom_data.rs" - -[[bin]] -name = "depth_image_3d" -path = "depth_image_3d.rs" - -[[bin]] -name = "depth_image_simple" -path = "depth_image_simple.rs" - -[[bin]] -name = "disconnected_space" -path = "disconnected_space.rs" - -[[bin]] -name = "entity_path" -path = "entity_path.rs" - -[[bin]] -name = "image_simple" -path = "image_simple.rs" - -[[bin]] -name = "line_segments2d_simple" -path = "line_segments2d_simple.rs" - -[[bin]] -name = "line_segments3d_simple" -path = "line_segments3d_simple.rs" - -[[bin]] -name = "line_strip2d_simple" -path = "line_strip2d_simple.rs" - -[[bin]] -name = "line_strip2d_batch" -path = "line_strip2d_batch.rs" - -[[bin]] -name = "line_strip3d_simple" -path = "line_strip3d_simple.rs" - -[[bin]] -name = "line_strip3d_batch" -path = "line_strip3d_batch.rs" - -[[bin]] -name = "manual_indicator" -path = "manual_indicator.rs" - -[[bin]] -name = "mesh3d_simple" -path = "mesh3d_simple.rs" - -[[bin]] -name = "mesh3d_indexed" -path = "mesh3d_indexed.rs" - -[[bin]] -name = "mesh3d_partial_updates" -path = "mesh3d_partial_updates.rs" - -[[bin]] -name = "pinhole_simple" -path = "pinhole_simple.rs" - -[[bin]] -name = "point2d_simple" -path = "point2d_simple.rs" - -[[bin]] -name = "point2d_random" -path = "point2d_random.rs" - -[[bin]] -name = "point3d_random" -path = "point3d_random.rs" - -[[bin]] -name = "point3d_simple" -path = "point3d_simple.rs" - -[[bin]] -name = "quick_start_connect" -path = "quick_start_connect.rs" - -[[bin]] -name = "quick_start_spawn" -path = "quick_start_spawn.rs" - -[[bin]] -name = "scalar_simple" -path = "scalar_simple.rs" - -[[bin]] -name = "scalar_multiple_plots" -path = "scalar_multiple_plots.rs" - -[[bin]] -name = "segmentation_image_simple" -path = "segmentation_image_simple.rs" - -[[bin]] -name = "tensor_simple" -path = "tensor_simple.rs" - -[[bin]] -name = "text_document" -path = "text_document.rs" - -[[bin]] -name = "text_log" -path = "text_log.rs" - -[[bin]] -name = "text_log_integration" -path = "text_log_integration.rs" - -[[bin]] -name = "transform3d_simple" -path = "transform3d_simple.rs" - -[[bin]] -name = "view_coordinates_simple" -path = "view_coordinates_simple.rs" - [dependencies] ndarray.workspace = true rand.workspace = true rerun = { path = "../../crates/rerun" } + +[build-dependencies] +itertools.workspace = true +re_build_tools.workspace = true +rust-format.workspace = true diff --git a/docs/code-examples/README.md b/docs/code-examples/README.md index eeb35eda695b..0de54aef88dc 100644 --- a/docs/code-examples/README.md +++ b/docs/code-examples/README.md @@ -9,10 +9,10 @@ Most of these examples are automatically used as docstrings for the `Archetype` You can run each example individually using the following: - **C++**: - - `pixi run cpp-build-examples` to compile all examples - - `./build/docs/code-examples/` to run, e.g. `./build/docs/code-examples/point3d_random` + - `pixi run cpp-build-doc-examples` to compile all examples + - `./build/docs/code-examples/all/` to run, e.g. `./build/docs/code-examples/all/point3d_random` - **Python**: `python .py`, e.g. `python point3d_random.py`. -- **Rust**: `cargo r -p code_examples --bin [args]`, e.g. `cargo run -p code_examples -- point3d_random`. ## Roundtrips @@ -31,6 +31,3 @@ To run the roundtrip tests, check out `./docs/code-examples/roundtrips.py --help Just pick a name for your test, and look at existing examples to get started. The `app_id` must be `rerun_example_`. The roundtrip process is driven by file names, so make sure all 3 tests use the same name: `.rs`, `.cpp`, `.py`. - -For Rust, also make sure to declare the new binary in `docs/code-examples/Cargo.toml`. - diff --git a/docs/code-examples/annotation-context/example.py b/docs/code-examples/all/annotation-context/example.py similarity index 100% rename from docs/code-examples/annotation-context/example.py rename to docs/code-examples/all/annotation-context/example.py diff --git a/docs/code-examples/annotation-context/example.rs b/docs/code-examples/all/annotation-context/example.rs similarity index 100% rename from docs/code-examples/annotation-context/example.rs rename to docs/code-examples/all/annotation-context/example.rs diff --git a/docs/code-examples/annotation_context_connections.cpp b/docs/code-examples/all/annotation_context_connections.cpp similarity index 100% rename from docs/code-examples/annotation_context_connections.cpp rename to docs/code-examples/all/annotation_context_connections.cpp diff --git a/docs/code-examples/annotation_context_connections.py b/docs/code-examples/all/annotation_context_connections.py similarity index 100% rename from docs/code-examples/annotation_context_connections.py rename to docs/code-examples/all/annotation_context_connections.py diff --git a/docs/code-examples/annotation_context_connections.rs b/docs/code-examples/all/annotation_context_connections.rs similarity index 100% rename from docs/code-examples/annotation_context_connections.rs rename to docs/code-examples/all/annotation_context_connections.rs diff --git a/docs/code-examples/annotation_context_rects.cpp b/docs/code-examples/all/annotation_context_rects.cpp similarity index 100% rename from docs/code-examples/annotation_context_rects.cpp rename to docs/code-examples/all/annotation_context_rects.cpp diff --git a/docs/code-examples/annotation_context_rects.py b/docs/code-examples/all/annotation_context_rects.py similarity index 100% rename from docs/code-examples/annotation_context_rects.py rename to docs/code-examples/all/annotation_context_rects.py diff --git a/docs/code-examples/annotation_context_rects.rs b/docs/code-examples/all/annotation_context_rects.rs similarity index 100% rename from docs/code-examples/annotation_context_rects.rs rename to docs/code-examples/all/annotation_context_rects.rs diff --git a/docs/code-examples/annotation_context_segmentation.cpp b/docs/code-examples/all/annotation_context_segmentation.cpp similarity index 100% rename from docs/code-examples/annotation_context_segmentation.cpp rename to docs/code-examples/all/annotation_context_segmentation.cpp diff --git a/docs/code-examples/annotation_context_segmentation.py b/docs/code-examples/all/annotation_context_segmentation.py similarity index 100% rename from docs/code-examples/annotation_context_segmentation.py rename to docs/code-examples/all/annotation_context_segmentation.py diff --git a/docs/code-examples/annotation_context_segmentation.rs b/docs/code-examples/all/annotation_context_segmentation.rs similarity index 100% rename from docs/code-examples/annotation_context_segmentation.rs rename to docs/code-examples/all/annotation_context_segmentation.rs diff --git a/docs/code-examples/any_values.py b/docs/code-examples/all/any_values.py similarity index 100% rename from docs/code-examples/any_values.py rename to docs/code-examples/all/any_values.py diff --git a/docs/code-examples/arrow2d_simple.cpp b/docs/code-examples/all/arrow2d_simple.cpp similarity index 100% rename from docs/code-examples/arrow2d_simple.cpp rename to docs/code-examples/all/arrow2d_simple.cpp diff --git a/docs/code-examples/arrow2d_simple.py b/docs/code-examples/all/arrow2d_simple.py similarity index 100% rename from docs/code-examples/arrow2d_simple.py rename to docs/code-examples/all/arrow2d_simple.py diff --git a/docs/code-examples/arrow2d_simple.rs b/docs/code-examples/all/arrow2d_simple.rs similarity index 100% rename from docs/code-examples/arrow2d_simple.rs rename to docs/code-examples/all/arrow2d_simple.rs diff --git a/docs/code-examples/arrow3d_simple.cpp b/docs/code-examples/all/arrow3d_simple.cpp similarity index 100% rename from docs/code-examples/arrow3d_simple.cpp rename to docs/code-examples/all/arrow3d_simple.cpp diff --git a/docs/code-examples/arrow3d_simple.py b/docs/code-examples/all/arrow3d_simple.py similarity index 100% rename from docs/code-examples/arrow3d_simple.py rename to docs/code-examples/all/arrow3d_simple.py diff --git a/docs/code-examples/arrow3d_simple.rs b/docs/code-examples/all/arrow3d_simple.rs similarity index 100% rename from docs/code-examples/arrow3d_simple.rs rename to docs/code-examples/all/arrow3d_simple.rs diff --git a/docs/code-examples/asset3d_out_of_tree.cpp b/docs/code-examples/all/asset3d_out_of_tree.cpp similarity index 100% rename from docs/code-examples/asset3d_out_of_tree.cpp rename to docs/code-examples/all/asset3d_out_of_tree.cpp diff --git a/docs/code-examples/asset3d_out_of_tree.py b/docs/code-examples/all/asset3d_out_of_tree.py similarity index 100% rename from docs/code-examples/asset3d_out_of_tree.py rename to docs/code-examples/all/asset3d_out_of_tree.py diff --git a/docs/code-examples/asset3d_out_of_tree.rs b/docs/code-examples/all/asset3d_out_of_tree.rs similarity index 100% rename from docs/code-examples/asset3d_out_of_tree.rs rename to docs/code-examples/all/asset3d_out_of_tree.rs diff --git a/docs/code-examples/asset3d_simple.cpp b/docs/code-examples/all/asset3d_simple.cpp similarity index 100% rename from docs/code-examples/asset3d_simple.cpp rename to docs/code-examples/all/asset3d_simple.cpp diff --git a/docs/code-examples/asset3d_simple.py b/docs/code-examples/all/asset3d_simple.py similarity index 100% rename from docs/code-examples/asset3d_simple.py rename to docs/code-examples/all/asset3d_simple.py diff --git a/docs/code-examples/asset3d_simple.rs b/docs/code-examples/all/asset3d_simple.rs similarity index 100% rename from docs/code-examples/asset3d_simple.rs rename to docs/code-examples/all/asset3d_simple.rs diff --git a/docs/code-examples/bar_chart.cpp b/docs/code-examples/all/bar_chart.cpp similarity index 100% rename from docs/code-examples/bar_chart.cpp rename to docs/code-examples/all/bar_chart.cpp diff --git a/docs/code-examples/bar_chart.py b/docs/code-examples/all/bar_chart.py similarity index 100% rename from docs/code-examples/bar_chart.py rename to docs/code-examples/all/bar_chart.py diff --git a/docs/code-examples/bar_chart.rs b/docs/code-examples/all/bar_chart.rs similarity index 100% rename from docs/code-examples/bar_chart.rs rename to docs/code-examples/all/bar_chart.rs diff --git a/docs/code-examples/box2d_simple.cpp b/docs/code-examples/all/box2d_simple.cpp similarity index 100% rename from docs/code-examples/box2d_simple.cpp rename to docs/code-examples/all/box2d_simple.cpp diff --git a/docs/code-examples/box2d_simple.py b/docs/code-examples/all/box2d_simple.py similarity index 100% rename from docs/code-examples/box2d_simple.py rename to docs/code-examples/all/box2d_simple.py diff --git a/docs/code-examples/box2d_simple.rs b/docs/code-examples/all/box2d_simple.rs similarity index 100% rename from docs/code-examples/box2d_simple.rs rename to docs/code-examples/all/box2d_simple.rs diff --git a/docs/code-examples/box3d_batch.cpp b/docs/code-examples/all/box3d_batch.cpp similarity index 100% rename from docs/code-examples/box3d_batch.cpp rename to docs/code-examples/all/box3d_batch.cpp diff --git a/docs/code-examples/box3d_batch.py b/docs/code-examples/all/box3d_batch.py similarity index 100% rename from docs/code-examples/box3d_batch.py rename to docs/code-examples/all/box3d_batch.py diff --git a/docs/code-examples/box3d_batch.rs b/docs/code-examples/all/box3d_batch.rs similarity index 100% rename from docs/code-examples/box3d_batch.rs rename to docs/code-examples/all/box3d_batch.rs diff --git a/docs/code-examples/box3d_simple.cpp b/docs/code-examples/all/box3d_simple.cpp similarity index 100% rename from docs/code-examples/box3d_simple.cpp rename to docs/code-examples/all/box3d_simple.cpp diff --git a/docs/code-examples/box3d_simple.py b/docs/code-examples/all/box3d_simple.py similarity index 100% rename from docs/code-examples/box3d_simple.py rename to docs/code-examples/all/box3d_simple.py diff --git a/docs/code-examples/box3d_simple.rs b/docs/code-examples/all/box3d_simple.rs similarity index 100% rename from docs/code-examples/box3d_simple.rs rename to docs/code-examples/all/box3d_simple.rs diff --git a/docs/code-examples/clear_recursive.cpp b/docs/code-examples/all/clear_recursive.cpp similarity index 100% rename from docs/code-examples/clear_recursive.cpp rename to docs/code-examples/all/clear_recursive.cpp diff --git a/docs/code-examples/clear_recursive.py b/docs/code-examples/all/clear_recursive.py similarity index 100% rename from docs/code-examples/clear_recursive.py rename to docs/code-examples/all/clear_recursive.py diff --git a/docs/code-examples/clear_recursive.rs b/docs/code-examples/all/clear_recursive.rs similarity index 100% rename from docs/code-examples/clear_recursive.rs rename to docs/code-examples/all/clear_recursive.rs diff --git a/docs/code-examples/clear_simple.cpp b/docs/code-examples/all/clear_simple.cpp similarity index 100% rename from docs/code-examples/clear_simple.cpp rename to docs/code-examples/all/clear_simple.cpp diff --git a/docs/code-examples/clear_simple.py b/docs/code-examples/all/clear_simple.py similarity index 100% rename from docs/code-examples/clear_simple.py rename to docs/code-examples/all/clear_simple.py diff --git a/docs/code-examples/clear_simple.rs b/docs/code-examples/all/clear_simple.rs similarity index 100% rename from docs/code-examples/clear_simple.rs rename to docs/code-examples/all/clear_simple.rs diff --git a/docs/code-examples/custom-recording-id/example.cpp b/docs/code-examples/all/custom-recording-id/example.cpp similarity index 100% rename from docs/code-examples/custom-recording-id/example.cpp rename to docs/code-examples/all/custom-recording-id/example.cpp diff --git a/docs/code-examples/custom-recording-id/example.py b/docs/code-examples/all/custom-recording-id/example.py similarity index 100% rename from docs/code-examples/custom-recording-id/example.py rename to docs/code-examples/all/custom-recording-id/example.py diff --git a/docs/code-examples/custom-recording-id/example.rs b/docs/code-examples/all/custom-recording-id/example.rs similarity index 100% rename from docs/code-examples/custom-recording-id/example.rs rename to docs/code-examples/all/custom-recording-id/example.rs diff --git a/docs/code-examples/custom_data.cpp b/docs/code-examples/all/custom_data.cpp similarity index 100% rename from docs/code-examples/custom_data.cpp rename to docs/code-examples/all/custom_data.cpp diff --git a/docs/code-examples/custom_data.py b/docs/code-examples/all/custom_data.py similarity index 100% rename from docs/code-examples/custom_data.py rename to docs/code-examples/all/custom_data.py diff --git a/docs/code-examples/custom_data.rs b/docs/code-examples/all/custom_data.rs similarity index 100% rename from docs/code-examples/custom_data.rs rename to docs/code-examples/all/custom_data.rs diff --git a/docs/code-examples/default-off-session/example.py b/docs/code-examples/all/default-off-session/example.py similarity index 100% rename from docs/code-examples/default-off-session/example.py rename to docs/code-examples/all/default-off-session/example.py diff --git a/docs/code-examples/default-off-session/example.rs b/docs/code-examples/all/default-off-session/example.rs similarity index 100% rename from docs/code-examples/default-off-session/example.rs rename to docs/code-examples/all/default-off-session/example.rs diff --git a/docs/code-examples/depth_image_3d.cpp b/docs/code-examples/all/depth_image_3d.cpp similarity index 100% rename from docs/code-examples/depth_image_3d.cpp rename to docs/code-examples/all/depth_image_3d.cpp diff --git a/docs/code-examples/depth_image_3d.py b/docs/code-examples/all/depth_image_3d.py similarity index 100% rename from docs/code-examples/depth_image_3d.py rename to docs/code-examples/all/depth_image_3d.py diff --git a/docs/code-examples/depth_image_3d.rs b/docs/code-examples/all/depth_image_3d.rs similarity index 100% rename from docs/code-examples/depth_image_3d.rs rename to docs/code-examples/all/depth_image_3d.rs diff --git a/docs/code-examples/depth_image_simple.cpp b/docs/code-examples/all/depth_image_simple.cpp similarity index 100% rename from docs/code-examples/depth_image_simple.cpp rename to docs/code-examples/all/depth_image_simple.cpp diff --git a/docs/code-examples/depth_image_simple.py b/docs/code-examples/all/depth_image_simple.py similarity index 100% rename from docs/code-examples/depth_image_simple.py rename to docs/code-examples/all/depth_image_simple.py diff --git a/docs/code-examples/depth_image_simple.rs b/docs/code-examples/all/depth_image_simple.rs similarity index 100% rename from docs/code-examples/depth_image_simple.rs rename to docs/code-examples/all/depth_image_simple.rs diff --git a/docs/code-examples/disconnected_space.cpp b/docs/code-examples/all/disconnected_space.cpp similarity index 100% rename from docs/code-examples/disconnected_space.cpp rename to docs/code-examples/all/disconnected_space.cpp diff --git a/docs/code-examples/disconnected_space.py b/docs/code-examples/all/disconnected_space.py similarity index 100% rename from docs/code-examples/disconnected_space.py rename to docs/code-examples/all/disconnected_space.py diff --git a/docs/code-examples/disconnected_space.rs b/docs/code-examples/all/disconnected_space.rs similarity index 100% rename from docs/code-examples/disconnected_space.rs rename to docs/code-examples/all/disconnected_space.rs diff --git a/docs/code-examples/entity_path.cpp b/docs/code-examples/all/entity_path.cpp similarity index 100% rename from docs/code-examples/entity_path.cpp rename to docs/code-examples/all/entity_path.cpp diff --git a/docs/code-examples/entity_path.py b/docs/code-examples/all/entity_path.py similarity index 100% rename from docs/code-examples/entity_path.py rename to docs/code-examples/all/entity_path.py diff --git a/docs/code-examples/entity_path.rs b/docs/code-examples/all/entity_path.rs similarity index 100% rename from docs/code-examples/entity_path.rs rename to docs/code-examples/all/entity_path.rs diff --git a/docs/code-examples/extra_values.py b/docs/code-examples/all/extra_values.py similarity index 100% rename from docs/code-examples/extra_values.py rename to docs/code-examples/all/extra_values.py diff --git a/docs/code-examples/image_advanced.py b/docs/code-examples/all/image_advanced.py similarity index 100% rename from docs/code-examples/image_advanced.py rename to docs/code-examples/all/image_advanced.py diff --git a/docs/code-examples/image_simple.cpp b/docs/code-examples/all/image_simple.cpp similarity index 100% rename from docs/code-examples/image_simple.cpp rename to docs/code-examples/all/image_simple.cpp diff --git a/docs/code-examples/image_simple.py b/docs/code-examples/all/image_simple.py similarity index 100% rename from docs/code-examples/image_simple.py rename to docs/code-examples/all/image_simple.py diff --git a/docs/code-examples/image_simple.rs b/docs/code-examples/all/image_simple.rs similarity index 100% rename from docs/code-examples/image_simple.rs rename to docs/code-examples/all/image_simple.rs diff --git a/docs/code-examples/line_segments2d_simple.cpp b/docs/code-examples/all/line_segments2d_simple.cpp similarity index 100% rename from docs/code-examples/line_segments2d_simple.cpp rename to docs/code-examples/all/line_segments2d_simple.cpp diff --git a/docs/code-examples/line_segments2d_simple.py b/docs/code-examples/all/line_segments2d_simple.py similarity index 100% rename from docs/code-examples/line_segments2d_simple.py rename to docs/code-examples/all/line_segments2d_simple.py diff --git a/docs/code-examples/line_segments2d_simple.rs b/docs/code-examples/all/line_segments2d_simple.rs similarity index 100% rename from docs/code-examples/line_segments2d_simple.rs rename to docs/code-examples/all/line_segments2d_simple.rs diff --git a/docs/code-examples/line_segments3d_simple.cpp b/docs/code-examples/all/line_segments3d_simple.cpp similarity index 100% rename from docs/code-examples/line_segments3d_simple.cpp rename to docs/code-examples/all/line_segments3d_simple.cpp diff --git a/docs/code-examples/line_segments3d_simple.py b/docs/code-examples/all/line_segments3d_simple.py similarity index 100% rename from docs/code-examples/line_segments3d_simple.py rename to docs/code-examples/all/line_segments3d_simple.py diff --git a/docs/code-examples/line_segments3d_simple.rs b/docs/code-examples/all/line_segments3d_simple.rs similarity index 100% rename from docs/code-examples/line_segments3d_simple.rs rename to docs/code-examples/all/line_segments3d_simple.rs diff --git a/docs/code-examples/line_strip2d_batch.cpp b/docs/code-examples/all/line_strip2d_batch.cpp similarity index 100% rename from docs/code-examples/line_strip2d_batch.cpp rename to docs/code-examples/all/line_strip2d_batch.cpp diff --git a/docs/code-examples/line_strip2d_batch.py b/docs/code-examples/all/line_strip2d_batch.py similarity index 100% rename from docs/code-examples/line_strip2d_batch.py rename to docs/code-examples/all/line_strip2d_batch.py diff --git a/docs/code-examples/line_strip2d_batch.rs b/docs/code-examples/all/line_strip2d_batch.rs similarity index 100% rename from docs/code-examples/line_strip2d_batch.rs rename to docs/code-examples/all/line_strip2d_batch.rs diff --git a/docs/code-examples/line_strip2d_simple.cpp b/docs/code-examples/all/line_strip2d_simple.cpp similarity index 100% rename from docs/code-examples/line_strip2d_simple.cpp rename to docs/code-examples/all/line_strip2d_simple.cpp diff --git a/docs/code-examples/line_strip2d_simple.py b/docs/code-examples/all/line_strip2d_simple.py similarity index 100% rename from docs/code-examples/line_strip2d_simple.py rename to docs/code-examples/all/line_strip2d_simple.py diff --git a/docs/code-examples/line_strip2d_simple.rs b/docs/code-examples/all/line_strip2d_simple.rs similarity index 100% rename from docs/code-examples/line_strip2d_simple.rs rename to docs/code-examples/all/line_strip2d_simple.rs diff --git a/docs/code-examples/line_strip3d_batch.cpp b/docs/code-examples/all/line_strip3d_batch.cpp similarity index 100% rename from docs/code-examples/line_strip3d_batch.cpp rename to docs/code-examples/all/line_strip3d_batch.cpp diff --git a/docs/code-examples/line_strip3d_batch.py b/docs/code-examples/all/line_strip3d_batch.py similarity index 100% rename from docs/code-examples/line_strip3d_batch.py rename to docs/code-examples/all/line_strip3d_batch.py diff --git a/docs/code-examples/line_strip3d_batch.rs b/docs/code-examples/all/line_strip3d_batch.rs similarity index 100% rename from docs/code-examples/line_strip3d_batch.rs rename to docs/code-examples/all/line_strip3d_batch.rs diff --git a/docs/code-examples/line_strip3d_simple.cpp b/docs/code-examples/all/line_strip3d_simple.cpp similarity index 100% rename from docs/code-examples/line_strip3d_simple.cpp rename to docs/code-examples/all/line_strip3d_simple.cpp diff --git a/docs/code-examples/line_strip3d_simple.py b/docs/code-examples/all/line_strip3d_simple.py similarity index 100% rename from docs/code-examples/line_strip3d_simple.py rename to docs/code-examples/all/line_strip3d_simple.py diff --git a/docs/code-examples/line_strip3d_simple.rs b/docs/code-examples/all/line_strip3d_simple.rs similarity index 100% rename from docs/code-examples/line_strip3d_simple.rs rename to docs/code-examples/all/line_strip3d_simple.rs diff --git a/docs/code-examples/log_line.py b/docs/code-examples/all/log_line.py similarity index 100% rename from docs/code-examples/log_line.py rename to docs/code-examples/all/log_line.py diff --git a/docs/code-examples/log_line.rs b/docs/code-examples/all/log_line.rs similarity index 100% rename from docs/code-examples/log_line.rs rename to docs/code-examples/all/log_line.rs diff --git a/docs/code-examples/manual_indicator.cpp b/docs/code-examples/all/manual_indicator.cpp similarity index 100% rename from docs/code-examples/manual_indicator.cpp rename to docs/code-examples/all/manual_indicator.cpp diff --git a/docs/code-examples/manual_indicator.py b/docs/code-examples/all/manual_indicator.py similarity index 100% rename from docs/code-examples/manual_indicator.py rename to docs/code-examples/all/manual_indicator.py diff --git a/docs/code-examples/manual_indicator.rs b/docs/code-examples/all/manual_indicator.rs similarity index 100% rename from docs/code-examples/manual_indicator.rs rename to docs/code-examples/all/manual_indicator.rs diff --git a/docs/code-examples/mesh3d_indexed.cpp b/docs/code-examples/all/mesh3d_indexed.cpp similarity index 100% rename from docs/code-examples/mesh3d_indexed.cpp rename to docs/code-examples/all/mesh3d_indexed.cpp diff --git a/docs/code-examples/mesh3d_indexed.py b/docs/code-examples/all/mesh3d_indexed.py similarity index 100% rename from docs/code-examples/mesh3d_indexed.py rename to docs/code-examples/all/mesh3d_indexed.py diff --git a/docs/code-examples/mesh3d_indexed.rs b/docs/code-examples/all/mesh3d_indexed.rs similarity index 100% rename from docs/code-examples/mesh3d_indexed.rs rename to docs/code-examples/all/mesh3d_indexed.rs diff --git a/docs/code-examples/mesh3d_partial_updates.cpp b/docs/code-examples/all/mesh3d_partial_updates.cpp similarity index 100% rename from docs/code-examples/mesh3d_partial_updates.cpp rename to docs/code-examples/all/mesh3d_partial_updates.cpp diff --git a/docs/code-examples/mesh3d_partial_updates.py b/docs/code-examples/all/mesh3d_partial_updates.py similarity index 100% rename from docs/code-examples/mesh3d_partial_updates.py rename to docs/code-examples/all/mesh3d_partial_updates.py diff --git a/docs/code-examples/mesh3d_partial_updates.rs b/docs/code-examples/all/mesh3d_partial_updates.rs similarity index 100% rename from docs/code-examples/mesh3d_partial_updates.rs rename to docs/code-examples/all/mesh3d_partial_updates.rs diff --git a/docs/code-examples/mesh3d_simple.cpp b/docs/code-examples/all/mesh3d_simple.cpp similarity index 100% rename from docs/code-examples/mesh3d_simple.cpp rename to docs/code-examples/all/mesh3d_simple.cpp diff --git a/docs/code-examples/mesh3d_simple.py b/docs/code-examples/all/mesh3d_simple.py similarity index 100% rename from docs/code-examples/mesh3d_simple.py rename to docs/code-examples/all/mesh3d_simple.py diff --git a/docs/code-examples/mesh3d_simple.rs b/docs/code-examples/all/mesh3d_simple.rs similarity index 100% rename from docs/code-examples/mesh3d_simple.rs rename to docs/code-examples/all/mesh3d_simple.rs diff --git a/docs/code-examples/pinhole_simple.cpp b/docs/code-examples/all/pinhole_simple.cpp similarity index 100% rename from docs/code-examples/pinhole_simple.cpp rename to docs/code-examples/all/pinhole_simple.cpp diff --git a/docs/code-examples/pinhole_simple.py b/docs/code-examples/all/pinhole_simple.py similarity index 100% rename from docs/code-examples/pinhole_simple.py rename to docs/code-examples/all/pinhole_simple.py diff --git a/docs/code-examples/pinhole_simple.rs b/docs/code-examples/all/pinhole_simple.rs similarity index 100% rename from docs/code-examples/pinhole_simple.rs rename to docs/code-examples/all/pinhole_simple.rs diff --git a/docs/code-examples/point2d_random.cpp b/docs/code-examples/all/point2d_random.cpp similarity index 100% rename from docs/code-examples/point2d_random.cpp rename to docs/code-examples/all/point2d_random.cpp diff --git a/docs/code-examples/point2d_random.py b/docs/code-examples/all/point2d_random.py similarity index 100% rename from docs/code-examples/point2d_random.py rename to docs/code-examples/all/point2d_random.py diff --git a/docs/code-examples/point2d_random.rs b/docs/code-examples/all/point2d_random.rs similarity index 100% rename from docs/code-examples/point2d_random.rs rename to docs/code-examples/all/point2d_random.rs diff --git a/docs/code-examples/point2d_simple.cpp b/docs/code-examples/all/point2d_simple.cpp similarity index 100% rename from docs/code-examples/point2d_simple.cpp rename to docs/code-examples/all/point2d_simple.cpp diff --git a/docs/code-examples/point2d_simple.py b/docs/code-examples/all/point2d_simple.py similarity index 100% rename from docs/code-examples/point2d_simple.py rename to docs/code-examples/all/point2d_simple.py diff --git a/docs/code-examples/point2d_simple.rs b/docs/code-examples/all/point2d_simple.rs similarity index 100% rename from docs/code-examples/point2d_simple.rs rename to docs/code-examples/all/point2d_simple.rs diff --git a/docs/code-examples/point3d_random.cpp b/docs/code-examples/all/point3d_random.cpp similarity index 100% rename from docs/code-examples/point3d_random.cpp rename to docs/code-examples/all/point3d_random.cpp diff --git a/docs/code-examples/point3d_random.py b/docs/code-examples/all/point3d_random.py similarity index 100% rename from docs/code-examples/point3d_random.py rename to docs/code-examples/all/point3d_random.py diff --git a/docs/code-examples/point3d_random.rs b/docs/code-examples/all/point3d_random.rs similarity index 100% rename from docs/code-examples/point3d_random.rs rename to docs/code-examples/all/point3d_random.rs diff --git a/docs/code-examples/point3d_simple.cpp b/docs/code-examples/all/point3d_simple.cpp similarity index 100% rename from docs/code-examples/point3d_simple.cpp rename to docs/code-examples/all/point3d_simple.cpp diff --git a/docs/code-examples/point3d_simple.py b/docs/code-examples/all/point3d_simple.py similarity index 100% rename from docs/code-examples/point3d_simple.py rename to docs/code-examples/all/point3d_simple.py diff --git a/docs/code-examples/point3d_simple.rs b/docs/code-examples/all/point3d_simple.rs similarity index 100% rename from docs/code-examples/point3d_simple.rs rename to docs/code-examples/all/point3d_simple.rs diff --git a/docs/code-examples/quick_start_connect.cpp b/docs/code-examples/all/quick_start_connect.cpp similarity index 100% rename from docs/code-examples/quick_start_connect.cpp rename to docs/code-examples/all/quick_start_connect.cpp diff --git a/docs/code-examples/quick_start_connect.py b/docs/code-examples/all/quick_start_connect.py similarity index 100% rename from docs/code-examples/quick_start_connect.py rename to docs/code-examples/all/quick_start_connect.py diff --git a/docs/code-examples/quick_start_connect.rs b/docs/code-examples/all/quick_start_connect.rs similarity index 100% rename from docs/code-examples/quick_start_connect.rs rename to docs/code-examples/all/quick_start_connect.rs diff --git a/docs/code-examples/quick_start_spawn.cpp b/docs/code-examples/all/quick_start_spawn.cpp similarity index 100% rename from docs/code-examples/quick_start_spawn.cpp rename to docs/code-examples/all/quick_start_spawn.cpp diff --git a/docs/code-examples/quick_start_spawn.py b/docs/code-examples/all/quick_start_spawn.py similarity index 100% rename from docs/code-examples/quick_start_spawn.py rename to docs/code-examples/all/quick_start_spawn.py diff --git a/docs/code-examples/quick_start_spawn.rs b/docs/code-examples/all/quick_start_spawn.rs similarity index 100% rename from docs/code-examples/quick_start_spawn.rs rename to docs/code-examples/all/quick_start_spawn.rs diff --git a/docs/code-examples/scalar_multiple_plots.cpp b/docs/code-examples/all/scalar_multiple_plots.cpp similarity index 100% rename from docs/code-examples/scalar_multiple_plots.cpp rename to docs/code-examples/all/scalar_multiple_plots.cpp diff --git a/docs/code-examples/scalar_multiple_plots.py b/docs/code-examples/all/scalar_multiple_plots.py similarity index 100% rename from docs/code-examples/scalar_multiple_plots.py rename to docs/code-examples/all/scalar_multiple_plots.py diff --git a/docs/code-examples/scalar_multiple_plots.rs b/docs/code-examples/all/scalar_multiple_plots.rs similarity index 100% rename from docs/code-examples/scalar_multiple_plots.rs rename to docs/code-examples/all/scalar_multiple_plots.rs diff --git a/docs/code-examples/scalar_simple.cpp b/docs/code-examples/all/scalar_simple.cpp similarity index 100% rename from docs/code-examples/scalar_simple.cpp rename to docs/code-examples/all/scalar_simple.cpp diff --git a/docs/code-examples/scalar_simple.py b/docs/code-examples/all/scalar_simple.py similarity index 100% rename from docs/code-examples/scalar_simple.py rename to docs/code-examples/all/scalar_simple.py diff --git a/docs/code-examples/scalar_simple.rs b/docs/code-examples/all/scalar_simple.rs similarity index 100% rename from docs/code-examples/scalar_simple.rs rename to docs/code-examples/all/scalar_simple.rs diff --git a/docs/code-examples/segmentation_image_simple.cpp b/docs/code-examples/all/segmentation_image_simple.cpp similarity index 100% rename from docs/code-examples/segmentation_image_simple.cpp rename to docs/code-examples/all/segmentation_image_simple.cpp diff --git a/docs/code-examples/segmentation_image_simple.py b/docs/code-examples/all/segmentation_image_simple.py similarity index 100% rename from docs/code-examples/segmentation_image_simple.py rename to docs/code-examples/all/segmentation_image_simple.py diff --git a/docs/code-examples/segmentation_image_simple.rs b/docs/code-examples/all/segmentation_image_simple.rs similarity index 100% rename from docs/code-examples/segmentation_image_simple.rs rename to docs/code-examples/all/segmentation_image_simple.rs diff --git a/docs/code-examples/tensor_simple.cpp b/docs/code-examples/all/tensor_simple.cpp similarity index 100% rename from docs/code-examples/tensor_simple.cpp rename to docs/code-examples/all/tensor_simple.cpp diff --git a/docs/code-examples/tensor_simple.py b/docs/code-examples/all/tensor_simple.py similarity index 100% rename from docs/code-examples/tensor_simple.py rename to docs/code-examples/all/tensor_simple.py diff --git a/docs/code-examples/tensor_simple.rs b/docs/code-examples/all/tensor_simple.rs similarity index 100% rename from docs/code-examples/tensor_simple.rs rename to docs/code-examples/all/tensor_simple.rs diff --git a/docs/code-examples/text_document.cpp b/docs/code-examples/all/text_document.cpp similarity index 100% rename from docs/code-examples/text_document.cpp rename to docs/code-examples/all/text_document.cpp diff --git a/docs/code-examples/text_document.py b/docs/code-examples/all/text_document.py similarity index 100% rename from docs/code-examples/text_document.py rename to docs/code-examples/all/text_document.py diff --git a/docs/code-examples/text_document.rs b/docs/code-examples/all/text_document.rs similarity index 100% rename from docs/code-examples/text_document.rs rename to docs/code-examples/all/text_document.rs diff --git a/docs/code-examples/text_log.cpp b/docs/code-examples/all/text_log.cpp similarity index 100% rename from docs/code-examples/text_log.cpp rename to docs/code-examples/all/text_log.cpp diff --git a/docs/code-examples/text_log.py b/docs/code-examples/all/text_log.py similarity index 100% rename from docs/code-examples/text_log.py rename to docs/code-examples/all/text_log.py diff --git a/docs/code-examples/text_log.rs b/docs/code-examples/all/text_log.rs similarity index 100% rename from docs/code-examples/text_log.rs rename to docs/code-examples/all/text_log.rs diff --git a/docs/code-examples/text_log_integration.cpp b/docs/code-examples/all/text_log_integration.cpp similarity index 100% rename from docs/code-examples/text_log_integration.cpp rename to docs/code-examples/all/text_log_integration.cpp diff --git a/docs/code-examples/text_log_integration.py b/docs/code-examples/all/text_log_integration.py similarity index 100% rename from docs/code-examples/text_log_integration.py rename to docs/code-examples/all/text_log_integration.py diff --git a/docs/code-examples/text_log_integration.rs b/docs/code-examples/all/text_log_integration.rs similarity index 100% rename from docs/code-examples/text_log_integration.rs rename to docs/code-examples/all/text_log_integration.rs diff --git a/docs/code-examples/timelines_example.cpp b/docs/code-examples/all/timelines_example.cpp similarity index 100% rename from docs/code-examples/timelines_example.cpp rename to docs/code-examples/all/timelines_example.cpp diff --git a/docs/code-examples/timelines_example.py b/docs/code-examples/all/timelines_example.py similarity index 100% rename from docs/code-examples/timelines_example.py rename to docs/code-examples/all/timelines_example.py diff --git a/docs/code-examples/timelines_example.rs b/docs/code-examples/all/timelines_example.rs similarity index 100% rename from docs/code-examples/timelines_example.rs rename to docs/code-examples/all/timelines_example.rs diff --git a/docs/code-examples/transform3d_simple.cpp b/docs/code-examples/all/transform3d_simple.cpp similarity index 100% rename from docs/code-examples/transform3d_simple.cpp rename to docs/code-examples/all/transform3d_simple.cpp diff --git a/docs/code-examples/transform3d_simple.py b/docs/code-examples/all/transform3d_simple.py similarity index 100% rename from docs/code-examples/transform3d_simple.py rename to docs/code-examples/all/transform3d_simple.py diff --git a/docs/code-examples/transform3d_simple.rs b/docs/code-examples/all/transform3d_simple.rs similarity index 100% rename from docs/code-examples/transform3d_simple.rs rename to docs/code-examples/all/transform3d_simple.rs diff --git a/docs/code-examples/view_coordinates_simple.cpp b/docs/code-examples/all/view_coordinates_simple.cpp similarity index 100% rename from docs/code-examples/view_coordinates_simple.cpp rename to docs/code-examples/all/view_coordinates_simple.cpp diff --git a/docs/code-examples/view_coordinates_simple.py b/docs/code-examples/all/view_coordinates_simple.py similarity index 100% rename from docs/code-examples/view_coordinates_simple.py rename to docs/code-examples/all/view_coordinates_simple.py diff --git a/docs/code-examples/view_coordinates_simple.rs b/docs/code-examples/all/view_coordinates_simple.rs similarity index 100% rename from docs/code-examples/view_coordinates_simple.rs rename to docs/code-examples/all/view_coordinates_simple.rs diff --git a/docs/code-examples/build.rs b/docs/code-examples/build.rs new file mode 100644 index 000000000000..43b70a3f426b --- /dev/null +++ b/docs/code-examples/build.rs @@ -0,0 +1,119 @@ +//! Finds all the `*.rs` files in `docs/code-examples/all`, +//! copies them to `src/examples` (with slight modifications), and generate a `examples/mod.rs` for them. +//! +//! The reason we combine all the examples into a single binary +//! is to reduce the amount of binaries in our workspace. +//! +//! Motivation: + +use std::{fs, path::Path}; + +use itertools::Itertools as _; +use rust_format::Formatter as _; + +fn main() { + let crate_path = + Path::new(&re_build_tools::get_and_track_env_var("CARGO_MANIFEST_DIR").unwrap()).to_owned(); + let all_path = crate_path.join("all"); + let src_path = crate_path.join("src"); + let examples_path = src_path.join("examples"); + + assert!( + all_path.exists() && all_path.is_dir(), + "Failed to find {all_path:?}" + ); + + let mut examples = Vec::new(); + + for entry in fs::read_dir(&all_path).unwrap().flatten() { + let path = entry.path(); + if let Some(extension) = path.extension() { + if extension == "rs" { + let example_name = path.file_stem().unwrap().to_str().unwrap().to_owned(); + + let contents = fs::read_to_string(&path).unwrap(); + + // TODO(#515): some examples lack a main, they should come with their necessary stub code commented out so that we can re-add it here. + if contents.contains("fn main()") { + // Patch the source code so we can call into `main` and pass arguments to it: + let contents = contents.replace("fn main()", "pub fn main(_args: &[String])"); + let contents = contents.replace( + "let args = std::env::args().collect::>();", + "let args = _args;", + ); + let contents = format!( + "//! DO NOT EDIT! This is a py. The original is in {path:?}.\n{contents}" + ); + + let target_path = examples_path.join(format!("{example_name}.rs")); + re_build_tools::write_file_if_necessary(target_path, contents.as_bytes()) + .unwrap(); + + examples.push(example_name); + } + } + } + } + + assert!( + examples.len() > 10, + "Found too few examples in {all_path:?}" + ); + + let source = r#" + //! DO NOT EDIT! Code generated by ${FILE}. + + #![allow(clippy::exit)] + + ${MODS} + + pub fn run() { + let args: Vec = std::env::args().skip(1).collect(); + + if args.is_empty() { + eprintln!("Usage: {} \n", std::env::args().next().unwrap()); + eprintln!("Available examples ${EXAMPLES}:\n"); + std::process::exit(1); + } + + let example_name = args[0].as_str(); + + match example_name { + ${MATCH_EXAMPLES} + _ => { + eprintln!("Unknown example: {example_name}"); + std::process::exit(1); + } + } + } + "# + .trim() + .replace("${FILE}", file!()) + .replace( + "${MODS}", + &examples.iter().map(|m| format!("mod {m};")).join("\n"), + ) + .replace("${EXAMPLES}", &examples.iter().join(" ")) + .replace( + "${MATCH_EXAMPLES}", + &examples + .iter() + .map(|m| { + format!( + r#"{m:?} => {{ + if let Err(err) = {m}::main(&args) {{ + panic!("Failed to run '{m}': {{err}}"); + }} + }}"# + ) + }) + .join(",\n"), + ); + + let source = rust_format::RustFmt::default() + .format_str(source) + .expect("Failed to format"); + + re_build_tools::write_file_if_necessary(examples_path.join("mod.rs"), source.as_bytes()) + .unwrap(); +} diff --git a/docs/code-examples/roundtrips.py b/docs/code-examples/roundtrips.py index 406f26ab22a6..d5352dc4bf19 100755 --- a/docs/code-examples/roundtrips.py +++ b/docs/code-examples/roundtrips.py @@ -47,6 +47,7 @@ "quick_start_spawn": ["cpp", "py", "rust"], # These example don't have exactly the same implementation. "scalar_multiple_plots": ["cpp"], # trigonometric functions have slightly different outcomes "tensor_simple": ["cpp", "py", "rust"], # TODO(#3206): examples use different RNGs + "text_log_integration": ["cpp", "py", "rust"], # The entity path will differ because the Rust code is part of a library } extra_args = { @@ -105,8 +106,7 @@ def main() -> None: print("----------------------------------------------------------") print("Build rerun_c & rerun_cpp…") start_time = time.time() - cmake_configure(args.release, build_env) - cmake_build("rerun_sdk", args.release) + run(["pixi", "run", "cpp-build-doc-examples"]) elapsed = time.time() - start_time print(f"rerun-sdk for C++ built in {elapsed:.1f} seconds") print("") @@ -114,7 +114,7 @@ def main() -> None: if len(args.example) > 0: examples = args.example else: - dir = os.path.dirname(__file__) + dir = os.path.join(os.path.dirname(__file__), "all") files = [f for f in listdir(dir) if isfile(join(dir, f))] examples = [ filename @@ -170,9 +170,9 @@ def main() -> None: if "rust" in example_opt_out_entirely: continue # No baseline to compare against - cpp_output_path = f"docs/code-examples/{example}_cpp.rrd" - python_output_path = f"docs/code-examples/{example}_py.rrd" - rust_output_path = f"docs/code-examples/{example}_rust.rrd" + cpp_output_path = f"docs/code-examples/all/{example}_cpp.rrd" + python_output_path = f"docs/code-examples/all/{example}_py.rrd" + rust_output_path = f"docs/code-examples/all/{example}_rust.rrd" if "cpp" in active_languages and "cpp" not in example_opt_out_entirely and "cpp" not in example_opt_out_compare: run_comparison(cpp_output_path, rust_output_path, args.full_dump) @@ -200,8 +200,8 @@ def run_example(example: str, language: str, args: argparse.Namespace) -> None: def run_roundtrip_python(example: str) -> str: - main_path = f"docs/code-examples/{example}.py" - output_path = f"docs/code-examples/{example}_py.rrd" + main_path = f"docs/code-examples/all/{example}.py" + output_path = f"docs/code-examples/all/{example}_py.rrd" # sys.executable: the absolute path of the executable binary for the Python interpreter python_executable = sys.executable @@ -217,9 +217,9 @@ def run_roundtrip_python(example: str) -> str: def run_roundtrip_rust(example: str, release: bool, target: str | None, target_dir: str | None) -> str: - output_path = f"docs/code-examples/{example}_rust.rrd" + output_path = f"docs/code-examples/all/{example}_rust.rrd" - cmd = ["cargo", "run", "--quiet", "-p", "code_examples", "--bin", example] + cmd = ["cargo", "run", "--quiet", "-p", "code_examples"] if target is not None: cmd += ["--target", target] @@ -230,8 +230,10 @@ def run_roundtrip_rust(example: str, release: bool, target: str | None, target_d if release: cmd += ["--release"] + cmd += ["--", example] + if extra_args.get(example): - cmd += ["--"] + extra_args[example] + cmd += extra_args[example] env = roundtrip_env(save_path=output_path) run(cmd, env=env, timeout=12000) @@ -240,12 +242,9 @@ def run_roundtrip_rust(example: str, release: bool, target: str | None, target_d def run_roundtrip_cpp(example: str, release: bool) -> str: - target_name = f"{example}" - output_path = f"docs/code-examples/{example}_cpp.rrd" - - cmake_build(target_name, release) + output_path = f"docs/code-examples/all/{example}_cpp.rrd" - cmd = [f"{cpp_build_dir}/docs/code-examples/{example}"] + (extra_args.get(example) or []) + cmd = [f"./build/debug/docs/code-examples/{example}"] + (extra_args.get(example) or []) env = roundtrip_env(save_path=output_path) run(cmd, env=env, timeout=12000) diff --git a/docs/code-examples/src/examples/.gitignore b/docs/code-examples/src/examples/.gitignore new file mode 100644 index 000000000000..6f5f3d11d3ed --- /dev/null +++ b/docs/code-examples/src/examples/.gitignore @@ -0,0 +1 @@ +*.rs diff --git a/docs/code-examples/src/lib.rs b/docs/code-examples/src/lib.rs new file mode 100644 index 000000000000..e9cf2fdc39f4 --- /dev/null +++ b/docs/code-examples/src/lib.rs @@ -0,0 +1,5 @@ +//! Code examples that we show in documentation. + +mod examples; + +pub use examples::run; diff --git a/docs/code-examples/src/main.rs b/docs/code-examples/src/main.rs new file mode 100644 index 000000000000..9d76de6ccb01 --- /dev/null +++ b/docs/code-examples/src/main.rs @@ -0,0 +1,6 @@ +//! Code examples that we show in documentation. + +pub fn main() { + // Call into the generated code. + code_examples::run(); +} diff --git a/rerun_cpp/src/rerun/c/rerun.h b/rerun_cpp/src/rerun/c/rerun.h index 4a59655fb7b5..f03af2aa3451 100644 --- a/rerun_cpp/src/rerun/c/rerun.h +++ b/rerun_cpp/src/rerun/c/rerun.h @@ -233,7 +233,7 @@ typedef struct rr_error { /// /// This should match the string returned by `rr_version_string`. /// If not, the SDK's binary and the C header are out of sync. -#define RERUN_SDK_HEADER_VERSION "0.12.0" +#define RERUN_SDK_HEADER_VERSION "0.13.0-alpha.1+dev" /// Returns a human-readable version string of the Rerun C SDK. /// diff --git a/rerun_py/pyproject.toml b/rerun_py/pyproject.toml index 8d32fb9c05d1..468d1b3e4492 100644 --- a/rerun_py/pyproject.toml +++ b/rerun_py/pyproject.toml @@ -53,10 +53,10 @@ extend-exclude = [ "target/", # Intentionally uses ''' instead of """ so we can embed it in a docstring in the Python API docs. - "docs/code-examples/text_document.py", + "docs/code-examples/all/text_document.py", # TODO(#4047): incomplete example snippet - "docs/code-examples/timelines_example.py", + "docs/code-examples/all/timelines_example.py", # generated "examples/python/objectron/proto/objectron/proto.py", @@ -108,7 +108,7 @@ select = [ ] [tool.ruff.per-file-ignores] -"docs/code-examples/*" = [ +"docs/code-examples/all/*" = [ # Missing required import: `from __future__ import annotations` "I002", ]