Skip to content

Commit

Permalink
Avoid generating redundant doc comments for methods (#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Jul 13, 2022
1 parent 9cda4e0 commit f2c7b49
Show file tree
Hide file tree
Showing 496 changed files with 41,105 additions and 100,796 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/com_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn gen(gen: &Gen, def: TypeDef, kind: InterfaceKind, method: MethodDef, meth
let where_clause = gen.where_clause(&signature.params);
let mut cfg = gen.reader.signature_cfg(&signature);
cfg.add_feature(gen.reader.type_def_namespace(def));
let doc = gen.cfg_doc(&cfg);
let doc = gen.cfg_method_doc(&cfg);
let features = gen.cfg_features(&cfg);

if kind == InterfaceKind::None {
Expand Down
24 changes: 24 additions & 0 deletions crates/libs/bindgen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ impl<'a> Gen<'a> {
// Cfg
//

/// Generates doc comments for types, free functions, and constants.
pub(crate) fn cfg_doc(&self, cfg: &Cfg) -> TokenStream {
if !self.doc {
quote! {}
Expand All @@ -361,6 +362,29 @@ impl<'a> Gen<'a> {
}
}

/// Generates doc comments for member functions (methods) and avoids redundantly declaring the
/// enclosing module feature required by the method's type.
pub(crate) fn cfg_method_doc(&self, cfg: &Cfg) -> TokenStream {
if !self.doc {
quote! {}
} else {
let mut features = cfg_features(cfg, self.namespace);
if features.is_empty() {
quote! {}
} else {
if self.windows_extern {
features.retain(|f| !f.starts_with("Windows."));
}
let mut tokens = String::new();
for features in features {
write!(tokens, r#"`\"{}\"`, "#, to_feature(features)).unwrap();
}
tokens.truncate(tokens.len() - 2);
format!(r#"#[doc = "*Required features: {}*"]"#, tokens).into()
}
}
}

pub(crate) fn cfg_features(&self, cfg: &Cfg) -> TokenStream {
if !self.cfg {
quote! {}
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/winrt_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn gen(gen: &Gen, def: TypeDef, generic_types: &[Type], kind: InterfaceKind,
let where_clause = gen.where_clause(params);
let mut cfg = gen.reader.signature_cfg(&signature);
gen.reader.type_def_cfg_combine(def, generic_types, &mut cfg);
let doc = gen.cfg_doc(&cfg);
let doc = gen.cfg_method_doc(&cfg);
let features = gen.cfg_features(&cfg);
let args = gen_winrt_abi_args(gen, params);
let params = gen_winrt_params(gen, params);
Expand Down
140 changes: 70 additions & 70 deletions crates/libs/windows/src/Windows/AI/MachineLearning/Preview/mod.rs

Large diffs are not rendered by default.

376 changes: 134 additions & 242 deletions crates/libs/windows/src/Windows/AI/MachineLearning/mod.rs

Large diffs are not rendered by default.

696 changes: 135 additions & 561 deletions crates/libs/windows/src/Windows/ApplicationModel/Activation/mod.rs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

49 changes: 17 additions & 32 deletions crates/libs/windows/src/Windows/ApplicationModel/AppService/mod.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,38 @@
#[repr(transparent)]
pub struct AddAppointmentOperation(::windows::core::IUnknown);
impl AddAppointmentOperation {
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn AppointmentInformation(&self) -> ::windows::core::Result<super::Appointment> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
(::windows::core::Interface::vtable(this).AppointmentInformation)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Appointment>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn SourcePackageFamilyName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).SourcePackageFamilyName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportCompleted<'a, P0>(&self, itemid: P0) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, ::windows::core::HSTRING>>,
{
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportCompleted)(::windows::core::Interface::as_raw(this), itemid.into().abi()).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportCanceled(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportCanceled)(::windows::core::Interface::as_raw(this)).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportError<'a, P0>(&self, value: P0) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, ::windows::core::HSTRING>>,
{
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportError)(::windows::core::Interface::as_raw(this), value.into().abi()).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn DismissUI(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).DismissUI)(::windows::core::Interface::as_raw(this)).ok() }
Expand Down Expand Up @@ -110,35 +104,30 @@ unsafe impl ::core::marker::Sync for AddAppointmentOperation {}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub struct AppointmentsProviderLaunchActionVerbs;
impl AppointmentsProviderLaunchActionVerbs {
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn AddAppointment() -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IAppointmentsProviderLaunchActionVerbsStatics(|this| unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).AddAppointment)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
})
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReplaceAppointment() -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IAppointmentsProviderLaunchActionVerbsStatics(|this| unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).ReplaceAppointment)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
})
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn RemoveAppointment() -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IAppointmentsProviderLaunchActionVerbsStatics(|this| unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).RemoveAppointment)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
})
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ShowTimeFrame() -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IAppointmentsProviderLaunchActionVerbsStatics(|this| unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).ShowTimeFrame)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
})
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ShowAppointmentDetails() -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IAppointmentsProviderLaunchActionVerbsStatics2(|this| unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
Expand Down Expand Up @@ -255,15 +244,14 @@ pub struct IReplaceAppointmentOperation_Vtbl {
#[repr(transparent)]
pub struct RemoveAppointmentOperation(::windows::core::IUnknown);
impl RemoveAppointmentOperation {
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn AppointmentId(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).AppointmentId)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`, `\"Foundation\"`*"]
#[doc = "*Required features: `\"Foundation\"`*"]
#[cfg(feature = "Foundation")]
pub fn InstanceStartDate(&self) -> ::windows::core::Result<super::super::super::Foundation::IReference<super::super::super::Foundation::DateTime>> {
let this = self;
Expand All @@ -272,33 +260,28 @@ impl RemoveAppointmentOperation {
(::windows::core::Interface::vtable(this).InstanceStartDate)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::super::Foundation::IReference<super::super::super::Foundation::DateTime>>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn SourcePackageFamilyName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).SourcePackageFamilyName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportCompleted(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportCompleted)(::windows::core::Interface::as_raw(this)).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportCanceled(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportCanceled)(::windows::core::Interface::as_raw(this)).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportError<'a, P0>(&self, value: P0) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, ::windows::core::HSTRING>>,
{
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportError)(::windows::core::Interface::as_raw(this), value.into().abi()).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn DismissUI(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).DismissUI)(::windows::core::Interface::as_raw(this)).ok() }
Expand Down Expand Up @@ -370,23 +353,21 @@ unsafe impl ::core::marker::Sync for RemoveAppointmentOperation {}
#[repr(transparent)]
pub struct ReplaceAppointmentOperation(::windows::core::IUnknown);
impl ReplaceAppointmentOperation {
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn AppointmentId(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).AppointmentId)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn AppointmentInformation(&self) -> ::windows::core::Result<super::Appointment> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<*mut ::core::ffi::c_void>::zeroed();
(::windows::core::Interface::vtable(this).AppointmentInformation)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::Appointment>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`, `\"Foundation\"`*"]
#[doc = "*Required features: `\"Foundation\"`*"]
#[cfg(feature = "Foundation")]
pub fn InstanceStartDate(&self) -> ::windows::core::Result<super::super::super::Foundation::IReference<super::super::super::Foundation::DateTime>> {
let this = self;
Expand All @@ -395,36 +376,31 @@ impl ReplaceAppointmentOperation {
(::windows::core::Interface::vtable(this).InstanceStartDate)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<super::super::super::Foundation::IReference<super::super::super::Foundation::DateTime>>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn SourcePackageFamilyName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__ = ::core::mem::MaybeUninit::<::core::mem::ManuallyDrop<::windows::core::HSTRING>>::zeroed();
(::windows::core::Interface::vtable(this).SourcePackageFamilyName)(::windows::core::Interface::as_raw(this), result__.as_mut_ptr()).from_abi::<::windows::core::HSTRING>(result__)
}
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportCompleted<'a, P0>(&self, itemid: P0) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, ::windows::core::HSTRING>>,
{
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportCompleted)(::windows::core::Interface::as_raw(this), itemid.into().abi()).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportCanceled(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportCanceled)(::windows::core::Interface::as_raw(this)).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn ReportError<'a, P0>(&self, value: P0) -> ::windows::core::Result<()>
where
P0: ::std::convert::Into<::windows::core::InParam<'a, ::windows::core::HSTRING>>,
{
let this = self;
unsafe { (::windows::core::Interface::vtable(this).ReportError)(::windows::core::Interface::as_raw(this), value.into().abi()).ok() }
}
#[doc = "*Required features: `\"ApplicationModel_Appointments_AppointmentsProvider\"`*"]
pub fn DismissUI(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).DismissUI)(::windows::core::Interface::as_raw(this)).ok() }
Expand Down
Loading

0 comments on commit f2c7b49

Please sign in to comment.