@@ -200,7 +200,7 @@ private def renderConfig (hasTfb : Bool) : RenderConfig :=
200200 emitTeX := false
201201 emitHtmlSingle := .no
202202 emitHtmlMulti := .immediately
203- htmlDepth := 2
203+ htmlDepth := 3
204204 rootTocDepth := some 1
205205 sectionTocDepth := some 1
206206 extraCss := [customCss]
@@ -318,10 +318,11 @@ private def mkTrustedBaseIndexBlocks (groups : Array GroupInfo) : Array (Block M
318318
319319/-- Renders one declaration card with docs, statement, links, and dependencies. -/
320320private def mkDeclBlock (decl : DeclInfo) (repoUrl? : Option String)
321- (declHrefs : Std.HashMap Name String) : Block Manual :=
321+ (declHrefs declPageHrefs : Std.HashMap Name String) : Block Manual :=
322322 Id.run do
323323 let issueUrl := issueUrlOf repoUrl? decl.name decl.moduleName decl.source? decl.hasSorry
324324 let sourceUrl := sourceUrlOf repoUrl? decl.source?
325+ let detailsUrl := declPageHrefs.get? decl.name
325326 let mkLinks (deps : Array Name) := deps.filterMap fun dep =>
326327 declHrefs.get? dep |>.map fun href => { label := dep.getString!, href? := some href }
327328 let typeDepLinks := mkLinks decl.typeDeps
@@ -342,7 +343,7 @@ private def mkDeclBlock (decl : DeclInfo) (repoUrl? : Option String)
342343 blocks := blocks.push <| .other (Block.details { summary := s! "Body uses ({ proofDepLinks.size} )" }) #[block]
343344 if let some block := depListBlock usedByLinks then
344345 blocks := blocks.push <| .other (Block.details { summary := s! "Used by ({ usedByLinks.size} )" }) #[block]
345- if let some block := mkLinkParagraph sourceUrl issueUrl then
346+ if let some block := mkLinkParagraph sourceUrl issueUrl detailsUrl then
346347 blocks := blocks.push block
347348 if let some proof := decl.proofText? then
348349 blocks := blocks.push <| .other (Block.details { summary := "Proof" }) #[.code proof]
@@ -358,9 +359,44 @@ private def mkDeclBlock (decl : DeclInfo) (repoUrl? : Option String)
358359 }
359360 .other (Block.declCard cardData) blocks
360361
362+ /-- Builds a dedicated detail page for one declaration, listing its direct and transitive
363+ dependencies. -/
364+ private def mkDeclPart (decl : DeclInfo) (declPageHrefs : Std.HashMap Name String) : Part Manual :=
365+ Id.run do
366+ let mkLinks (deps : Array Name) := deps.filterMap fun dep =>
367+ declPageHrefs.get? dep |>.map fun href => { label := dep.getString!, href? := some href }
368+ let typeDepLinks := mkLinks decl.typeDeps
369+ let proofDepLinks := mkLinks <| decl.deps.filter (!decl.typeDeps.contains ·)
370+ let usedByLinks := mkLinks decl.usedBy
371+ let transDepLinks := mkLinks decl.transDeps
372+ let mut blocks : Array (Block Manual) := #[]
373+ if let some docstringBlock := decl.docstringBlock? then
374+ blocks := blocks.push docstringBlock
375+ blocks := blocks.push (.para #[.bold #[.text "Code" ]])
376+ blocks := blocks.push (.code decl.displaySignature)
377+ if let some block := depListBlock typeDepLinks then
378+ blocks := blocks.push <| .other (Block.details { summary := s! "Type uses ({ typeDepLinks.size} )" }) #[block]
379+ if let some block := depListBlock proofDepLinks then
380+ blocks := blocks.push <| .other (Block.details { summary := s! "Body uses ({ proofDepLinks.size} )" }) #[block]
381+ if let some block := depListBlock usedByLinks then
382+ blocks := blocks.push <| .other (Block.details { summary := s! "Used by ({ usedByLinks.size} )" }) #[block]
383+ if let some block := depListBlock transDepLinks then
384+ blocks := blocks.push <| .other (Block.details { summary := s! "All dependencies, transitively ({ transDepLinks.size} )" }) #[block]
385+ return {
386+ title := #[.code decl.name.toString]
387+ titleString := decl.name.toString
388+ metadata := some {
389+ file := some s! "decl-{ anchorIdOf decl.name} "
390+ shortTitle := some decl.name.getString!
391+ number := false
392+ }
393+ content := blocks
394+ subParts := #[]
395+ }
396+
361397/-- Builds a module page from its declarations. -/
362398private def mkModulePart (moduleInfo : ModuleInfo) (repoUrl? : Option String)
363- (declHrefs : Std.HashMap Name String) : Part Manual :=
399+ (declHrefs declPageHrefs : Std.HashMap Name String) : Part Manual :=
364400 {
365401 title := #[.text moduleInfo.path]
366402 titleString := moduleInfo.path
@@ -375,13 +411,13 @@ private def mkModulePart (moduleInfo : ModuleInfo) (repoUrl? : Option String)
375411 .code moduleInfo.name.toString,
376412 .text s! " contains { moduleInfo.decls.size} exposed declarations."
377413 ]
378- ] ++ moduleInfo.decls.map (fun decl => mkDeclBlock decl repoUrl? declHrefs)
379- subParts := #[]
414+ ] ++ moduleInfo.decls.map (fun decl => mkDeclBlock decl repoUrl? declHrefs declPageHrefs )
415+ subParts := moduleInfo.decls.map ( fun decl => mkDeclPart decl declPageHrefs)
380416 }
381417
382418/-- Builds a trusted-base module page from declarations in that module. -/
383419private def mkTrustedBaseModulePart (moduleInfo : ModuleInfo) (repoUrl? : Option String)
384- (declHrefs : Std.HashMap Name String) : Part Manual :=
420+ (declHrefs declPageHrefs : Std.HashMap Name String) : Part Manual :=
385421 {
386422 title := #[.text moduleInfo.path]
387423 titleString := moduleInfo.path
@@ -396,13 +432,13 @@ private def mkTrustedBaseModulePart (moduleInfo : ModuleInfo) (repoUrl? : Option
396432 .code moduleInfo.name.toString,
397433 .text s! " contributes { moduleInfo.decls.size} declarations to the trusted formalization base."
398434 ]
399- ] ++ moduleInfo.decls.map (fun decl => mkDeclBlock decl repoUrl? declHrefs)
435+ ] ++ moduleInfo.decls.map (fun decl => mkDeclBlock decl repoUrl? declHrefs declPageHrefs )
400436 subParts := #[]
401437 }
402438
403439/-- Builds a chapter page that contains regular module pages. -/
404440private def mkGroupPart (group : GroupInfo) (repoUrl? : Option String)
405- (declHrefs : Std.HashMap Name String) : Part Manual :=
441+ (declHrefs declPageHrefs : Std.HashMap Name String) : Part Manual :=
406442 let title := humanizeWord group.key
407443 {
408444 title := #[.text title]
@@ -415,12 +451,12 @@ private def mkGroupPart (group : GroupInfo) (repoUrl? : Option String)
415451 content := #[
416452 .para #[.text s! "Modules in the { title} slice are grouped from the first path component after the project root." ]
417453 ]
418- subParts := group.modules.map fun moduleInfo => mkModulePart moduleInfo repoUrl? declHrefs
454+ subParts := group.modules.map fun moduleInfo => mkModulePart moduleInfo repoUrl? declHrefs declPageHrefs
419455 }
420456
421457/-- Builds a chapter page for the trusted-base view. -/
422458private def mkTrustedBaseGroupPart (group : GroupInfo) (repoUrl? : Option String)
423- (declHrefs : Std.HashMap Name String) : Part Manual :=
459+ (declHrefs declPageHrefs : Std.HashMap Name String) : Part Manual :=
424460 let title := humanizeWord group.key
425461 {
426462 title := #[.text title]
@@ -433,12 +469,12 @@ private def mkTrustedBaseGroupPart (group : GroupInfo) (repoUrl? : Option String
433469 content := #[
434470 .para #[.text s! "Modules in the { title} slice that contribute declarations to the trusted formalization base." ]
435471 ]
436- subParts := group.modules.map fun moduleInfo => mkTrustedBaseModulePart moduleInfo repoUrl? declHrefs
472+ subParts := group.modules.map fun moduleInfo => mkTrustedBaseModulePart moduleInfo repoUrl? declHrefs declPageHrefs
437473 }
438474
439475/-- Builds the top-level trusted-base section and its chapter subpages. -/
440476private def mkTrustedBasePart (groups : Array GroupInfo) (repoUrl? : Option String)
441- (declHrefs : Std.HashMap Name String) (targetBlocks : Array (Block Manual)) : Part Manual :=
477+ (declHrefs declPageHrefs : Std.HashMap Name String) (targetBlocks : Array (Block Manual)) : Part Manual :=
442478 let declCount := countDecls groups
443479 let moduleCount := groups.foldl (fun n group => n + group.modules.size) 0
444480 let intro :=
@@ -462,7 +498,7 @@ private def mkTrustedBasePart (groups : Array GroupInfo) (repoUrl? : Option Stri
462498 ++ intro
463499 ++ mkTrustedBaseIndexBlocks groups
464500 ++ mkDashboardBlocks groups
465- subParts := groups.map fun group => mkTrustedBaseGroupPart group repoUrl? declHrefs
501+ subParts := groups.map fun group => mkTrustedBaseGroupPart group repoUrl? declHrefs declPageHrefs
466502 }
467503
468504/-- Builds the interactive dependency graph page and graph payload. -/
@@ -500,7 +536,7 @@ private def mkGraphPart (decls : Array DeclInfo) (declHrefs : Std.HashMap Name S
500536
501537/-- Builds the root site part with chapter pages and utility sections. -/
502538private def mkRootPart (cfg : Cli) (rootPrefix : Name) (groups : Array GroupInfo)
503- (decls : Array DeclInfo) (declHrefs : Std.HashMap Name String)
539+ (decls : Array DeclInfo) (declHrefs declPageHrefs : Std.HashMap Name String)
504540 (introBlocks : Array (Block Manual)) (readerGuideBlocks : Array (Block Manual))
505541 (extraParts : Array (Part Manual)) : Part Manual :=
506542 let title := cfg.siteTitle.getD s! "{ rootPrefix} exposition"
@@ -516,7 +552,7 @@ private def mkRootPart (cfg : Cli) (rootPrefix : Name) (groups : Array GroupInfo
516552 ++ introBlocks
517553 ++ readerGuideBlocks
518554 ++ mkDashboardBlocks groups
519- subParts := (groups.map fun group => mkGroupPart group cfg.repoUrl declHrefs)
555+ subParts := (groups.map fun group => mkGroupPart group cfg.repoUrl declHrefs declPageHrefs )
520556 ++ extraParts
521557 ++ #[mkGraphPart decls declHrefs]
522558 }
@@ -585,22 +621,23 @@ unsafe def mainImpl (args : List String) : IO UInt32 := do
585621 else
586622 IO.println s! "Collected { decls.size} declarations under { rootPrefix} "
587623 let tfbInfo ← loadTrustedBaseInfo cfg rootPrefix
588- let decls := decls |> attachReverseDeps |> attachDependsOnSorry |> attachTrustedBaseFlags tfbInfo.names
624+ let decls := decls |> attachReverseDeps |> attachTransitiveDeps |> attachDependsOnSorry |> attachTrustedBaseFlags tfbInfo.names
589625 let order ← moduleOrderMap cfg.projectDir rootPrefix
590626 let modules := buildModules rootPrefix order decls
591627 let groups := buildGroups order modules
592628 let declHrefs := declHrefMap decls
629+ let declPageHrefs := declPageHrefMap decls
593630 let (introBlocks, extraParts) ← loadProjectContextParts cfg.projectDir cfg.repoUrl
594631 let tfbGroups := buildGroups order <| buildModules rootPrefix order <| decls.filter (·.inTfb)
595632 let targetBlocks ← loadTrustedBaseTargetBlocks cfg.projectDir cfg.repoUrl tfbInfo
596633 let hasContext := extraParts.any fun part => part.metadata.bind PartMetadata.file == some "context"
597634 let extraParts :=
598635 if tfbInfo.comparator?.isSome then
599- extraParts.push <| mkTrustedBasePart tfbGroups cfg.repoUrl declHrefs targetBlocks
636+ extraParts.push <| mkTrustedBasePart tfbGroups cfg.repoUrl declHrefs declPageHrefs targetBlocks
600637 else
601638 extraParts
602639 let readerGuideBlocks := mkReaderGuideBlocks hasContext tfbInfo.comparator?.isSome
603- let root := mkRootPart cfg rootPrefix groups decls declHrefs introBlocks readerGuideBlocks extraParts
640+ let root := mkRootPart cfg rootPrefix groups decls declHrefs declPageHrefs introBlocks readerGuideBlocks extraParts
604641 let versoArgs :=
605642 match cfg.outputDir with
606643 | some out => ["--output" , out]
0 commit comments