Skip to main content

StrictDoc-style tree map visualizations for sphinx-needs

Project description

sphinx-needs-tree-map

StrictDoc-style tree map visualizations for sphinx-needs documentation.

Overview

sphinx-needs-tree-map is a Sphinx extension that provides interactive treemap visualizations for your sphinx-needs documentation. It allows you to visualize requirements, specifications, and other need types in a hierarchical treemap using Plotly.js.

Installation

pip install sphinx-needs-tree-map

Or with uv:

uv add sphinx-needs-tree-map

Quick Start

Add the extension to your conf.py:

extensions = [
    "sphinx_needs",
    "sphinx_needs_tree_map",
]

Then use the needtreemap directive in your documentation:

.. needtreemap::
   :hierarchy: document
   :depth: 3
   :show_values:

Directive Options

The needtreemap directive supports the following options:

Filtering

  • :filter: - sphinx-needs filter expression (e.g., type == 'req')
  • :types: - Comma-separated list of need types to include
  • :status: - Comma-separated list of statuses to include
  • :tags: - Comma-separated list of tags to include

Hierarchy

  • :hierarchy: - Hierarchy mode: document (default), links, or type
  • :root: - Root node: document, section, or a specific need ID
  • :depth: - Maximum hierarchy depth (default: 3)

Visualization

  • :size_by: - Size metric: count (default), links, or content_length
  • :color_by: - Color scheme: type (default) or status
  • :show_values: - Show counts in labels
  • :interactive: - Enable interactive features (default: enabled)

Layout

  • :height: - CSS height (default: 600px)
  • :width: - CSS width (default: 100%)
  • :title: - Optional title for the treemap

Configuration

Add these to your conf.py to customize the extension:

# Plotly.js CDN URL
needtreemap_plotly_cdn = "https://cdn.plot.ly/plotly-2.35.2.min.js"

# Default dimensions
needtreemap_default_height = "600px"
needtreemap_default_width = "100%"

# Colors for need types
needtreemap_colors = {
    "req": "#E3F2FD",
    "spec": "#FFF3E0",
    "impl": "#E8F5E9",
    "test": "#FCE4EC",
    "default": "#ECEFF1",
}

# Colors for statuses
needtreemap_status_colors = {
    "open": "#FFCDD2",
    "in progress": "#FFF9C4",
    "implemented": "#C8E6C9",
    "verified": "#B2DFDB",
    "default": "#ECEFF1",
}

Examples

Document-based hierarchy

.. needtreemap::
   :hierarchy: document
   :depth: 3
   :show_values:

Filter by type

.. needtreemap::
   :filter: type == 'req' or type == 'spec'
   :color_by: type

Status-based coloring

.. needtreemap::
   :types: req,spec
   :color_by: status
   :show_values:

Link-based hierarchy

.. needtreemap::
   :hierarchy: links
   :depth: 4
   :title: Requirements Traceability

Example Project

See the example/ directory for a complete example Sphinx project demonstrating all features of the extension. The example project is a fictional "Task Management System" with:

  • 45+ needs (requirements, specifications, test cases, user stories)
  • Multiple documents organized hierarchically
  • Traceability links between needs
  • Examples of all three hierarchy modes
  • Various filtering and visualization options

To build the example:

cd example
uv sync
make html
# Open _build/html/index.html

Requirements

  • Python >= 3.9
  • Sphinx >= 5.0
  • sphinx-needs >= 2.0

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_needs_tree_map-0.1.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_needs_tree_map-0.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_needs_tree_map-0.1.0.tar.gz.

File metadata

  • Download URL: sphinx_needs_tree_map-0.1.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sphinx_needs_tree_map-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1062f48faae00515309a27ca753e6ee0f692fbab7a8b1645c2d571474856e98
MD5 0ce880851a3a1153e5a8b87c7f23ea94
BLAKE2b-256 92848f8b37f3079af3eeb2ebdf678a6ce5049604289e2b5791026478f6bde171

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_needs_tree_map-0.1.0.tar.gz:

Publisher: release.yaml on patdhlk/sphinx-needs-tree-map

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_needs_tree_map-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_needs_tree_map-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50aa58367fb2a93aa2b42a6294bd213194f4ad89de85201569cb2b6ef410814f
MD5 25e2473ae2582d2a8679f61653836b8c
BLAKE2b-256 f900b103a942b10c4f012ec4e954be942ffe490fdb5958c7debde5630df2612b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_needs_tree_map-0.1.0-py3-none-any.whl:

Publisher: release.yaml on patdhlk/sphinx-needs-tree-map

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page