AI Exploration Journey

AI Exploration Journey

RepoDoc: Building Better Code Documentation with Knowledge Graphs — AI Innovations and Insights 145

Jul 19, 2026
∙ Paid

Writing documentation feels satisfying until the next pull request makes part of it outdated.

For large, fast-changing repositories, keeping documentation trustworthy can be harder than creating it.

AI Exploration Journey is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Why Repository Documentation Keeps Falling Behind

Current LLM-powered documentation tools can generate documentation, but producing repository-level docs that are well structured, coherent, affordable, and accurate as the codebase evolves remains difficult.

Three core problems stand out.

  • Fragmented Documentation Structure: Most existing tools split code by directory, file, or fixed token limits rather than by functionality and dependency relationships. Under those designs, documentation can become fragmented: individual APIs may be described, while cross-module relationships and an architectural overview are harder to preserve.

  • High Generation Costs: In the two representative baselines, RepoAgent injects caller-callee context, while CodeWiki carries source code, submodule documentation, and structural information into higher-level prompts. This context stacking increases token use and runtime, especially as repositories grow.

  • Inaccurate Incremental Updates: A small code change can affect far more than the file where it was made. Its impact may spread through function calls, inheritance relationships, interface implementations, and module dependencies. Existing approaches often detect changes only at the file level. Others regenerate all documentation from scratch. Neither design performs the graph-based semantic impact analysis that RepoDoc uses to target documentation components after a change.

Figure 1: Baseline problems: Left: RepoAgent uses physical file structure with template-based documentation; Right: CodeWiki decomposes code by physical size. [Source].

In one sentence, existing approaches can write documentation, but they do not treat a code repository as a connected system that continuously evolves.

So here comes a simple idea: build a repository knowledge graph called RepoKG and use it throughout the entire documentation lifecycle. RepoKG can organize code by function and meaning, retrieve only the context that matters, and trace code changes through dependency relationships. As a result, only the documentation that is genuinely affected needs to be updated.

RepoDoc: From Stale Docs to Living Documentation

RepoDoc takes a graph-first approach: it turns a code repository into a knowledge graph, then uses that graph to generate and maintain documentation.

The initial generation pipeline has three phases: RepoKG construction, module clustering, and documentation generation. Incremental maintenance is a separate four-stage workflow.

Figure 2: RepoDoc architecture. Blue arrows: full generation workflow; Red arrows: incremental update workflow; Black arrows: common paths. [Source].

1. Build the Repository Knowledge Graph, RepoKG

For Python, RepoDoc uses the language’s native AST; for the other supported languages, it uses Tree-sitter to extract functions, classes, interfaces, and modules. It then maps relationships between them, including function calls, imports, inheritance, interface implementations, and containment.

User's avatar

Continue reading this post for free, courtesy of Florian.

Or purchase a paid subscription.
© 2026 Florian June · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture