Skip to content

Commit ce361be

Browse files
authored
enum codegen for Python (#5319)
### What * Part of #3384 Even includes codegen of the arrow serialization, which is a first for Python. Best reviewed commit-by-commit ### 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/5319/index.html) * Using examples from latest `main` build: [app.rerun.io](https://app.rerun.io/pr/5319/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/5319/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5319) - [Docs preview](https://rerun.io/preview/2f1d162e5f221d9c0a78b1bcff1524fec67e110c/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/2f1d162e5f221d9c0a78b1bcff1524fec67e110c/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
1 parent 27cbc3d commit ce361be

File tree

17 files changed

+701
-114
lines changed

17 files changed

+701
-114
lines changed

crates/re_types/definitions/rerun/datatypes.fbs

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ include "./datatypes/vec2d.fbs";
3232
include "./datatypes/vec3d.fbs";
3333
include "./datatypes/vec4d.fbs";
3434

35+
include "./testing/datatypes/enum.fbs";
3536

3637
namespace rerun.datatypes;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace rerun.testing.datatypes;
2+
3+
/// A test of the enum type.
4+
enum EnumTest: byte {
5+
/// Great film.
6+
Up,
7+
8+
/// Feeling blue.
9+
Down,
10+
11+
/// Correct.
12+
Right,
13+
14+
/// It's what's remaining.
15+
Left,
16+
17+
/// It's the only way to go.
18+
Forward,
19+
20+
/// Baby's got it.
21+
Back,
22+
}

crates/re_types/src/testing/datatypes/.gitattributes

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/re_types/src/testing/datatypes/enum_test.rs

+203
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/re_types/src/testing/datatypes/mod.rs

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/re_types_builder/src/codegen/common.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,29 @@ pub fn collect_examples_for_api_docs<'a>(
293293
}
294294

295295
pub trait StringExt {
296-
fn push_text(&mut self, text: impl AsRef<str>, linefeeds: usize, indent: usize) -> &mut Self;
297-
fn push_unindented_text(&mut self, text: impl AsRef<str>, linefeeds: usize) -> &mut Self;
296+
fn push_indented(
297+
&mut self,
298+
indent_level: usize,
299+
text: impl AsRef<str>,
300+
linefeeds: usize,
301+
) -> &mut Self;
302+
303+
fn push_unindented(&mut self, text: impl AsRef<str>, linefeeds: usize) -> &mut Self;
298304
}
299305

300306
impl StringExt for String {
301-
fn push_text(&mut self, text: impl AsRef<str>, linefeeds: usize, indent: usize) -> &mut Self {
302-
self.push_str(&indent::indent_all_by(indent, text.as_ref()));
307+
fn push_indented(
308+
&mut self,
309+
indent_level: usize,
310+
text: impl AsRef<str>,
311+
linefeeds: usize,
312+
) -> &mut Self {
313+
self.push_str(&indent::indent_all_by(indent_level * 4, text.as_ref()));
303314
self.push_str(&vec!["\n"; linefeeds].join(""));
304315
self
305316
}
306317

307-
fn push_unindented_text(&mut self, text: impl AsRef<str>, linefeeds: usize) -> &mut Self {
318+
fn push_unindented(&mut self, text: impl AsRef<str>, linefeeds: usize) -> &mut Self {
308319
self.push_str(&unindent::unindent(text.as_ref()));
309320
self.push_str(&vec!["\n"; linefeeds].join(""));
310321
self

0 commit comments

Comments
 (0)