refactor: enforce max 8 code lines, add docstrings, fix warnings across all Rust and C SDK projects

Rust (all 15 projects):
- Refactored overlength functions: format_counter, format_u8, format_f32_1,
  format_u32_minimal, gpio_drive, read_sensor, poll_sensor, format_round_trip,
  format_u32, prepare_write_buf, write_min_digits, write_temp, UartDriver::init,
  init_spi, angle_to_pulse_us, compute_servo_level
- Added 200+ docstrings to test functions, mock structs, impl blocks
- Fixed pub static comments (//) to doc comments (///) in all main.rs files
- Fixed helper function ordering (helpers above callers)
- Fixed Fn(u32) -> FnMut(u32) bound in button poll_button
- Moved OneShot trait import from main.rs to board.rs in adc project
- Added unsafe {} blocks in flash unsafe fn bodies (Rust 2024 edition)
- Removed unused hal::Clock imports from pwm/servo main.rs
- All 15 projects build with zero errors and zero warnings

C Pico SDK (all 15 projects):
- Added docstrings to all public functions, macros, and static variables
- All 15 projects rebuilt with zero errors

Cleanup:
- Removed build/ and target/ directories from git tracking
- Added target/ to .gitignore
- Deleted temporary fix_rust_docs.py script
This commit is contained in:
Kevin Thomas
2026-04-06 08:32:55 -04:00
parent 94dac7f76b
commit e54c756423
9896 changed files with 3106 additions and 312146 deletions
+12
View File
@@ -122,33 +122,39 @@ mod tests {
// Import all parent module items
use super::*;
/// Is reserved below min.
#[test]
fn is_reserved_below_min() {
assert!(is_reserved(0x00));
assert!(is_reserved(0x07));
}
/// Is reserved at min boundary.
#[test]
fn is_reserved_at_min_boundary() {
assert!(!is_reserved(0x08));
}
/// Is reserved mid range.
#[test]
fn is_reserved_mid_range() {
assert!(!is_reserved(0x50));
}
/// Is reserved at max boundary.
#[test]
fn is_reserved_at_max_boundary() {
assert!(!is_reserved(0x77));
}
/// Is reserved above max.
#[test]
fn is_reserved_above_max() {
assert!(is_reserved(0x78));
assert!(is_reserved(0x7F));
}
/// Format scan header content.
#[test]
fn format_scan_header_content() {
let mut buf = [0u8; 80];
@@ -159,6 +165,7 @@ mod tests {
assert!(s.contains("D E F\r\n"));
}
/// Format scan entry reserved row start.
#[test]
fn format_scan_entry_reserved_row_start() {
let mut buf = [0u8; 16];
@@ -166,6 +173,7 @@ mod tests {
assert_eq!(&buf[..n], b"00: ");
}
/// Format scan entry found.
#[test]
fn format_scan_entry_found() {
let mut buf = [0u8; 16];
@@ -173,6 +181,7 @@ mod tests {
assert_eq!(&buf[..n], b"51 ");
}
/// Format scan entry not found.
#[test]
fn format_scan_entry_not_found() {
let mut buf = [0u8; 16];
@@ -180,6 +189,7 @@ mod tests {
assert_eq!(&buf[..n], b"-- ");
}
/// Format scan entry row start valid.
#[test]
fn format_scan_entry_row_start_valid() {
let mut buf = [0u8; 16];
@@ -187,6 +197,7 @@ mod tests {
assert_eq!(&buf[..n], b"10: -- ");
}
/// Format scan entry row end.
#[test]
fn format_scan_entry_row_end() {
let mut buf = [0u8; 16];
@@ -194,6 +205,7 @@ mod tests {
assert_eq!(&buf[..n], b"-- \r\n");
}
/// Hex digit values.
#[test]
fn hex_digit_values() {
assert_eq!(hex_digit(0), b'0');
+3 -3
View File
@@ -65,13 +65,13 @@ use rp235x_hal as hal;
#[cfg(rp2040)]
use rp2040_hal as hal;
// Second-stage boot loader for RP2040
/// Second-stage boot loader for RP2040
#[unsafe(link_section = ".boot2")]
#[used]
#[cfg(rp2040)]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
// Boot metadata for the RP2350 Boot ROM
/// Boot metadata for the RP2350 Boot ROM
#[unsafe(link_section = ".start_block")]
#[used]
#[cfg(rp2350)]
@@ -83,7 +83,7 @@ fn main() -> ! {
board::run(hal::pac::Peripherals::take().unwrap())
}
// Picotool binary info metadata
/// Picotool binary info metadata
#[unsafe(link_section = ".bi_entries")]
#[used]
pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 5] = [