ex_doc icon indicating copy to clipboard operation
ex_doc copied to clipboard

Add links to jump to latest version of docs

Open pdavies opened this issue 1 year ago • 6 comments

Hello! 👋

This PR addresses #1917 . It adds support for specifying which version is the latest via docs_config.js:

var versionNodes = [
    { version: 'v1.0.0', url: '/foo'},
    { version: 'v2.0.0', url: "/bar", latest: true },
    { version: 'v0.34.0-dev', url: "/baz" }
];

which will trigger a warning hyperlink to the latest version when viewing other versions:

image

It is not required to have a latest version in docs_config.js. Existing docs_config.js files will continue to produce the existing behaviour with no warning links.

Rather than try to determine which version is the latest through javascript logic, it seemed more appropriate to delegate to the author of docs_config.js, for example hexdocs. This avoids the risk of behaviour that differs from the documentation host's opinion on which version is the latest. This does mean that the PR doesn't do anything interesting without a small enhancement to (in practice) hexdocs.

This PR has the drawback that docs published prior to this PR will not get warnings. But due to the way exdocs works, I don't see how any attempt at fixing #1917 could get around this.

pdavies avatar Jun 10 '24 21:06 pdavies

This looks good to me but the indicator is calling too much attention. What if we keep only the warning sign? And then on mouse over it says this is not the latest version and you can click it to update?

josevalim avatar Jun 11 '24 06:06 josevalim

@josevalim I think that it would be better to have the words than the warning sign for mobile users, since there is no "mouse over" capability there. I think the colours could definitely be muted, but from an accessibility point of view, words are better.

halostatue avatar Jun 11 '24 15:06 halostatue

On mobile, we usually render the project name and version on every page, below the title, because the sidebar is not open. Shall we have the go to latest there instead (for mobile)?

josevalim avatar Jun 11 '24 15:06 josevalim

I think so, but it might be something worth rethinking the render, because having that as a parenthetical next to a parenthetical is odd.

mobile-ish rendering of Oban docs

halostatue avatar Jun 11 '24 15:06 halostatue

Thanks for the feedback!

Visuals: I agree the white on red is unpleasant and should be toned down. It also did not play nicely with light/dark theming. However there is a balance to strike - if it isn't eyecatching, it isn't useful. I've revised the appearance to be theme-aware and less painful on the eyes. It still isn't beautiful but I'd need to defer to someone with better frontend design skills to improve it any further!

Mobile view: I hadn't given any thought to this. My preference would be to tackle that separately - more honestly for someone else to tackle that separately. This is mainly because I'm not sure how I would get the necessary information to module_template.eex in a nice way.

image image

pdavies avatar Jun 12 '24 12:06 pdavies

Hello there, this PR slipped off my radar but I was reminded of it by this tweet: https://x.com/jskalc/status/1816920900660236370

I've pushed a change to address @halostatue's suggestion. Anything more you need from me here? Keen to get it in if possible!

pdavies avatar Aug 06 '24 14:08 pdavies

Is there any action on me to get this over the line?

pdavies avatar Dec 02 '24 15:12 pdavies

Hi @pdavies, I believe the only blocker is making this fit visually. Perhaps just an alert icon after the version selector is enough? On mouse over we could say "Go to latest version", which will be done on click? Unsure.

josevalim avatar Dec 02 '24 17:12 josevalim

Someone dropped a suggestion on the forum which I quite like:

https://elixirforum.com/t/search-engines-return-old-library-versions/58873/10

image

image

What do you think? It is quite subtle but probably enough to portray the meaning. Then the person can click on the select to go to latest. So no additional buttons needed.

josevalim avatar Dec 24 '24 19:12 josevalim

Great idea 👌👌👌

zachdaniel avatar Dec 24 '24 19:12 zachdaniel

Can we go regular color for latest, otherwise orange, i.e. no green? This would be subjectively less busy visually. The downside would be for docs generated with prior ExDoc versions there would be no difference but less of an issue in the long term.

wojtekmach avatar Dec 24 '24 20:12 wojtekmach

@josevalim The problem with the colour approach is red-green colour blindness. I think that some sort of iconography or plain text is going to be best and most accessible.

halostatue avatar Jan 07 '25 19:01 halostatue

@halostatue what if we just show yellow/orange if outdated? No need to show it on green if latest.

I am also open to using icons, if there is a good suggestion. But if we don't have one such proposal for now, my suggestion is to ship this and we continue refining it in the future (adding icons, notifications, etc).

josevalim avatar Jan 07 '25 20:01 josevalim

@pdavies, are you ok with someone else carrying this over the finish line or do you want some time? It is your call, it was pending on the ExDoc team decision for sometime anyway. Thanks!

josevalim avatar Jan 07 '25 22:01 josevalim

Simulated deuteranopia

CleanShot 2025-01-07 at 21 36 04@2x

