Explore the docs knowledge graph

docsbot graph builds a knowledge graph of your docs and stores it in a SQLite file. Use it to answer questions that a link checker cannot:

  • Which pages document server.port, and do they agree?
  • Which pages are dead ends or orphans? Which are hubs?
  • Which terms are used but never defined?
  • Which pages overlap so much they may be duplicates?

Build the graph

docsbot graph build docs        # writes docsbot-graph.db

The graph holds these kinds of node:

  • Pages and sections, from your content.
  • Entities the docs talk about: commands, flags, configuration keys, API endpoints, error messages, glossary terms and vocabulary terms.
  • Metadata: tags, content types, audiences, versions, owners (front matter or CODEOWNERS) and repositories.
  • Includes (partials) and missing nodes, the targets of broken links.

Every edge records how it was found and where:

Kind Meaning Example
explicit written by an author a link, an include, a front matter tag, a navigation entry
extracted found in the text by a fixed rule a flag in a code block, a config key in a table
inferred a similarity or heuristic, with a confidence two pages that are related, or overlap

Each edge also has the file, line and the text it came from. Entities are extracted with rules, not a model, so the same docs always give the same graph. Suspected duplicate entities (for example config file and configuration file) are listed for review, never merged.

Tell docsbot the names of your product’s commands if it does not find them in code blocks:

graph:
  commands: [lumen]

Find structural problems

docsbot graph stats

stats lists orphans, dead ends, hubs, clusters, depth, broken edges, terms that are used but not defined, and naming problems. --top 20 lengthens each list.

Ask what the docs say about one thing

docsbot graph explain "server.port"

explain lists every page that defines, documents or mentions the entity, with file and line, so you can see at a glance whether the docs contradict each other.

Draw the graph

docsbot graph view -o graph.html                    # offline viewer with search and filters
docsbot graph view --root install --format mindmap  # a Mermaid mind map around one page
docsbot graph view --section guide/ --format mermaid
docsbot graph view --type page,command --format dot | dot -Tsvg > graph.svg

Large sites make unreadable pictures. Keep views small with:

Flag Keeps
--root NODE the nodes around one entity, page, tag or ID (--depth, default 2)
--entity NAME one entity and the pages around it
--section PATH pages under a path and what they touch
--tag TAG pages with a tag and what they touch
--type TYPES only these node types or entity kinds
--max-nodes N the N most connected nodes (default 2000)
--inferred=false no similarity edges

Export it

docsbot graph export -f graphml -o docs.graphml   # Gephi, yEd, Cytoscape, NetworkX
docsbot graph export -f csv -o docs               # docs.nodes.csv and docs.edges.csv
docsbot graph export -f jsonld -o docs.jsonld     # edges reified, so provenance survives
docsbot graph export -f cypher -o docs.cypher     # Neo4j or Memgraph
docsbot graph export -o docs.json                 # JSON (default)

The same filters as view apply.

Tune similarity

Inferred edges come from TF-IDF cosine similarity (related-to) and shared five-word sequences (overlaps-with). Raise the thresholds if you see too many, or turn them off:

graph:
  similarity: true
  related_threshold: 0.35
  overlap_threshold: 0.5
  max_related: 3