Extension Architecture

Extension Architecture#

The diagram below illustrates the key components and their interactions within the sphinx-diagram-connect extension. This overview helps in understanding how the extension integrates with the Sphinx build process to resolve references in SVG diagrams.

@startuml

title <SIZE:40>Sphinx-Diagram-Connect Component Diagram</SIZe>

scale 0.44
skinparam backgroundColor transparent
'skinparam backgroundColor #b5b4a8ff

skinparam defaultFontSize 30
skinparam defaultText {
  FontColor #000000
}

skinparam component {
  BackgroundColor #ADD8E6
  BorderColor #336699
  FontColor #000000
}

skinparam package {
  BackgroundColor #FFFFE0
  BorderColor #CCAA66
  FontColor #000000
}

skinparam database {
  BackgroundColor #90EE90
  BorderColor #006600
  FontColor #000000
}

skinparam folder {
  BackgroundColor #B0E0E6
  BorderColor #4682B4
  FontColor #000000
}

skinparam file {
  BackgroundColor #F5F5F5
  BorderColor #696969
  FontColor #000000
}

package "Sphinx Documentation Build" #FFFFE0 {
  [Sphinx Application] as SphinxApp #ADD8E6
  [Sphinx Builder (HTML)] as SphinxBuilder #ADD8E6
  [conf.py] as Config #F5F5F5
}

package "Sphinx-Diagram-Connect Extension" #FFFFE0 {
  [DiagramConnect Class] as DCClass #ADD8E6
  [resolve_references Method] as ResolveRefs #ADD8E6
  [NeedsList Class (from sphinx-needs)] as NeedsList #ADD8E6
}

database "Sphinx Output Directory" #90EE90 {
  folder "SVG Files" as SVGs #B0E0E6
  file "needs.json" as NeedsJSON #F5F5F5
}

SphinxApp -right-> Config : loads configuration
Config --> DCClass : config values\n(`verbose`)

SphinxApp -right-> DCClass : instantiates,\nregisters event

SphinxBuilder .down.> SVGs : generates\nSVG content
SphinxBuilder .right.> NeedsJSON : generates\nneeds.json\n(if needs enabled)

SphinxApp .down.> ResolveRefs : `build-finished`\nevent trigger

ResolveRefs --> SVGs : reads/writes SVG content
ResolveRefs ..> NeedsJSON : reads needs.json\n(via `_init_needs`)

DCClass ..> NeedsList : utilizes

ResolveRefs --> SphinxBuilder : logs warnings/info

@enduml