Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix before_snippet failing in release #2040

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions esp-hal-embassy/src/executor/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ impl Executor {
multi_core,
doc = r#"

This will use software-interrupt 3 which isn't
available for anything else to wake the other core(s).
"#
This will use software-interrupt 3 which isn't available for anything else to wake the other core(s)."#
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: could not parse code block as Rust code
  --> src\executor\thread.rs:70:5
   |
70 | /     /// Create a new Executor.
71 | |     #[cfg_attr(
72 | |         multi_core,
73 | |         doc = r#"
...  |
76 | |     available for anything else to wake the other core(s).
77 | |     "#
   | |______^
   |
   = note: error from rustc: prefix `isn` is unknown
   = note: `#[warn(rustdoc::invalid_rust_codeblocks)]` on by default

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did that show up for you? Don't think I've seen this before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built the documentation for esp-hal-embassy, which we don't usually do.

)]
pub fn new() -> Self {
#[cfg(multi_core)]
Expand Down
6 changes: 0 additions & 6 deletions esp-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ fn main() -> Result<(), Box<dyn Error>> {
)?;
}

// needed for before_snippet! macro
let host = env::var_os("HOST").expect("HOST not set");
if let Some("windows") = host.to_str().unwrap().split('-').nth(2) {
println!("cargo:rustc-cfg=host_os=\"windows\"");
}

// With the architecture-specific linker scripts taken care of, we can copy all
// remaining linker scripts which are common to all devices:
copy_dir_all(&config_symbols, "ld/sections", &out)?;
Expand Down
12 changes: 0 additions & 12 deletions esp-hal/doc-helper/before

This file was deleted.

32 changes: 14 additions & 18 deletions esp-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,26 +621,22 @@ unsafe extern "C" fn stack_chk_fail() {

#[doc(hidden)]
/// Helper macro for checking doctest code snippets
#[cfg(not(host_os = "windows"))]
#[macro_export]
macro_rules! before_snippet {
() => {
core::include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../esp-hal/doc-helper/before"
))
};
}

#[doc(hidden)]
/// Helper macro for checking doctest code snippets
#[cfg(host_os = "windows")]
#[macro_export]
macro_rules! before_snippet {
() => {
core::include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"\\..\\esp-hal\\doc-helper\\before"
))
r#"
# #![no_std]
# use esp_hal::peripherals::Peripherals;
# use esp_hal::clock::ClockControl;
# use esp_hal::system::SystemControl;
# #[panic_handler]
# fn panic(_ : &core::panic::PanicInfo) -> ! {
# loop {}
# }
# fn main() {
# let peripherals = Peripherals::take();
# let system = SystemControl::new(peripherals.SYSTEM);
# let mut clocks = ClockControl::boot_defaults(system.clock_control).freeze();
"#
};
}
2 changes: 1 addition & 1 deletion esp-hal/src/mcpwm/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool>
///
/// # H-Bridge example
/// ```rust, no_run
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/doc-helper/before"))]
#[doc = crate::before_snippet!()]
/// # use esp_hal::{mcpwm, prelude::*};
/// # use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
/// # use esp_hal::mcpwm::operator::{DeadTimeCfg, PwmPinConfig, PWMStream};
Expand Down