Skip to main content

Meta plugin for debugging utilities while using Datasette

Project description

datasette-debug-bar

PyPI Changelog Tests License

A generic debug bar for Datasette that other plugins can add items to. The bar is fixed to the bottom-right corner of every page and can be minimized/expanded (state persists in localStorage).

Installation

datasette install datasette-debug-bar

Writing a debug-bar plugin

Any Datasette plugin can add a section to the debug bar by defining a debug_bar_items function at the top level of its module.

API

def debug_bar_items(datasette):
    return {
        "label": "My Section",
        "entrypoint": """function(el) {
            // el is an empty HTMLElement — append your UI to it
            el.textContent = 'Hello from my plugin!';
        }""",
    }
Key Type Description
label str Heading displayed above the section in the bar.
entrypoint str A JavaScript function body as a string. It receives a single argument el (an HTMLElement). Append whatever DOM you want to el.

You can return a single dict or a list of dicts to register multiple sections.

Complete example

Here is a minimal but complete Datasette plugin that adds a "Request Info" section to the debug bar. This is a single Python file that can be used directly with datasette --plugins-dir.

# debug_request_info.py

def debug_bar_items(datasette):
    return {
        "label": "Request Info",
        "entrypoint": """function(el) {
            var items = [
                ['Path', location.pathname],
                ['Query', location.search || '(none)'],
                ['Hash', location.hash || '(none)'],
            ];
            var table = document.createElement('table');
            table.style.cssText = 'border-collapse:collapse;font-size:12px;width:100%;';
            items.forEach(function(row) {
                var tr = document.createElement('tr');
                var td1 = document.createElement('td');
                td1.textContent = row[0];
                td1.style.cssText = 'padding:2px 8px 2px 0;color:#666;white-space:nowrap;';
                var td2 = document.createElement('td');
                td2.textContent = row[1];
                td2.style.cssText = 'padding:2px 0;font-family:monospace;word-break:break-all;';
                tr.appendChild(td1);
                tr.appendChild(td2);
                table.appendChild(tr);
            });
            el.appendChild(table);
        }""",
    }

Using it as a package

For installable plugins, add datasette-debug-bar as a dependency in your pyproject.toml:

[project]
dependencies = [
    "datasette",
    "datasette-debug-bar",
]

[project.entry-points.datasette]
my_debug_plugin = "my_debug_plugin"

Then define debug_bar_items in your package's __init__.py. The function will be discovered automatically when both plugins are installed.

Entrypoint tips

  • The el argument is a <div> inside the bar panel. Append DOM nodes to it.
  • The function runs once on page load. If you need live updates, use setInterval or event listeners inside the function.
  • You have access to the full browser environment: document, window, fetch, localStorage, location, cookies, etc.
  • Keep the UI compact — the bar is meant for quick-glance debugging info.

Sample plugins

The sample/ directory contains two working example plugins that can be used with --plugins-dir:

  • debug_request_info.py — displays current URL path, query string, and hash
  • debug_performance.py — displays page performance timing (DNS, connect, response, DOM ready, load, transfer size)

Run them:

DATASETTE_SECRET=abc123 datasette --plugins-dir sample

Development

cd datasette-debug-bar

# Run tests
uv run pytest

# Run dev server with sample plugins
just dev

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

datasette_debug_bar-0.0.1a1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

datasette_debug_bar-0.0.1a1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file datasette_debug_bar-0.0.1a1.tar.gz.

File metadata

  • Download URL: datasette_debug_bar-0.0.1a1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for datasette_debug_bar-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 5390f656852cf3e3404d625757fc6f27c69be86f3784c7901b87562740085689
MD5 219abb1532d2acc7cb35b5f6b4617988
BLAKE2b-256 12fcd72442c1ca1b553f9a24426edf3d0d61eb1048e8b40961d22c9cad79e506

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_debug_bar-0.0.1a1.tar.gz:

Publisher: publish.yml on datasette/datasette-debug-bar

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

File details

Details for the file datasette_debug_bar-0.0.1a1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_debug_bar-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee4e70a2beeb1fe65784c81edb81595b5a37075443108041cf7c7da0bf5016f3
MD5 cd77aa20cffdb2fad271042fe3793ebc
BLAKE2b-256 e3d8521a72d1611391b9b771dd271c2c806900436e50b2c78ca80748cab66ba4

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_debug_bar-0.0.1a1-py3-none-any.whl:

Publisher: publish.yml on datasette/datasette-debug-bar

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