Skip to content

Commit e445c18

Browse files
authored
Fix a number of spelling errors in the documentation (#433)
* Add missing doc comments for error types * Fix a number of spelling errors in the documentation * Minor improvements to errors * Capitalize acronyms
1 parent e5f0e17 commit e445c18

File tree

13 files changed

+42
-33
lines changed

13 files changed

+42
-33
lines changed

cargo-espflash/src/error.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum Error {
2121
#[error("The current workspace is invalid, and could not be loaded")]
2222
#[diagnostic(
2323
code(cargo_espflash::invalid_workspace),
24-
help("Ensure that a valid Cargo.toml file is in the executing directory")
24+
help("Ensure that a valid `Cargo.toml` file is in the executing directory")
2525
)]
2626
InvalidWorkspace,
2727

@@ -45,9 +45,9 @@ pub enum Error {
4545
code(cargo_espflash::no_build_std),
4646
help(
4747
"Cargo currently requires the unstable 'build-std' feature, ensure \
48-
that .cargo/config{{.toml}} has the appropriate options.\n \
49-
\tSee: https://doc.rust-lang.org/cargo/reference/unstable.html#build-std"
50-
)
48+
that `.cargo/config{{.toml}}` has the appropriate options."
49+
),
50+
url("https://doc.rust-lang.org/cargo/reference/unstable.html#build-std")
5151
)]
5252
NoBuildStd,
5353

@@ -59,7 +59,7 @@ pub enum Error {
5959
)]
6060
NoPackage,
6161

62-
#[error("No Cargo.toml found in the current directory")]
62+
#[error("No `Cargo.toml` found in the current directory")]
6363
#[diagnostic(
6464
code(cargo_espflash::no_project),
6565
help("Ensure that you're running the command from within a Cargo project")

espflash/src/cli/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ pub struct Config {
8282
/// Preferred USB devices
8383
#[serde(default)]
8484
pub usb_device: Vec<UsbDevice>,
85-
/// Path of the file to save the config to
85+
/// Path of the file to save the configuration to
8686
#[serde(skip)]
8787
save_path: PathBuf,
8888
}
8989

9090
impl Config {
91-
/// Load the config from config file
91+
/// Load configuration from the configuration file
9292
pub fn load() -> Result<Self> {
9393
let dirs = ProjectDirs::from("rs", "esp", "espflash").unwrap();
9494
let file = dirs.config_dir().join("espflash.toml");
@@ -102,7 +102,7 @@ impl Config {
102102
Ok(config)
103103
}
104104

105-
/// Save the config to the config file
105+
/// Save configuration to the configuration file
106106
pub fn save_with<F: Fn(&mut Self)>(&self, modify_fn: F) -> Result<()> {
107107
let mut copy = self.clone();
108108
modify_fn(&mut copy);

espflash/src/cli/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub struct PartitionTableArgs {
120120
/// Input partition table
121121
#[arg(value_name = "FILE")]
122122
partition_table: PathBuf,
123-
/// Convert CSV parition table to binary representation
123+
/// Convert CSV partition table to binary representation
124124
#[arg(long, conflicts_with = "to_csv")]
125125
to_binary: bool,
126126
/// Convert binary partition table to CSV representation

espflash/src/cli/serial.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ fn find_serial_port(ports: &[SerialPortInfo], name: &str) -> Result<SerialPortIn
104104
}
105105
}
106106

107-
/// Serialport's autodetect doesn't provide any port information when using musl
108-
/// linux we can do some manual parsing of sysfs to get the relevant bits
107+
/// Serialport's auto-detect doesn't provide any port information when using MUSL
108+
/// Linux we can do some manual parsing of sysfs to get the relevant bits
109109
/// without udev
110110
#[cfg(all(target_os = "linux", target_env = "musl"))]
111111
fn detect_usb_serial_ports() -> Result<Vec<SerialPortInfo>> {
@@ -186,7 +186,7 @@ fn detect_usb_serial_ports() -> Result<Vec<SerialPortInfo>> {
186186
Ok(ports)
187187
}
188188

189-
/// USB UART adapters which are known to be on common dev boards
189+
/// USB UART adapters which are known to be on common development boards
190190
const KNOWN_DEVICES: &[UsbDevice] = &[
191191
UsbDevice {
192192
vid: 0x10c4,

espflash/src/connection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ impl Connection {
164164
Ok(())
165165
}
166166

167-
/// Set baudrate for the serial port
167+
/// Set baud rate for the serial port
168168
pub fn set_baud(&mut self, speed: u32) -> Result<(), Error> {
169169
self.serial.serial_port_mut().set_baud_rate(speed)?;
170170

171171
Ok(())
172172
}
173173

174-
/// Get the current baudrate of the serial port
174+
/// Get the current baud rate of the serial port
175175
pub fn get_baud(&self) -> Result<u32, Error> {
176176
Ok(self.serial.serial_port().baud_rate()?)
177177
}

espflash/src/error.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::{
1818
targets::Chip,
1919
};
2020

21+
/// All possible errors returned by espflash
2122
#[derive(Debug, Diagnostic, Error)]
2223
#[non_exhaustive]
2324
pub enum Error {
@@ -172,6 +173,7 @@ impl From<SerialConfigError> for Error {
172173
}
173174
}
174175

176+
/// Connection-related errors
175177
#[derive(Debug, Diagnostic, Error)]
176178
#[non_exhaustive]
177179
pub enum ConnectionError {
@@ -253,6 +255,7 @@ impl From<SlipError> for ConnectionError {
253255
}
254256
}
255257

258+
/// An executed command which has timed out
256259
#[derive(Clone, Debug, Default)]
257260
pub struct TimedOutCommand {
258261
command: Option<CommandType>,
@@ -273,6 +276,7 @@ impl From<CommandType> for TimedOutCommand {
273276
}
274277
}
275278

279+
/// Errors originating from a device's ROM functionality
276280
#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, FromRepr)]
277281
#[non_exhaustive]
278282
#[repr(u8)]
@@ -357,6 +361,7 @@ impl From<u8> for RomErrorKind {
357361
}
358362
}
359363

364+
/// An error originating from a device's ROM functionality
360365
#[derive(Clone, Copy, Debug, Diagnostic, Error)]
361366
#[error("Error while running {command} command")]
362367
#[non_exhaustive]
@@ -372,6 +377,7 @@ impl RomError {
372377
}
373378
}
374379

380+
/// Missing partition error
375381
#[derive(Debug, Diagnostic, Error)]
376382
#[error("Missing partition")]
377383
#[diagnostic(
@@ -386,6 +392,7 @@ impl From<String> for MissingPartition {
386392
}
387393
}
388394

395+
/// Missing partition table error
389396
#[derive(Debug, Error, Diagnostic)]
390397
#[error("No partition table could be found")]
391398
#[diagnostic(
@@ -394,6 +401,7 @@ impl From<String> for MissingPartition {
394401
)]
395402
pub struct MissingPartitionTable;
396403

404+
/// Invalid ELF file error
397405
#[derive(Debug, Error)]
398406
#[error("{0}")]
399407
pub struct ElfError(&'static str);
@@ -404,7 +412,7 @@ impl From<&'static str> for ElfError {
404412
}
405413
}
406414

