Skip to main content

WikiGenerator

Struct WikiGenerator 

Source
pub struct WikiGenerator<'a, P: LlmProvider> { /* private fields */ }
Expand description

Wiki 页面生成器

通过 LLM 为每个模块生成叙述性的 Wiki 页面, 供人类开发者阅读和理解代码。

Implementations§

Source§

impl<'a, P: LlmProvider> WikiGenerator<'a, P>

Source

pub fn new(provider: &'a P, max_concurrent: usize) -> Self

使用指定的 LLM Provider 创建 WikiGenerator

max_concurrent 控制 describe_modules 的并行上限(0 表示不限制)。

Source

pub fn llm_call_count(&self) -> usize

返回已完成的 LLM 调用次数

Source

pub fn failed_modules(&self) -> Vec<String>

返回生成失败的模块名列表(演进计划 T3.2:失败隔离的可见性出口)

Source

pub async fn generate_wiki_page( &self, chunk: &Chunk, card_summary: &str, config: &WikiConfig, root: &ProjectRoot, entity_ranges: Option<&EntityRanges>, ) -> Result<WikiDocument>

生成模块 Wiki 页面

  • chunk — 模块的代码数据块
  • card_summary — 之前生成的 Knowledge Card 摘要,作为上下文参考
  • config — Wiki 配置(用于获取语言设置等)

P0-1 引用契约:生成后校验源码引用(文件存在 + 行号有效), 引用无效时重试(最多 CITATION_RETRY_MAX 次,用户决策“总是重试“)。 重试注入错误反馈(无效引用清单),最后一次仍失败时返回错误—— 由调用方失败隔离(record_failure)记录,不产出无引用的页面。 G2 Mermaid 契约:正文中的 Mermaid 代码块同样校验(merman 权威解析), 坏块错误消息注入重试反馈;重试耗尽后降级而非失败——坏块替换为 text fence + 标记注释(OpenWiki degrade-and-repair),页面照常产出。

Source

pub async fn generate_architecture( &self, output: &GenerationOutput, graph: &KnowledgeGraph, config: &WikiConfig, root: &ProjectRoot, ) -> Result<WikiDocument>

生成架构概览页面

基于所有模块的生成输出和知识图谱,生成项目级的架构概览文档。 生成前先为每个模块生成一行职责描述(describe_modules), 填充到模块快照的 description 字段——架构 prompt 依此输出模块职责, 取代原本恒为 None 的空描述(此前的 overview 只有模块名+节点数+边计数, 无法表达“模块负责什么“)。

Source

pub async fn generate_overview( &self, output: &GenerationOutput, graph: &KnowledgeGraph, config: &WikiConfig, root: &ProjectRoot, ) -> Result<WikiDocument>

生成项目概览页面

与 generate_architecture 同签名同风格:基于完整 KnowledgeGraph 的 模块列表与模块间依赖摘要,生成全仓库概览(技术栈/目录结构/核心模块)。

Auto Trait Implementations§

§

impl<'a, P> !Freeze for WikiGenerator<'a, P>

§

impl<'a, P> RefUnwindSafe for WikiGenerator<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for WikiGenerator<'a, P>

§

impl<'a, P> Sync for WikiGenerator<'a, P>

§

impl<'a, P> Unpin for WikiGenerator<'a, P>

§

impl<'a, P> UnsafeUnpin for WikiGenerator<'a, P>

§

impl<'a, P> UnwindSafe for WikiGenerator<'a, P>
where P: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more