1
Fork 0

rustdoc: Implement cross-crate searching

A major discoverability issue with rustdoc is that all crates have their
documentation built in isolation, so it's difficult when looking at the
documentation for libstd to learn that there's a libcollections crate with a
HashMap in it.

This commit moves rustdoc a little closer to improving the multiple crate
experience. This unifies all search indexes for all crates into one file so all
pages share the same search index. This allows searching to work across crates
in the same documentation directory (as the standard distribution is currently
built).

This strategy involves updating a shared file amongst many rustdoc processes, so
I implemented a simple file locking API for handling synchronization for updates
to the shared files.

cc #12554
This commit is contained in:
Alex Crichton 2014-03-16 01:08:56 -07:00
parent d717d613e3
commit 848f7b734e
6 changed files with 382 additions and 156 deletions

View file

@ -37,7 +37,7 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
<link href='http://fonts.googleapis.com/css?family=Oswald:700|Inconsolata:400,700'
rel='stylesheet' type='text/css'>
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}{krate}/main.css\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}main.css\">
{favicon, select, none{} other{<link rel=\"shortcut icon\" href=\"#\" />}}
</head>
@ -74,13 +74,6 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
<section class=\"footer\"></section>
<script>
var rootPath = \"{root_path}\";
</script>
<script src=\"{root_path}{krate}/jquery.js\"></script>
<script src=\"{root_path}{krate}/search-index.js\"></script>
<script src=\"{root_path}{krate}/main.js\"></script>
<div id=\"help\" class=\"hidden\">
<div class=\"shortcuts\">
<h1>Keyboard shortcuts</h1>
@ -111,6 +104,14 @@ pub fn render<T: fmt::Show, S: fmt::Show>(
</p>
</div>
</div>
<script>
var rootPath = \"{root_path}\";
var currentCrate = \"{krate}\";
</script>
<script src=\"{root_path}jquery.js\"></script>
<script src=\"{root_path}main.js\"></script>
<script async src=\"{root_path}search-index.js\"></script>
</body>
</html>
",