Skip to content

Commit c655b5a

Browse files
authored
Merge pull request #1089 from Yarwin/fix-docs-not-generating-if-only-variables-are-present
Fix editor docs not generating when class itself is undocumented
2 parents 62a7381 + 83c14f4 commit c655b5a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

godot-core/src/docs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ pub fn gather_xml_docs() -> impl Iterator<Item = String> {
8686
..
8787
}) => map.entry(class_name).or_default().virtual_methods = virtual_method_docs,
8888

89-
PluginItem::Struct(Struct {
90-
docs: Some(docs), ..
91-
}) => map.entry(class_name).or_default().definition = docs,
89+
PluginItem::Struct(Struct { docs, .. }) => {
90+
map.entry(class_name).or_default().definition = docs
91+
}
9292

9393
_ => (),
9494
}

godot-core/src/registry/plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ pub struct Struct {
189189

190190
/// Documentation extracted from the struct's RustDoc.
191191
#[cfg(all(since_api = "4.3", feature = "register-docs"))]
192-
pub(crate) docs: Option<StructDocs>,
192+
pub(crate) docs: StructDocs,
193193
}
194194

195195
impl Struct {
196196
pub fn new<T: GodotClass + cap::ImplementsGodotExports>(
197-
#[cfg(all(since_api = "4.3", feature = "register-docs"))] docs: Option<StructDocs>,
197+
#[cfg(all(since_api = "4.3", feature = "register-docs"))] docs: StructDocs,
198198
) -> Self {
199199
Self {
200200
base_class_name: T::Base::class_name(),

godot-macros/src/docs.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ use crate::class::{ConstDefinition, Field, FuncDefinition, SignalDefinition};
1111
use proc_macro2::{Ident, TokenStream};
1212
use quote::{quote, ToTokens};
1313

14-
/// Returns code containing the doc information of a `#[derive(GodotClass)] struct MyClass` declaration.
14+
/// Returns code containing the doc information of a `#[derive(GodotClass)] struct MyClass` declaration iff class or any of its members is documented.
1515
pub fn document_struct(
1616
base: String,
1717
description: &[venial::Attribute],
1818
fields: &[Field],
1919
) -> TokenStream {
2020
let base_escaped = xml_escape(base);
21-
let Some(desc_escaped) = attribute_docs_to_bbcode(description).map(xml_escape) else {
22-
return quote! { None };
23-
};
21+
let desc_escaped = attribute_docs_to_bbcode(description)
22+
.map(xml_escape)
23+
.unwrap_or_default();
2424

2525
let members = fields
2626
.iter()
@@ -29,13 +29,11 @@ pub fn document_struct(
2929
.collect::<String>();
3030

3131
quote! {
32-
Some(
3332
::godot::docs::StructDocs {
3433
base: #base_escaped,
3534
description: #desc_escaped,
3635
members: #members,
3736
}
38-
)
3937
}
4038
}
4139

0 commit comments

Comments
 (0)