diff --git a/crates/rune/src/doc/build.rs b/crates/rune/src/doc/build.rs index 8c81550d8..c662bff60 100644 --- a/crates/rune/src/doc/build.rs +++ b/crates/rune/src/doc/build.rs @@ -132,7 +132,8 @@ pub(crate) fn build( css.try_push(runedoc_css)?; // Collect an ordered set of modules, so we have a baseline of what to render when. - let mut initial = VecDeque::new(); + let mut initial = Vec::new(); + let mut initial_seen = HashSet::new(); for item in context.iter_modules() { let item = item?; @@ -143,9 +144,15 @@ pub(crate) fn build( .find(|m| matches!(&m.kind, Kind::Module)) .with_context(|| anyhow!("Missing meta for {item}"))?; - initial.try_push_back((Build::Module, meta))?; + if !initial_seen.try_insert(meta.hash)? { + continue; + } + + initial.try_push((Build::Module, meta))?; } + initial.sort_by_key(|(_, meta)| meta.item); + let search_index = RelativePath::new("index.js"); let root_index = RelativePath::new("index.html"); @@ -172,49 +179,46 @@ pub(crate) fn build( let mut modules = Vec::new(); let mut builders = Vec::new(); - let mut visited = HashSet::new(); while let Some((build, meta)) = queue.pop_front() { - if !visited.try_insert(meta.hash)? { + if !visited.try_insert((build, meta.hash))? { + tracing::error!(?build, ?meta.item, "Already visited"); continue; } + cx.set_path(meta)?; + + tracing::trace!(?build, ?meta.item, ?cx.state.path, "Building"); + match build { Build::Type => { - cx.set_path(meta)?; let (builder, items) = self::type_::build(&mut cx, "Type", "type", meta)?; builders.try_push(builder)?; cx.index.try_extend(items)?; } Build::Trait => { - cx.set_path(meta)?; let (builder, items) = self::type_::build(&mut cx, "Trait", "trait", meta)?; builders.try_push(builder)?; cx.index.try_extend(items)?; } Build::Struct => { - cx.set_path(meta)?; let (builder, index) = self::type_::build(&mut cx, "Struct", "struct", meta)?; builders.try_push(builder)?; cx.index.try_extend(index)?; } Build::Enum => { - cx.set_path(meta)?; let (builder, index) = self::type_::build(&mut cx, "Enum", "enum", meta)?; builders.try_push(builder)?; cx.index.try_extend(index)?; } Build::Macro => { - cx.set_path(meta)?; builders.try_push(build_macro(&mut cx, meta)?)?; } Build::Function => { - cx.set_path(meta)?; builders.try_push(build_function(&mut cx, meta)?)?; } Build::Module => { - cx.set_path(meta)?; builders.try_push(module(&mut cx, meta, &mut queue)?)?; modules.try_push((meta.item, cx.state.path.clone()))?; } @@ -813,6 +817,7 @@ impl<'m> Ctxt<'_, 'm> { } } +#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] enum Build { Type, Struct, @@ -999,9 +1004,12 @@ fn module<'m>( let mut traits = Vec::new(); for (_, name) in cx.context.iter_components(meta.item)? { - let lookup_item = meta.item.join([name])?; + let item = meta.item.join([name])?; + tracing::trace!(?item, "Looking up"); + + for m in cx.context.meta(&item)? { + tracing::trace!(?item, ?m.kind, "Found"); - for m in cx.context.meta(&lookup_item)? { match m.kind { Kind::Type { .. } => { queue.try_push_front((Build::Type, m))?; diff --git a/crates/rune/src/modules/f64.rs b/crates/rune/src/modules/f64.rs index 5c7aa73bc..2400bdcbb 100644 --- a/crates/rune/src/modules/f64.rs +++ b/crates/rune/src/modules/f64.rs @@ -380,7 +380,10 @@ fn round(this: f64) -> f64 { this.round() } -/// Test two integers for partial equality. +/// Clone a `f64`. +/// +/// Note that since the type is copy, cloning has the same effect as assigning +/// it. /// /// # Examples /// @@ -392,7 +395,7 @@ fn round(this: f64) -> f64 { /// a += 1.0; /// /// assert_eq!(a, 6.0); -/// assert_eq!(b, 6.0); +/// assert_eq!(b, 5.0); /// assert_eq!(c, 5.0); /// ``` #[rune::function(keep, instance, protocol = CLONE)] diff --git a/crates/rune/src/modules/i64.rs b/crates/rune/src/modules/i64.rs index ff63a088a..6f3a52e80 100644 --- a/crates/rune/src/modules/i64.rs +++ b/crates/rune/src/modules/i64.rs @@ -530,7 +530,10 @@ fn is_negative(this: i64) -> bool { i64::is_negative(this) } -/// Test two integers for partial equality. +/// Clone a `i64`. +/// +/// Note that since the type is copy, cloning has the same effect as assigning +/// it. /// /// # Examples /// @@ -542,7 +545,7 @@ fn is_negative(this: i64) -> bool { /// a += 1; /// /// assert_eq!(a, 6); -/// assert_eq!(b, 6); +/// assert_eq!(b, 5); /// assert_eq!(c, 5); /// ``` #[rune::function(keep, instance, protocol = CLONE)]