mirror of
https://github.com/bevyengine/bevy
synced 2024-12-18 17:13:10 +00:00
694c06f3d0
# Objective Currently the `missing_docs` lint is allowed-by-default and enabled at crate level when their documentations is complete (see #3492). This PR proposes to inverse this logic by making `missing_docs` warn-by-default and mark crates with imcomplete docs allowed. ## Solution Makes `missing_docs` warn at workspace level and allowed at crate level when the docs is imcomplete.
30 lines
1 KiB
Rust
30 lines
1 KiB
Rust
//! This example illustrates how to create a custom diagnostic.
|
|
|
|
use bevy::{
|
|
diagnostic::{
|
|
Diagnostic, DiagnosticPath, Diagnostics, LogDiagnosticsPlugin, RegisterDiagnostic,
|
|
},
|
|
prelude::*,
|
|
};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins((
|
|
DefaultPlugins,
|
|
// The "print diagnostics" plugin is optional.
|
|
// It just visualizes our diagnostics in the console.
|
|
LogDiagnosticsPlugin::default(),
|
|
))
|
|
// Diagnostics must be initialized before measurements can be added.
|
|
.register_diagnostic(Diagnostic::new(SYSTEM_ITERATION_COUNT).with_suffix(" iterations"))
|
|
.add_systems(Update, my_system)
|
|
.run();
|
|
}
|
|
|
|
// All diagnostics should have a unique DiagnosticPath.
|
|
const SYSTEM_ITERATION_COUNT: DiagnosticPath = DiagnosticPath::const_new("system_iteration_count");
|
|
|
|
fn my_system(mut diagnostics: Diagnostics) {
|
|
// Add a measurement of 10.0 for our diagnostic each time this system runs.
|
|
diagnostics.add_measurement(&SYSTEM_ITERATION_COUNT, || 10.0);
|
|
}
|