Simulated Deuteranomaly

CleanShot 2025-01-07 at 21 36 56@2x

Simullated Protanopia

CleanShot 2025-01-07 at 21 37 40@2x

Simulated Protanomaly

CleanShot 2025-01-07 at 21 38 14@2x

Simulated Tritanopia

CleanShot 2025-01-07 at 21 39 00@2x

Simulated Tritanopoly

CleanShot 2025-01-07 at 21 39 34@2x

Simulated Monochromacy

CleanShot 2025-01-07 at 21 40 02@2x

Simulated Partial Monochromacy

CleanShot 2025-01-07 at 21 40 43@2x

All of this is with SimDaltonism: https://github.com/michelf/sim-daltonism for macOS.

(I am not colour blind myself, but I have a friend who is.)

halostatue avatar Jan 08 '25 02:01 halostatue

Thank you, those are helpful. Given we only plan to highlight it when it is outdated, we can compare the color of the version with the “Elixir” title in the first example, and it seems it is noticeable in all images. So we can move forward.

although I also I think the color is too subtle overall, even in regular cases without the simulation, so we should definitely have additional mechanisms or icons. Suggestions and mockups are definitely welcome, so we iterate until we find something nice looking and useful.

josevalim avatar Jan 08 '25 04:01 josevalim

Thank you, those are helpful. Given we only plan to highlight it when it is outdated, we can compare the color of the version with the “Elixir” title in the first example, and it seems it is noticeable in all images. So we can move forward.

I think something like this might work:

⏷ v1.17.3 ⏷ v1.17.2 ⚠️

is likely to be a better choice — if the warning sign is a popover so that the meaning of that sign can be tapped/clicked (in either mobile or desktop) to see the meaning (something like This is not the current version of the documentation.).

I do worry that it's going to be too subtle, and also think that it would be good to show the version on desktop like we do on mobile if the sidebar is hidden. We could then also use the same hooks that the dropdown is using to append the ⚠️ popover activator to present the same message without showing the sidebar.

CleanShot 2025-01-07 at 23 37 38@2x

Also, here's the simulated protanopia view of the suggestion:

CleanShot 2025-01-07 at 23 43 10@2x

halostatue avatar Jan 08 '25 04:01 halostatue

The warning sign looks like it's going to be pretty stable in terms of display size and style across operating systems and devices, per emojipedia (scrolling required to see the options).

halostatue avatar Jan 08 '25 04:01 halostatue

We should not use the emoji IMO because it is too dissonant. We don’t use them anywhere else in ExDoc UI. We do use Remix icons though, and perhaps the warning one can be used. I believe it is already in the build as we use it for admonition.

josevalim avatar Jan 08 '25 05:01 josevalim

Looking at ones that suggest a warning, I think that spam, alarm-warning, and thunderstorms are the best choices — and they may not be used, but I don't think that's a negative here because this should be seen.

CleanShot 2025-01-08 at 00 35 27@2x

I am sort of partial to the spam one for multiple reasons (it's a hexagon, which goes well with hexdocs; the old versions of the docs when found via search engines are essentially a form of spam).

halostatue avatar Jan 08 '25 05:01 halostatue

We already have alert-line as part of the bundle, so we can probably just use it, and it looks like the emoji:

Screenshot 2025-01-08 at 08 08 03

josevalim avatar Jan 08 '25 07:01 josevalim

@pdavies, are you ok with someone else carrying this over the finish line or do you want some time? It is your call, it was pending on the ExDoc team decision for sometime anyway. Thanks!

Sorry I've not been super responsive! Very happy for someone to carry this over the line as I make no claims about being a UI designer. But if my opinion is worth anything after saying that... we don't want it to be garish, but it has little value if users don't notice it. I share @halostatue's concern that it could end up too subtle. Using the remix icons is a good call (for a start, it's theme-aware), but something needs to provide contrast/colour that the emoji was adding. Everyone will have a different opinion on the right balance and I think I'm partly chickening out so I'm not the person who has to find the right compromise while also ensuring that it's themed, accessible, etc 😅

pdavies avatar Jan 08 '25 12:01 pdavies

Thank you. I think we can make the version number and the remix icon colored in orange/yellow when outdated. At least have that as a starting point. @alisinabh, would you like to pick it up?

josevalim avatar Jan 08 '25 14:01 josevalim

@josevalim yes sure. Would be happy to do it.

alisinabh avatar Jan 08 '25 15:01 alisinabh

Thank you. I think we can make the version number and the remix icon colored in orange/yellow when outdated. At least have that as a starting point. @alisinabh, would you like to pick it up?

I would choose yellow over orange as it has higher contrast even with variances of colour blindness.

halostatue avatar Jan 08 '25 18:01 halostatue

Thank you @pdavies for getting the party started! Merged as part of #2012.

josevalim avatar Jan 09 '25 18:01 josevalim