Commit graph

481 commits

Author SHA1 Message Date
Folyd
d841642cf4 Improve optional dependencies ui and parsing 2022-02-22 15:18:55 +08:00
Folyd
8b81fc70fb Render optional. dependencies in feature flags menu. 2022-02-21 21:08:04 +08:00
Folyd
00ad329c39 Improve compatibility for TOC of docs.rs 2022-02-21 17:05:53 +08:00
Rahul Butani
9f0c2b17d4
Fix latest version parsing for crates with hyphens
Crates with hyphens have their version extracted from the DOM (when
viewing the latest version of a crate and adding it to the extension's
index) incorrectly.

This in turn causes the extension to produce invalid docs.rs links.

----

[This snippet](4e84385e83 (diff-dc9969d9ec58ceb09765359c0caa6852a087b462d98bb9a7e45f1ac75c79b066L12-R14))
(which itself addressed[fallout](7483ba377d (diff-dc9969d9ec58ceb09765359c0caa6852a087b462d98bb9a7e45f1ac75c79b066R12-R15))
from `rustdoc` [changing its version output](6a5f8b1aef (diff-40a0eb025da61717b3b765ceb7fab21d91af3012360e90b9f46e15a4047946faL1768-L1776)))
is the problematic bit.

Updating the logic linked above to take the _last_ element after
splitting on `-` instead of the second fixes this case but I think this
leaves _other_ edge cases unhandled.

