Skip to content

Commit a3eba86

Browse files
committed
RustDoc links: handle [C] syntax (e.g. [RID], [PhysicsBody])
1 parent caea1db commit a3eba86

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

bindings_generator/src/class_docs.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl GodotXmlDocs {
136136
"String" => "GodotString",
137137
"Error" => "GodotError",
138138
"RID" => "Rid",
139+
// TODO PoolVector3Array etc
139140
"G6DOFJointAxisParam" => "G6dofJointAxisParam",
140141
"G6DOFJointAxisFlag" => "G6dofJointAxisFlag",
141142
_ => godot_type,
@@ -152,11 +153,28 @@ impl GodotXmlDocs {
152153
};
153154

154155
// TODO reuse regex across classes
156+
157+
// Covers:
158+
// * [url=U]text[/url]
159+
// * [url=U][/url]
155160
let url_regex = Regex::new("\\[url=(.+?)](.*?)\\[/url]").unwrap();
156161

157-
let type_regex = Regex::new("\\[enum ([A-Za-z0-9_]+?)]").unwrap();
162+
// Covers:
163+
// * [C]
164+
// * [enum C]
165+
let type_regex = Regex::new("\\[(enum )?([A-Za-z0-9_]+?)]").unwrap();
166+
167+
// Covers:
168+
// * [member M]
169+
// * [method M]
170+
// * [constant M]
158171
let self_member_regex =
159172
Regex::new("\\[(member|method|constant) ([A-Za-z0-9_]+?)]").unwrap();
173+
174+
// Covers:
175+
// * [member C.M]
176+
// * [method C.M]
177+
// * [constant C.M]
160178
let class_member_regex =
161179
Regex::new("\\[(member|method|constant) ([A-Za-z0-9_]+?)\\.([A-Za-z0-9_]+?)]").unwrap();
162180

@@ -183,7 +201,7 @@ impl GodotXmlDocs {
183201

184202
// [Type] style
185203
let godot_doc = type_regex.replace_all(&godot_doc, |c: &Captures| {
186-
let godot_ty = &c[1];
204+
let godot_ty = &c[2];
187205
let rust_ty = Self::to_rust_type(godot_ty);
188206

189207
format!(

0 commit comments

Comments
 (0)