Commit graph

529 commits

Author SHA1 Message Date
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
Folyd
850d0ec7bf Move redirect page to manage directory 2021-07-12 22:32:26 +08:00
Folyd
76b09a6f2b Use Rust and tera to build manage html pages 2021-07-10 14:11:12 +08:00
Folyd
63a76571a1 Improve manage ui 2021-07-10 12:09:31 +08:00
Folyd
3a3975b7bd Update command index 2021-07-08 10:37:19 +08:00
Folyd
377f29e1a2 Add crate manage page 2021-07-04 23:38:24 +08:00
Folyd
eeea86dc67 Extract CrateDocManager 2021-07-04 00:25:53 +08:00
Folyd
dfee10b4fe Move settings from popup page to manage page 2021-07-03 23:58:59 +08:00
Folyd
36dd242bfe Setup manage pages 2021-07-03 23:21:21 +08:00
Folyd
861e488ca9 Merge default type data with statistic type data 2021-06-23 23:52:19 +08:00
Folyd
9252ecbf03 Ignore legacy rust std docs, such as 0.12.0. 2021-06-16 23:24:10 +08:00
Folyd
84a4c28909 Update README 2021-05-14 00:43:54 +08:00
Folyd
5939b485a4 Add areweyeetyet.rs 2021-05-12 22:57:42 +08:00
Folyd
9faaf6ff4d Add search index resolve fallback in docs.rs page 2021-05-05 16:17:01 +08:00
Folyd
06d1f3f512 Move transform statistics code to stats page. 2021-05-05 11:30:41 +08:00
Folyd
b14ef55376 Rename Statistics properties 2021-05-05 00:26:23 +08:00
Folyd
56f5dd81f6 Only keep the latest 100 of search history. 2021-05-05 00:12:27 +08:00
Folyd
8e4b72caaa Only transform the statistics result in stats page 2021-05-05 00:10:54 +08:00
Folyd
72b077316e Refactor statistics.js 2021-05-04 23:29:02 +08:00
Folyd
1ac96a0a29 Improve Statistics code 2021-05-03 17:00:58 +08:00
Folyd
af17987f74
Merge pull request #116 from huhu/v1.2.1
Release v1.2.1
2021-04-28 09:45:35 +08:00
Folyd
ff9471b561 Fix wrongly load searchIndexJS bug 2021-04-27 14:33:04 +08:00
Folyd
0461a71e5f Improve add search index error handling 2021-04-27 13:59:46 +08:00
Folyd
8b15d7614a Fix compatibility of Github markdown file's sticky header 2021-04-27 12:50:10 +08:00
Folyd
fca4d8310c Refactor the search statistics 2021-04-24 11:20:14 +08:00
Folyd
73a402441d Convert var to let/const 2021-04-24 10:45:15 +08:00
Folyd
2d63211bf7 Improve calendarData data structure 2021-04-23 23:59:01 +08:00
Folyd
3d399b5214 Separate of data statistics and UI render 2021-04-23 23:39:37 +08:00
Folyd
a8ffc2105d Fix compatibility of Github markdown file's sticky header 2021-04-15 20:59:43 +08:00
Folyd
422f0fca6f Update the latest search-index 2021-03-27 00:03:37 +08:00
Folyd
d56d7f392c Compat the new style of search-index.js format. Fixes #106
librustdoc has switched the search-index.js from a "array of struct" to a "struct of array" format.We need to compat both the new and old formats.
2021-03-20 12:25:16 +08:00
Folyd
4f0be20ae2 Add comments about rustc cache policy 2021-03-20 12:23:44 +08:00
Folyd
eefa192c90 Fix search-index.js on-demand load mode compatiblity
rustdoc merged a new PR [#82310](https://github.com/rust-lang/rust/pull/82310) a few days ago, this cause breaking changes to this extension. This commit aims to fix this incompatibility.
2021-03-18 00:43:48 +08:00
Folyd
c0586263eb Improve the user experience of offline doc path. Fix #105 2021-03-07 23:37:23 +08:00
Folyd
c44847596d Fallback enum variant srclink to the enum itself 2021-03-03 23:36:53 +08:00
Folyd
05291a5420 Eliminate tags for docs description 2021-03-03 23:25:57 +08:00
Folyd
6d3bacba93 Eliminate unnecessary tags (such as <match>, <dim>) to save disk usage. 2021-02-28 23:44:27 +08:00
Folyd
92f377925e Put blog release request last to avoid reload error due to possibly request failed. E.g. Github Pages down. 2021-02-28 23:27:04 +08:00
Folyd
0146cac041 Improve the time granularity of stats 2021-02-28 23:22:16 +08:00
Folyd
308bd69a6f Add alias "s" to "src" mode 2021-02-25 00:08:01 +08:00
Folyd
b236d72b32 Extract INDEX_UPDATE_URL const 2021-02-24 10:51:42 +08:00
Folyd
983693615f Ignore the command history 2021-02-23 23:36:39 +08:00
Folyd
3f1c47cd52 Polish command register codes 2021-02-22 21:50:51 +08:00
Folyd
a02268747f Change ReleaseCommand to an OpenCommand 2021-02-21 23:47:52 +08:00
Folyd
14e4857903 Support src: mode for Rust std docs search to open source code page. Fixes #103 2021-02-21 12:27:01 +08:00
Folyd
6373beaab5 Extract rust src navigate codes 2021-02-21 12:17:50 +08:00
Folyd
5ef7689ce0 Extract levenshtein() to algorithm.js 2021-02-21 11:32:49 +08:00
Folyd
0b34445940 Rust std docs support "src" mode for navigating to source code page 2021-02-21 00:23:32 +08:00
Folyd
4d71d6fbe2 Change UpdateCommand to an OpenCommand 2021-02-20 22:06:22 +08:00
Folyd
ea7dfc979c Change StatsCommand to an OpenCommand 2021-02-20 22:01:48 +08:00
Folyd
d50fa953bd Fix docs.rs/releases page search statistics bug 2021-02-19 22:34:47 +08:00
Folyd
6a711257fd Fix new const-since link compatibility 2021-02-14 14:37:39 +08:00
Folyd
bc7db05919 Fix invalid version cause undefine error 2021-02-14 14:27:00 +08:00