For example, `cargo` and friends allow for [pre-release versions which
are allowed to have hyphens](https://semver.org/#spec-item-9) (i.e.
`0.0.1-my-extremely-unstable-release`). While it's unlikely that the
docs.rs "latest" link for a crate will redirect to one of these, it is
still possible – `docsrs` will [search stable, unyanked releases _first_
but *will* fall back to pre-releases](dad5863093/src/web/mod.rs (L341-L368)).
The [`wasi` crate](https://docs.rs/wasi/latest/wasi/) is one such
example of this (no "stable" releases as of this writing, pre-release
version has a hypen in it: `0.11.0+wasi-snapshot-preview1`).

Reverting to the previous method (grabbing the version from the sidebar)
and changing the query to `'nav.sidebar .version'` is general enough to
support pages generated before and after the `rustdoc` version change
without being _too_ general (and potentially picking up things in
user-added HTML snippets). This is the change this commit implements.

The downside to this approach is that it doesn't work on `rustdoc`
output that predates the addition of the version in the sidebar; since
docs.rs [doesn't rebuild docs for older releases](https://github.com/rust-lang/docs.rs/issues/464)
this can be a real concern for older stable crates that haven't had a
release in a while.

---

Another approach is to snoop through some of the relative links on the
page and to extract the version from the relative URLs there. There
doesn't seem to be an obvious thing in the DOM to go after and we're
definitely still susceptible to changes in `rustdoc` this way; I'm not
sure if this is worth doing.

Yet another option is to pick an approach based on the `rustdoc` version
in [`rustdoc-vars`](502d6aa47b/src/librustdoc/html/templates/page.html (L147))
(i.e. `document.querySelector("#rustdoc-vars").getAttribute("data-rustdoc-version")`).
This could help a little but it's worth noting that it itself is a
relatively recent addition to the `rustdoc` HTML output, I think.
2022-02-14 07:50:20 -06:00
Folyd
b3b7fe900e Improve impl blocks highlight effects. Fixes #144 2022-01-31 17:29:34 +08:00
Folyd
668ebac0a4 Update search index 2022-01-25 22:59:25 +08:00
Folyd
3047383453 Add a default rustdoc-toggle outline color 2022-01-25 22:47:00 +08:00
Folyd
2d7351ad64 Add original color to .rse-link 2022-01-25 21:24:56 +08:00
Folyd
fcc0d2911d Enable default search dynamically. Fixes #141 2022-01-24 00:07:56 +08:00
Folyd
0aeb273672 Support customize default search items in settings 2022-01-23 23:51:45 +08:00
Folyd
9924c7351c Enable external crate searching as the default searching 2022-01-17 20:44:10 +08:00
Folyd
1f0c705cdf Improve rustdoc toggle border styles 2022-01-15 23:26:17 +08:00
Folyd
f48e29b558 Fix docs.rs TOC render and UI 2022-01-15 19:13:12 +08:00
Folyd
4e84385e83 Fix crate version parse bug 2022-01-15 18:16:16 +08:00
Folyd
1e05684079 Improve rustdoc-toggle class 2022-01-15 18:03:30 +08:00
Folyd
cd1483cec7 Fix add to extension button toggle float issue 2022-01-15 17:37:13 +08:00
Naturel Lee
633cd0d1ab feat: rust docs enhancement 2022-01-12 20:21:59 +08:00
Folyd
5028b2e895 Update latest index 2021-12-27 23:33:13 +08:00
Folyd
5e95997ce6 Add unsafe code guide book 2021-12-15 17:31:40 +08:00
Folyd
6476091b74 Fix #134. get the searchIndexJs from window.searchIndexJs 2021-12-07 10:56:27 +08:00
Folyd
7483ba377d Fix #135, docs.rs latest version path compatibility 2021-12-07 10:23:24 +08:00
Folyd
ee7c3fb6d7 Update index 2021-10-27 22:30:10 +08:00
Folyd
f76c2abb4c Expand :stable command to 100 versions 2021-10-27 21:09:03 +08:00
Folyd
46ecab2e0f Compare with date instead datetime when get scheduled versions 2021-10-27 21:07:20 +08:00
Folyd
08e50c178f Update std docs index 2021-10-25 12:30:56 +08:00
Folyd
0c86c316b0 Fix books index 2021-10-25 12:22:07 +08:00
Folyd
315032ae9b Improve RFC and blog command filter 2021-10-18 11:48:30 +08:00
Folyd
acda1c77ac Fix some github and docs.rs injected css styles 2021-10-17 10:37:51 +08:00
Folyd
9df8b07b1c Fix RFC command ui 2021-10-16 22:12:28 +08:00
Folyd
b3c8994af1 Generate rfcs index 2021-10-16 20:35:13 +08:00
Folyd
c1e56f82e2 Add RfcCommand 2021-10-16 12:14:40 +08:00
Folyd
ad17de1ddc Don't override the time if the crate exists 2021-10-16 11:46:37 +08:00
Folyd
e7913e3702 Fix some descriptions escape 2021-10-12 09:58:17 +08:00
Folyd
38aac8f289 Error code search support offline mode 2021-10-01 12:49:36 +08:00
Folyd
525d76d210 Make docs.rs TOC overflow auto 2021-08-12 11:13:21 +08:00
Folyd
4cb6cc3bb6 Fix weeks, hours, and dates statistics bug 2021-08-10 00:30:37 +08:00
Folyd
230e5f9017 Fix docs TOC overlap issue 2021-08-09 10:58:24 +08:00
Folyd
d1b0f7aa3e Release v1.3.1 2021-08-06 19:13:25 +08:00
Folyd
e5237d6224 Don't render TOC if the screen width less than 1500px. 2021-08-06 09:56:56 +08:00
Folyd
079a3f4d5e Support open crates manage page in docs.rs pages 2021-08-04 23:35:47 +08:00
Folyd
9301dbb890 Add reminder for crates manage page 2021-08-04 23:15:13 +08:00
Folyd
051085e821 Fix docs.rs TOC render issue 2021-08-04 22:56:38 +08:00
Folyd
64a6158a72 Update commands.js 2021-07-31 12:00:08 +08:00
Folyd
b0ed6676aa Add append reminding for @ searching 2021-07-31 11:33:03 +08:00
Folyd
5106559477 Update the search index 2021-07-30 00:06:26 +08:00
Folyd
03ce7846f9 Fix target undefined bug 2021-07-29 23:32:10 +08:00
Folyd
2db365d90c Fix docs.rs header css selector, add min-width for TOC 2021-07-26 15:10:09 +08:00
Folyd
6de9b050bd Show TOC for docs.rs 2021-07-25 13:55:28 +08:00
Folyd
2b6fc33933 Support offline mode for Windows 2021-07-23 00:29:15 +08:00
Folyd
cef5dafab9 Don't validate the offline doc path 2021-07-23 00:19:19 +08:00