Enforce writing username in TODO comments (#4235)

This commit is contained in:
Emil Ernerfeldt 2024-03-26 11:48:24 +01:00 committed by GitHub
parent 8a10f81ca0
commit f8d7d0ebaa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 31 additions and 25 deletions

View File

@ -88,7 +88,7 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
if let Some(key) = egui_key { if let Some(key) = egui_key {
runner.input.raw.events.push(egui::Event::Key { runner.input.raw.events.push(egui::Event::Key {
key, key,
physical_key: None, // TODO physical_key: None, // TODO(fornwall)
pressed: true, pressed: true,
repeat: false, // egui will fill this in for us! repeat: false, // egui will fill this in for us!
modifiers, modifiers,
@ -155,7 +155,7 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
if let Some(key) = translate_key(&event.key()) { if let Some(key) = translate_key(&event.key()) {
runner.input.raw.events.push(egui::Event::Key { runner.input.raw.events.push(egui::Event::Key {
key, key,
physical_key: None, // TODO physical_key: None, // TODO(fornwall)
pressed: false, pressed: false,
repeat: false, repeat: false,
modifiers, modifiers,

View File

@ -308,7 +308,7 @@ impl State {
consumed: false, consumed: false,
} }
} }
// WindowEvent::TouchpadPressure {device_id, pressure, stage, .. } => {} // TODO // WindowEvent::TouchpadPressure {device_id, pressure, stage, .. } => {} // TODO(emilk)
WindowEvent::Touch(touch) => { WindowEvent::Touch(touch) => {
self.on_touch(window, touch); self.on_touch(window, touch);
let consumed = match touch.phase { let consumed = match touch.phase {
@ -1298,7 +1298,7 @@ fn process_viewport_command(
ViewportCommand::StartDrag => { ViewportCommand::StartDrag => {
// If `is_viewport_focused` is not checked on x11 the input will be permanently taken until the app is killed! // If `is_viewport_focused` is not checked on x11 the input will be permanently taken until the app is killed!
// TODO: check that the left mouse-button was pressed down recently, // TODO(emilk): check that the left mouse-button was pressed down recently,
// or we will have bugs on Windows. // or we will have bugs on Windows.
// See https://github.com/emilk/egui/pull/1108 // See https://github.com/emilk/egui/pull/1108
if is_viewport_focused { if is_viewport_focused {

View File

@ -2770,7 +2770,7 @@ impl Context {
/// The `Context` lock is held while the given closure is called! /// The `Context` lock is held while the given closure is called!
/// ///
/// Returns `None` if acesskit is off. /// Returns `None` if acesskit is off.
// TODO: consider making both RO and RW versions // TODO(emilk): consider making both RO and RW versions
#[cfg(feature = "accesskit")] #[cfg(feature = "accesskit")]
pub fn accesskit_node_builder<R>( pub fn accesskit_node_builder<R>(
&self, &self,

View File

@ -236,7 +236,7 @@ impl InputState {
// So we smooth it out over several frames for a nicer user experience when scrolling in egui. // So we smooth it out over several frames for a nicer user experience when scrolling in egui.
unprocessed_scroll_delta += raw_scroll_delta; unprocessed_scroll_delta += raw_scroll_delta;
let dt = stable_dt.at_most(0.1); let dt = stable_dt.at_most(0.1);
let t = crate::emath::exponential_smooth_factor(0.90, 0.1, dt); // reach _% in _ seconds. TODO: parameterize let t = crate::emath::exponential_smooth_factor(0.90, 0.1, dt); // reach _% in _ seconds. TODO(emilk): parameterize
for d in 0..2 { for d in 0..2 {
if unprocessed_scroll_delta[d].abs() < 1.0 { if unprocessed_scroll_delta[d].abs() < 1.0 {

View File

@ -247,8 +247,8 @@ pub(crate) fn interact(
hits.click.iter().chain(&hits.drag).map(|w| w.id).collect() hits.click.iter().chain(&hits.drag).map(|w| w.id).collect()
} else { } else {
// Whatever is topmost is what we are hovering. // Whatever is topmost is what we are hovering.
// TODO: consider handle hovering over multiple top-most widgets? // TODO(emilk): consider handle hovering over multiple top-most widgets?
// TODO: allow hovering close widgets? // TODO(emilk): allow hovering close widgets?
hits.contains_pointer hits.contains_pointer
.last() .last()
.map(|w| w.id) .map(|w| w.id)

View File

@ -243,7 +243,7 @@ impl Options {
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
let Self { let Self {
style, // covered above style, // covered above
zoom_factor: _, // TODO zoom_factor: _, // TODO(emilk)
zoom_with_keyboard, zoom_with_keyboard,
tessellation_options, tessellation_options,
repaint_on_widget_change, repaint_on_widget_change,

View File

@ -8,7 +8,7 @@ use super::{
}; };
/// Turn on to help debug this /// Turn on to help debug this
const DEBUG: bool = false; // TODO: don't merge this while `true` const DEBUG: bool = false; // Don't merge `true`!
fn paint_selection( fn paint_selection(
ui: &Ui, ui: &Ui,
@ -169,7 +169,7 @@ impl LabelSelectionState {
if ctx.input(|i| i.pointer.any_pressed() && !i.modifiers.shift) { if ctx.input(|i| i.pointer.any_pressed() && !i.modifiers.shift) {
// Maybe a new selection is about to begin, but the old one is over: // Maybe a new selection is about to begin, but the old one is over:
// state.selection = None; // TODO: this makes sense, but doesn't work as expected. // state.selection = None; // TODO(emilk): this makes sense, but doesn't work as expected.
} }
state.selection_bbox_last_frame = state.selection_bbox_this_frame; state.selection_bbox_last_frame = state.selection_bbox_this_frame;
@ -562,7 +562,7 @@ impl LabelSelectionState {
old.widget_id != new_primary.widget_id || old.ccursor != new_primary.ccursor old.widget_id != new_primary.widget_id || old.ccursor != new_primary.ccursor
}); });
if primary_changed && new_primary.widget_id == widget_id { if primary_changed && new_primary.widget_id == widget_id {
let is_fully_visible = ui.clip_rect().contains_rect(response.rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531 let is_fully_visible = ui.clip_rect().contains_rect(response.rect); // TODO(emilk): remove this HACK workaround for https://github.com/emilk/egui/issues/1531
if selection_changed && !is_fully_visible { if selection_changed && !is_fully_visible {
// Scroll to keep primary cursor in view: // Scroll to keep primary cursor in view:
let row_height = estimate_row_height(galley); let row_height = estimate_row_height(galley);

View File

@ -452,7 +452,7 @@ impl ImageSize {
} }
} }
// TODO: unit-tests // TODO(jprochazk): unit-tests
fn scale_to_fit(image_size: Vec2, available_size: Vec2, maintain_aspect_ratio: bool) -> Vec2 { fn scale_to_fit(image_size: Vec2, available_size: Vec2, maintain_aspect_ratio: bool) -> Vec2 {
if maintain_aspect_ratio { if maintain_aspect_ratio {
let ratio_x = available_size.x / image_size.x; let ratio_x = available_size.x / image_size.x;

View File

@ -687,7 +687,7 @@ impl<'t> TextEdit<'t> {
let primary_cursor_rect = let primary_cursor_rect =
cursor_rect(galley_pos, &galley, &cursor_range.primary, row_height); cursor_rect(galley_pos, &galley, &cursor_range.primary, row_height);
let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531 let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO(emilk): remove this HACK workaround for https://github.com/emilk/egui/issues/1531
if (response.changed || selection_changed) && !is_fully_visible { if (response.changed || selection_changed) && !is_fully_visible {
// Scroll to keep primary cursor in view: // Scroll to keep primary cursor in view:
ui.scroll_to_rect(primary_cursor_rect, None); ui.scroll_to_rect(primary_cursor_rect, None);

View File

@ -261,7 +261,7 @@ The style characters are chosen to be similar to what they are representing:
`$` = $small$ `$` = $small$
`^` = ^raised^ `^` = ^raised^
# TODO # To do
- Sub-headers (`## h2`, `### h3` etc) - Sub-headers (`## h2`, `### h3` etc)
- Hotkey Editor - Hotkey Editor
- International keyboard algorithm for non-letter keys - International keyboard algorithm for non-letter keys

View File

@ -1,4 +1,4 @@
// TODO: automatic cache eviction // TODO(jprochazk): automatic cache eviction
/// Installs a set of image loaders. /// Installs a set of image loaders.
/// ///

View File

@ -106,7 +106,7 @@ pub struct AxisHints {
pub(super) label_spacing: Rangef, pub(super) label_spacing: Rangef,
} }
// TODO: this just a guess. It might cease to work if a user changes font size. // TODO(JohannesProgrammiert): this just a guess. It might cease to work if a user changes font size.
const LINE_HEIGHT: f32 = 12.0; const LINE_HEIGHT: f32 = 12.0;
impl AxisHints { impl AxisHints {
@ -366,7 +366,7 @@ impl AxisWidget {
match HPlacement::from(self.hints.placement) { match HPlacement::from(self.hints.placement) {
HPlacement::Left => { HPlacement::Left => {
let angle = 0.0; // TODO: allow users to rotate text let angle = 0.0; // TODO(emilk): allow users to rotate text
if angle == 0.0 { if angle == 0.0 {
let x = self.rect.max.x - galley.size().x; let x = self.rect.max.x - galley.size().x;

View File

@ -156,7 +156,7 @@ impl Default for Orientation {
pub enum PlotPoints { pub enum PlotPoints {
Owned(Vec<PlotPoint>), Owned(Vec<PlotPoint>),
Generator(ExplicitGenerator), Generator(ExplicitGenerator),
// Borrowed(&[PlotPoint]), // TODO: Lifetimes are tricky in this case. // Borrowed(&[PlotPoint]), // TODO(EmbersArc): Lifetimes are tricky in this case.
} }
impl Default for PlotPoints { impl Default for PlotPoints {

View File

@ -800,7 +800,7 @@ impl Plot {
let plot_id = id.unwrap_or_else(|| ui.make_persistent_id(id_source)); let plot_id = id.unwrap_or_else(|| ui.make_persistent_id(id_source));
let ([x_axis_widgets, y_axis_widgets], plot_rect) = axis_widgets( let ([x_axis_widgets, y_axis_widgets], plot_rect) = axis_widgets(
PlotMemory::load(ui.ctx(), plot_id).as_ref(), // TODO: avoid loading plot memory twice PlotMemory::load(ui.ctx(), plot_id).as_ref(), // TODO(emilk): avoid loading plot memory twice
show_axes, show_axes,
complete_rect, complete_rect,
[&x_axes, &y_axes], [&x_axes, &y_axes],

View File

@ -192,7 +192,7 @@ impl PaintStats {
fn add(&mut self, shape: &Shape) { fn add(&mut self, shape: &Shape) {
match shape { match shape {
Shape::Vec(shapes) => { Shape::Vec(shapes) => {
// self += PaintStats::from_shapes(&shapes); // TODO // self += PaintStats::from_shapes(&shapes); // TODO(emilk)
self.shapes += AllocInfo::from_slice(shapes); self.shapes += AllocInfo::from_slice(shapes);
self.shape_vec += AllocInfo::from_slice(shapes); self.shape_vec += AllocInfo::from_slice(shapes);
for shape in shapes { for shape in shapes {

View File

@ -1864,7 +1864,7 @@ impl Tessellator {
.filter(|(_, clipped_shape)| should_parallelize(&clipped_shape.shape)) .filter(|(_, clipped_shape)| should_parallelize(&clipped_shape.shape))
.map(|(index, clipped_shape)| { .map(|(index, clipped_shape)| {
crate::profile_scope!("tessellate_big_shape"); crate::profile_scope!("tessellate_big_shape");
// TODO: reuse tessellator in a thread local // TODO(emilk): reuse tessellator in a thread local
let mut tessellator = (*self).clone(); let mut tessellator = (*self).clone();
let mut mesh = Mesh::default(); let mut mesh = Mesh::default();
tessellator.tessellate_shape(clipped_shape.shape.clone(), &mut mesh); tessellator.tessellate_shape(clipped_shape.shape.clone(), &mut mesh);

View File

@ -960,7 +960,7 @@ fn is_kana(c: char) -> bool {
#[inline] #[inline]
fn is_cjk(c: char) -> bool { fn is_cjk(c: char) -> bool {
// TODO: Add support for Korean Hangul. // TODO(bigfarts): Add support for Korean Hangul.
is_cjk_ideograph(c) || is_kana(c) is_cjk_ideograph(c) || is_kana(c)
} }

View File

@ -441,7 +441,7 @@ fn drag_source<R>(
} }
} }
// TODO: Update to be more like `crates/egui_demo_lib/src/debo/drag_and_drop.rs` // TODO(emilk): Update to be more like `crates/egui_demo_lib/src/debo/drag_and_drop.rs`
fn drop_target<R>( fn drop_target<R>(
ui: &mut egui::Ui, ui: &mut egui::Ui,
body: impl FnOnce(&mut egui::Ui) -> R, body: impl FnOnce(&mut egui::Ui) -> R,

View File

@ -36,7 +36,7 @@ def lint_lines(filepath, lines_in):
for line_nr, line in enumerate(lines_in): for line_nr, line in enumerate(lines_in):
line_nr = line_nr + 1 line_nr = line_nr + 1
# TODO: only # and /// on lines before a keyword # TODO(emilk): only # and /// on lines before a keyword
pattern = ( pattern = (
r"^\s*((///)|((pub(\(\w*\))? )?((impl|fn|struct|enum|union|trait)\b))).*$" r"^\s*((///)|((pub(\(\w*\))? )?((impl|fn|struct|enum|union|trait)\b))).*$"
@ -66,6 +66,12 @@ def lint_lines(filepath, lines_in):
) )
lines_out.append("#[inline]") lines_out.append("#[inline]")
if re.search(r"TODO[^(]", line):
errors.append(
f"{filepath}:{line_nr}: write 'TODO(username):' instead"
)
if ( if (
"(target_os" in line "(target_os" in line
and filepath.startswith("./crates/egui/") and filepath.startswith("./crates/egui/")