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

doc: dash used instead of minus in mathematical expressions #90793

Closed
tspiteri opened this issue Nov 11, 2021 · 3 comments · Fixed by #93612
Closed

doc: dash used instead of minus in mathematical expressions #90793

tspiteri opened this issue Nov 11, 2021 · 3 comments · Fixed by #93612

Comments

@tspiteri
Copy link
Contributor

tspiteri commented Nov 11, 2021

The minus sign in mathematical expressions for i*::MIN, i*::MAX and u*::MAX is rendered using U+002D (see images below). U+002D looks bad in that context; U+2212 is more suitable and looks better in mathematical expressions.

Note: I had already opened PR #90777 to fix this, but it was closed. I opened the issue to discuss this here instead of in an already-closed PR. The reason given for closing is:

In Rust, negative numbers are expressed using U+002D HYPHEN-MINUS, and our documentation should be consistent with Rust code, rather than using a confusingly similar symbol.

But I don't agree with that: here the minus sign is in a mathematical expression that is not code. If it were an expression in verbatim code then yes, U+002D would be better, but for example −231 cannot be written in code anyway (the code -2i32.pow(31) wouldn't even work).

image
image
image

@tspiteri tspiteri changed the title doc: dash used instead of hyphen in mathematical expressions doc: dash used instead of minus in mathematical expressions Nov 11, 2021
@wooster0
Copy link
Contributor

wooster0 commented Nov 11, 2021

CC @joshtriplett

Now I'm less confused. You are making a good point. I think there are a few options here:

  1. Write it as -2_i64.pow(31)? Although the different type might be confusing.
  2. -2_i64.pow(31) as i32? It might be too long.
  3. Change it to U+2212? I think using a special character like that makes it harder for others to conform to this style because it's not as easy to type and easy to mistake for the - that's easy to type.
  4. Change it to U+002D? It's easy to type and most people will probably use this one but I agree that U+2212 kind of is more suitable for mathematical expressions.

I think what we ultimately need is a documentation guide for mathematical expressions, or even better (or rather in addition) a way to write -2.pow(31) in the doc comment and then have the markdown renderer automatically convert it to −231. The idea is that type annotation wouldn't be needed in such special doc comment math expression. Maybe it could look like

/// The smallest value that can be represented by this integer type, <`-2.pow(31)`>.

or something like that.
But I think a complete documentation guide that everyone is actively encouraged to follow is a good first step for documentation consistency.

But ultimately there is generally tons of inconsistency in documentation and I think it's pretty much normal, especially in such a large project. So maybe it's fine to just merge those occasional fixup PRs like #90777 to keep some consistency.

@tspiteri
Copy link
Contributor Author

Options 1 and 2 are not really something I'd ever go for. When I wrote -2i32.pow(31) my point was to emphasize that the expression wasn't code; those code expressions would not make the MIN and MAX documentation any easier to read and understand, rather the opposite.

@nagisa
Copy link
Member

nagisa commented Feb 3, 2022

I would argue that using MathML would be ideal in terms of presentation here. If we wanted to utilize math expressions at scale in our documentations, adding support for (la-)tex-like math to our markdown-html converter would also make some sense.

Sadly neither are easy fixes – MathML isn't super widely supported out-of-the-box and the latter feature is effectively a pandoc exclusive feature AFAIK.

@bors bors closed this as completed in 9ba09f9 Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants