zed icon indicating copy to clipboard operation
zed copied to clipboard

API Example usage dont show in the autocomplete window

Open Iovans opened this issue 1 year ago • 5 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

When i see the api docs on the autocomplete window it doesnt show the example usage

Environment

Zed: v0.123.6 (Zed) OS: macOS 14.2.1 Memory: 8 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

![Screenshot 2024-02-24 alle 21 16 22](https://github.com/zed- Screenshot 2024-02-24 alle 21 16 22

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

Iovans avatar Feb 24 '24 20:02 Iovans

Not sure why, but the actual rust docs do not specify an example, you can see it here.

It works perfectly fine for i32::wrapping_rem(...), which actually has an example: image

bennetbo avatar Feb 24 '24 20:02 bennetbo

the example that you gave me dont work because is an experimental api and that reasonable, but in my case are not experimental, it should shows the code!

Iovans avatar Feb 24 '24 21:02 Iovans

Sorry, looks like I am the one that got confused there. For some reason I thought the rust doc itself is empty. Looks like there is something wrong with the rendering indeed.

Edit: VS Code doesn't seem to display it either image

While it works for wrapping_rem image

Maybe the markdown is malformed or the language server is having some kind of issue, but I cannot find the actual markdown source of i32::checked_abs without the macros It uses.

Here is the documentation of checked_abs

/// Checked absolute value. Computes `self.abs()`, returning `None` if
/// `self == MIN`.
///
/// # Examples
///
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").checked_abs(), Some(5));")]
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_abs(), None);")]
/// ```

Here is the documentation of wrapping_add

/// Wrapping (modular) remainder. Computes `self % rhs`, wrapping around at the
/// boundary of the type.
///
/// Such wrap-around never actually occurs mathematically; implementation artifacts make `x % y`
/// invalid for `MIN / -1` on a signed type (where `MIN` is the negative minimal value). In such a case,
/// this function returns `0`.
///
/// # Panics
///
/// This function will panic if `rhs` is 0.
///
/// # Examples
///
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);")]  //This line is missing
/// assert_eq!((-128i8).wrapping_rem(-1), 0);                                     //This line gets rendered
/// ```

Im not sure what #[doc ...] is doing but those lines seem to be missing when rendering the docs in zed/vscode. As you can see in the i32::wrapping_rem docs, the last line is displayed fine for the example code, but the line above seems to be missing.

bennetbo avatar Feb 24 '24 21:02 bennetbo

Looks like this is an issue of the language server (rust-analyzer), see https://github.com/rust-lang/rust-analyzer/issues/7688

bennetbo avatar Feb 24 '24 22:02 bennetbo

okay thank you for tell me about it, they are fixing it right?

Iovans avatar Feb 24 '24 23:02 Iovans

Closing this, since we've identified it as an upstream issue.

maxdeviant avatar Feb 26 '24 23:02 maxdeviant