407-
/// Uunsuported image format error
415+
/// Unsupported image format error
408416
#[derive(Debug)]
409417
pub struct UnsupportedImageFormatError {
410418
format: ImageFormatKind,
@@ -434,7 +442,7 @@ impl UnsupportedImageFormatError {
434442
.join(", ")
435443
}
436444

437-
/// Update the context of the unsported image format error
445+
/// Update the context of the unsupported image format error
438446
pub fn with_context(mut self, ctx: String) -> Self {
439447
self.context.replace(ctx);
440448

espflash/src/flasher/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl FlashSize {
139139
/// Encodes flash size into the format used by the bootloader.
140140
///
141141
/// ## Values:
142-
/// * [Esp8266](https://docs.espressif.com/projects/esptool/en/latest/esp8266/advanced-topics/firmware-image-format.html#file-header)
142+
/// * [ESP8266](https://docs.espressif.com/projects/esptool/en/latest/esp8266/advanced-topics/firmware-image-format.html#file-header)
143143
/// * [Others](https://docs.espressif.com/projects/esptool/en/latest/esp32s3/advanced-topics/firmware-image-format.html#file-header)
144144
pub const fn encode_flash_size(self: FlashSize, chip: Chip) -> Result<u8, Error> {
145145
use FlashSize::*;
@@ -280,7 +280,7 @@ impl SpiAttachParams {
280280
}
281281
}
282282

283-
/// List of spi params to try while detecting flash size
283+
/// List of SPI parameters to try while detecting flash size
284284
const TRY_SPI_PARAMS: [SpiAttachParams; 2] =
285285
[SpiAttachParams::default(), SpiAttachParams::esp32_pico_d4()];
286286

@@ -333,7 +333,7 @@ pub trait ProgressCallbacks {
333333
fn init(&mut self, addr: u32, total: usize);
334334
/// Update some progress report
335335
fn update(&mut self, current: usize);
336-
/// Finish some prgoress report
336+
/// Finish some progress report
337337
fn finish(&mut self);
338338
}
339339

@@ -686,7 +686,7 @@ impl Flasher {
686686
Ok(info)
687687
}
688688

689-
/// Load an elf image to ram and execute it
689+
/// Load an ELF image to RAM and execute it
690690
///
691691
/// Note that this will not touch the flash on the device
692692
pub fn load_elf_to_ram(
@@ -716,7 +716,7 @@ impl Flasher {
716716
target.finish(&mut self.connection, true).flashing()
717717
}
718718

719-
/// Load an elf image to flash and execute it
719+
/// Load an ELF image to flash and execute it
720720
pub fn load_elf_to_flash_with_format(
721721
&mut self,
722722
elf_data: &[u8],
@@ -756,7 +756,7 @@ impl Flasher {
756756
flash_freq,
757757
)?;
758758

759-
// When the "cli" feature is enabled, display the image size information.
759+
// When the `cli` feature is enabled, display the image size information.
760760
#[cfg(feature = "cli")]
761761
crate::cli::display_image_size(image.app_size(), image.part_size());
762762

@@ -791,7 +791,7 @@ impl Flasher {
791791
Ok(())
792792
}
793793

794-
/// Load an elf image to flash and execute it
794+
/// Load an ELF image to flash and execute it
795795
pub fn load_elf_to_flash(
796796
&mut self,
797797
elf_data: &[u8],

espflash/src/flasher/stubs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::targets::Chip;
88
pub struct FlashStub {
99
/// Entry point (address)
1010
entry: u32,
11-
/// Text (b64 encoded)
11+
/// Text (base64 encoded)
1212
text: String,
1313
/// Start of text section address
1414
text_start: u32,

espflash/src/image_format/idf_bootloader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ impl<'a> ImageFormat<'a> for IdfBootloaderFormat<'a> {
213213
}
214214

215215
/// Actual alignment (in data bytes) required for a segment header: positioned
216-
/// so that after we write the next 8 byte header, file_offs % IROM_ALIGN ==
216+
/// so that after we write the next 8 byte header, file_offset % IROM_ALIGN ==
217217
/// segment.addr % IROM_ALIGN
218218
///
219219
/// (this is because the segment's vaddr may not be IROM_ALIGNed, more likely is
220-
/// aligned IROM_ALIGN+0x18 to account for the binary file header
220+
/// aligned IROM_ALIGN+0x18 to account for the binary file header)
221221
fn get_segment_padding(offset: usize, segment: &CodeSegment) -> u32 {
222222
let align_past = (segment.addr - SEG_HEADER_LEN) % IROM_ALIGN;
223223
let pad_len = ((IROM_ALIGN - ((offset as u32) % IROM_ALIGN)) + align_past) % IROM_ALIGN;

espflash/src/image_format/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ struct SegmentHeader {
117117

118118
/// Operations for working with firmware image formats
119119
pub trait ImageFormat<'a>: Send {
120-
/// Get the rom segments needed when flashing to device
120+
/// Get the ROM segments needed when flashing to device
121121
fn flash_segments<'b>(&'b self) -> Box<dyn Iterator<Item = RomSegment<'b>> + 'b>
122122
where
123123
'a: 'b;
124124

125-
/// Get the rom segments to save when exporting for ota
125+
/// Get the ROM segments to save when exporting for OTA
126126
///
127127
/// Compared to `flash_segments` this excludes things like bootloader and
128128
/// partition table

espflash/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub mod image_format;
5858
pub mod interface;
5959
pub mod targets;
6060

61-
/// Logging utilties
61+
/// Logging utilities
6262
#[cfg(feature = "cli")]
6363
#[cfg_attr(docsrs, doc(cfg(feature = "cli")))]
6464
pub mod logging {

espflash/src/targets/esp32s2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Esp32s2 {
5757
Ok(flash_version)
5858
}
5959

60-
/// Return the psram version based on eFuses
60+
/// Return the PSRAM version based on eFuses
6161
fn get_psram_version(&self, connection: &mut Connection) -> Result<u32, Error> {
6262
let blk1_word3 = self.read_efuse(connection, 20)?;
6363
let psram_version = (blk1_word3 >> 28) & 0xf;

espflash/src/targets/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mod esp32s3;
4444
mod esp8266;
4545
mod flash_target;
4646

47-
/// Enumeration of all supported devices
47+
/// All supported devices
4848
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
4949
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display, EnumIter, EnumString, EnumVariantNames)]
5050
#[non_exhaustive]
@@ -165,8 +165,9 @@ impl Esp32Params {
165165
}
166166

167167
/// Generates a default partition table.
168+
///
168169
/// `flash_size` is used to scale app partition when present, otherwise the
169-
/// param defaults are used.
170+
/// paramameter defaults are used.
170171
pub fn default_partition_table(&self, flash_size: Option<u32>) -> PartitionTable {
171172
PartitionTable::new(vec![
172173
Partition::new(
@@ -261,7 +262,7 @@ pub trait Target: ReadEFuse {
261262
/// Enumerate the chip's features, read from eFuse
262263
fn chip_features(&self, connection: &mut Connection) -> Result<Vec<&str>, Error>;
263264

264-
/// Deterimine the chip's revision number
265+
/// Determine the chip's revision number
265266
fn chip_revision(&self, connection: &mut Connection) -> Result<(u32, u32), Error> {
266267
let major = self.major_chip_version(connection)?;
267268
let minor = self.minor_chip_version(connection)?;

0 commit comments

Comments
 (0)