Skip to main content

slashdocs — turn your Discord bot commands into beautiful documentation

CI PyPI Python versions License

Auto-generated command docs for discord.py bots — attach one line and your commands page writes itself on startup.

Your bot already knows every command, parameter, type, description, permission, and cooldown. slashdocs turns that into three kinds of output, kept in sync every time the bot starts — no annotations required to get started:

  • MDX pages for a docs site (Fumadocs, Nextra, Docusaurus, Starlight): one page per command, a category index, sidebar metadata.
  • commands.json — a stable, documented JSON feed for building your own interactive /commands page.
  • commands.html — a zero-dependency, self-contained searchable command browser (category sidebar with counts, live search, parameter chips, permission badges) for bots without a website.

Install

pip install slashdocs   # or: uv add slashdocs

Quickstart

import slashdocs
from slashdocs import docs

@bot.tree.command(description="Bet money on a coin flip.")
@docs(category="Economy", example="/coinflip 500 heads")
async def coinflip(interaction: discord.Interaction, amount: int, side: str): ...

slashdocs.attach(bot, out="docs/commands")

bot.run(TOKEN)

Want the interactive command browser (and/or the JSON feed) too? Configure outputs explicitly — one walk feeds them all:

from slashdocs import attach, mdx, commands_json, commands_page

attach(bot, outputs=[
    mdx("docs/content/commands"),                     # docs-site MDX (as above)
    commands_json("site/public/commands.json"),       # feed your own /commands UI
    commands_page("site/public/commands.html",        # instant searchable page
                  title="MyBot Commands", accent="#5865F2"),
])

On startup slashdocs walks the loaded command tree (slash, prefix, and hybrid commands, groups, cogs), diffs against the previous run, and writes only what changed:

INFO slashdocs: 12 added, 0 changed, 0 removed -> docs/commands

Second startup with nothing changed:

INFO slashdocs: docs up to date (12 commands)

The @docs decorator (optional)

Everything discord.py knows is picked up automatically. @docs adds what it can't express:

@docs(
    category="Economy",              # docs-site grouping (default: cog name)
    example="/coinflip 500 heads",   # str or list[str]
    hidden=True,                     # exclude from generated docs
    notes="Requires the Economy module to be enabled.",
    permissions="Booster Only",      # custom permission badges (str or list[str])
    tier="Premium",                  # renders a 👑 tier badge
)

Standard permissions and cooldowns are picked up without @docs: @app_commands.default_permissions(...) on slash commands, @commands.has_permissions(...) / has_guild_permissions(...) and @commands.cooldown(...) on prefix and hybrid commands. The bot's real command_prefix is rendered too (pass attach(..., prefix="?") to override — needed when the prefix is a callable).

Works above or below the command decorator, on slash, prefix, and hybrid commands and groups. Commands marked hidden=True in discord.py's own @commands.command(hidden=True) are excluded too, as is discord.py's auto-injected default help command.

Wiring the output into your docs site

slashdocs writes plain MDX with frontmatter plus meta.json. Point it at your content directory:

  • Fumadocs — attach(bot, out="content/docs/commands"). meta.json is picked up natively for sidebar order.
  • Nextra — attach(bot, out="pages/commands") (or content/ for Nextra 4).
  • Docusaurus — attach(bot, out="docs/commands"); frontmatter title and description are used as-is; meta.json is ignored (harmless).
  • Astro Starlight — attach(bot, out="src/content/docs/commands").

Generated files carry generated_by: slashdocs in their frontmatter; slashdocs only ever deletes files bearing that marker, so hand-written pages in the same folder are safe.

The commands.json feed

commands_json(path) writes a deterministic, schema-versioned JSON document — the same manifest slashdocs uses internally:

{
  "schema_version": 2,
  "prefix": "!",
  "commands": [
    {
      "name": "ban", "slug": "ban", "kind": "slash",       // "slash" | "prefix" | "hybrid"
      "description": "...", "category": "Moderation",
      "params": [{ "name": "user", "type": "user", "required": true,
                   "description": "...", "choices": [], "default": null }],
      "permissions": ["Ban Members"], "tier": "",
      "cooldown_rate": 0, "cooldown_per": 0.0,
      "aliases": [], "examples": [], "notes": "",
      "subcommands": []                                     // same shape, nested
    }
  ]
}

Fetch it from any frontend and render search/filter UI however you like. The file is only rewritten when its content changes, so it's safe to serve statically and cache.

The static commands page

commands_page(path, title=..., accent=...) emits a single HTML file with the data embedded and zero external requests — drop it on any static host. It renders a category sidebar with counts, live search over names/aliases/ descriptions, and cards with parameter chips, permission and tier badges, cooldowns, and slash/prefix indicators — hybrid commands show both invocation forms. Light and dark themes follow the visitor's system preference.

API

slashdocs.attach(bot, out=None, *, outputs=None, prefix=None, base_slug="/commands", clean=True)
slashdocs.mdx(path, *, base_slug="/commands", clean=True)
slashdocs.commands_json(path)
slashdocs.commands_page(path, *, title="Commands", accent="#5865F2")
slashdocs.docs(*, category=None, example=None, hidden=False, notes="", permissions=None, tier="")
slashdocs.__version__

attach(bot, out="docs/commands") is shorthand for a single mdx() output.

attach()'s on_ready hook can never crash your bot: every output is attempted even if another fails, and any failure is caught, logged to the slashdocs logger, and never re-raised into the bot. Calling generate() directly (e.g. from a script) instead raises OutputGenerationError if any output failed, after every output has been attempted — so a CI job or build script can tell generation actually failed rather than reading a false "up to date".

Requirements

  • Python ≥ 3.10
  • discord.py ≥ 2.4

License

MIT

Metadata

Release files for slashdocs 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slashdocs 0.2.1
File Size Uploaded
slashdocs-0.2.1.tar.gz 162.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slashdocs 0.2.1
File Interpreter ABI Platform
slashdocs-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 184.7 kB

Release files / slashdocs-0.2.1.tar.gz

Download URL slashdocs-0.2.1.tar.gz
Size 162.2 kB
Tags Source
SHA-256 checksum
How to use checksums
32f3568d88a2831e8b8d6dda2c42faf5caa0156caf7453e893432a0f7bfb71b1
BLAKE2b-256 checksum
How to use checksums
d5ec4b6edf2d210a634e5aeccbb3c0f82f68afe87195e2753984bcc7ad58ff62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 18, 2026.

Transparency log

Release files / slashdocs-0.2.1-py3-none-any.whl

Download URL slashdocs-0.2.1-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6beae5632229d9d731b7a72d00c06bb23718cb4f02777543171fa294848627e0
BLAKE2b-256 checksum
How to use checksums
f0db11e5d8914cfdf314f0341eda39a208153129180b68d26194d6189aa44f56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page