Fix rustdoc HTML rendering
By returning the items to process and storing them in a queue, we were losing the context that was setup for that item during the recursion. This is an easy fix, rather than hoisting out the state that it needs.
This commit is contained in:
parent
793eb1d38d
commit
8b5a317d48
@ -648,9 +648,13 @@ fn recurse<T>(&mut self, s: ~str, f: |&mut Context| -> T) -> T {
|
||||
self.root_path.push_str("../");
|
||||
self.current.push(s);
|
||||
|
||||
info!("Recursing into {}", self.dst.display());
|
||||
|
||||
mkdir(&self.dst);
|
||||
let ret = f(self);
|
||||
|
||||
info!("Recursed; leaving {}", self.dst.display());
|
||||
|
||||
// Go back to where we were at
|
||||
self.dst = prev;
|
||||
let len = self.root_path.len();
|
||||
@ -674,13 +678,7 @@ fn crate(mut self, mut crate: clean::Crate, cache: Cache) {
|
||||
// using a rwarc makes this parallelizable in the future
|
||||
local_data::set(cache_key, Arc::new(cache));
|
||||
|
||||
let mut work = ~[item];
|
||||
while work.len() > 0 {
|
||||
let item = work.pop();
|
||||
self.item(item, |_cx, item| {
|
||||
work.push(item);
|
||||
})
|
||||
}
|
||||
self.item(item);
|
||||
}
|
||||
|
||||
/// Non-parellelized version of rendering an item. This will take the input
|
||||
@ -688,9 +686,10 @@ fn crate(mut self, mut crate: clean::Crate, cache: Cache) {
|
||||
/// all sub-items which need to be rendered.
|
||||
///
|
||||
/// The rendering driver uses this closure to queue up more work.
|
||||
fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) {
|
||||
fn item(&mut self, item: clean::Item) {
|
||||
fn render(w: io::File, cx: &mut Context, it: &clean::Item,
|
||||
pushname: bool) {
|
||||
info!("Rendering an item to {}", w.path().display());
|
||||
// A little unfortunate that this is done like this, but it sure
|
||||
// does make formatting *a lot* nicer.
|
||||
local_data::set(current_location_key, cx.current.clone());
|
||||
@ -734,7 +733,7 @@ fn render(w: io::File, cx: &mut Context, it: &clean::Item,
|
||||
};
|
||||
this.sidebar = build_sidebar(&m);
|
||||
for item in m.items.move_iter() {
|
||||
f(this, item);
|
||||
this.item(item);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user