Skip to content

Commit a09b53a

Browse files
committed
RustDoc links: map more types which are named differently in Rust
1 parent a3eba86 commit a09b53a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

bindings_generator/src/api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ pub enum Ty {
357357
}
358358

359359
impl Ty {
360+
// Note: there is some code duplication with GodotXmlDocs::translate_type() in class_docs.rs
360361
pub fn from_src(src: &str) -> Self {
361362
match src {
362363
"void" => Ty::Void,

bindings_generator/src/class_docs.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,21 @@ impl GodotXmlDocs {
131131
);
132132
}
133133

134-
fn to_rust_type(godot_type: &str) -> &str {
134+
fn translate_type(godot_type: &str) -> &str {
135+
// Note: there is some code duplication with Ty::from_src() in api.rs
135136
match godot_type {
136137
"String" => "GodotString",
137138
"Error" => "GodotError",
138139
"RID" => "Rid",
139-
// TODO PoolVector3Array etc
140+
"AABB" => "Aabb",
141+
"Array" => "VariantArray",
142+
"PoolByteArray" => "ByteArray",
143+
"PoolStringArray" => "StringArray",
144+
"PoolVector2Array" => "Vector2Array",
145+
"PoolVector3Array" => "Vector3Array",
146+
"PoolColorArray" => "ColorArray",
147+
"PoolIntArray" => "Int32Array",
148+
"PoolRealArray" => "Float32Array",
140149
"G6DOFJointAxisParam" => "G6dofJointAxisParam",
141150
"G6DOFJointAxisFlag" => "G6dofJointAxisFlag",
142151
_ => godot_type,
@@ -202,7 +211,7 @@ impl GodotXmlDocs {
202211
// [Type] style
203212
let godot_doc = type_regex.replace_all(&godot_doc, |c: &Captures| {
204213
let godot_ty = &c[2];
205-
let rust_ty = Self::to_rust_type(godot_ty);
214+
let rust_ty = Self::translate_type(godot_ty);
206215

207216
format!(
208217
"[`{godot_ty}`][{rust_ty}]",
@@ -214,7 +223,7 @@ impl GodotXmlDocs {
214223
// [Type::member] style
215224
let godot_doc = class_member_regex.replace_all(&godot_doc, |c: &Captures| {
216225
let godot_ty = &c[2];
217-
let rust_ty = Self::to_rust_type(godot_ty);
226+
let rust_ty = Self::translate_type(godot_ty);
218227

219228
format!(
220229
"[`{godot_ty}.{member}`][{rust_ty}::{member}]",

0 commit comments

Comments
 (0)