Skip to main content

Filter documentation build output (MkDocs, Sphinx) to show only warnings and errors with nice formatting

Project description

docs-output-filter

Filter documentation build output to show only what matters: warnings and errors.

Works with MkDocs and Sphinx (including sphinx-autobuild, Jupyter Book, myst-nb). Includes an MCP server for AI code assistant integration (Claude Code, etc.).

Before & After

โŒ Raw build output (43 lines) โœ… Filtered output (15 lines)
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Log level set to INFO
INFO    -  Building documentation to directory: /project/site
INFO    -  MERMAID2  - Initialization arguments: {}
INFO    -  Generating index pages...
INFO    -  Reading page 'index.md'
INFO    -  Reading page 'guide/getting-started.md'
INFO    -  Reading page 'guide/configuration.md'
INFO    -  Reading page 'api/reference.md'
INFO    -  Copying static files from theme: material
INFO    -  Copying 'assets/stylesheets/extra.css'
INFO    -  Copying 'assets/javascripts/extra.js'
[git-revision-date-localized-plugin] has no git logs
INFO    -  Executing code blocks with markdown_exec...
WARNING -  markdown_exec: Execution of python
code block exited with errors

Code block is:

  import numpy as np
  data = np.random.rand(10, 10)
  raise ValueError("INTENTIONAL TEST ERROR")

Output is:

  Traceback (most recent call last):
    File "<code block: session test; n1>", line 3
      raise ValueError("INTENTIONAL TEST ERROR")
  ValueError: INTENTIONAL TEST ERROR

WARNING -  [git-revision] Unable to read git logs
INFO    -  Rendering 'index.md'
INFO    -  Rendering 'guide/getting-started.md'
INFO    -  Rendering 'guide/configuration.md'
INFO    -  Rendering 'api/reference.md'
INFO    -  Building search index...
INFO    -  Writing 'sitemap.xml'
INFO    -  Writing 'search/search_index.json'
INFO    -  Documentation built in 12.34 seconds
โš  WARNING [markdown_exec] ValueError: INTENTIONAL TEST ERROR
   ๐Ÿ“ session 'test' โ†’ line 3

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Code Block โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  1 import numpy as np                       โ”‚
โ”‚  2 data = np.random.rand(10, 10)            โ”‚
โ”‚  3 raise ValueError("INTENTIONAL TEST E...")โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Error Output โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ValueError: INTENTIONAL TEST ERROR  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ use -v for full traceback โ”€โ•ฏ

โš  WARNING [git-revision] Unable to read git logs

Summary: 2 warning(s)

๐ŸŒ Server: http://127.0.0.1:8000/
๐Ÿ“ Output: /project/site
Built in 12.34s

Installation

# With uv (recommended)
uv tool install docs-output-filter

# With pip
pip install docs-output-filter

Usage

# Wrapper mode (recommended) โ€” just prefix your build command
docs-output-filter -- mkdocs build
docs-output-filter -- mkdocs serve --livereload
docs-output-filter -- sphinx-autobuild docs _build/html

# Pipe mode โ€” traditional Unix pipe
mkdocs build 2>&1 | docs-output-filter
sphinx-build docs _build 2>&1 | docs-output-filter

# Process a remote build log (e.g., ReadTheDocs)
docs-output-filter --url https://app.readthedocs.org/projects/myproject/builds/12345/

Tip: Wrapper mode (--) is the easiest way to use docs-output-filter. It runs the command for you, automatically captures both stdout and stderr, and fixes buffering issues with sphinx-autobuild. No 2>&1 needed.

Note: If using pipe mode, 2>&1 is important โ€” Sphinx writes warnings to stderr. Without it, warnings bypass the filter.

Note: Use --livereload with mkdocs serve due to a Click 8.3.x bug.

Features

Feature Description
Multi-tool support MkDocs and Sphinx with auto-detection
Filtered output Shows WARNING and ERROR messages, hides routine INFO
Code blocks Syntax-highlighted code for markdown_exec and myst-nb errors
Location info File, line number, session name, warning codes
Streaming mode Real-time output for mkdocs serve / sphinx-autobuild with rebuild detection
Interactive mode Toggle between raw/filtered with keyboard (-i)
Remote logs Fetch and parse build logs from ReadTheDocs and other CI
MCP server API for AI code assistants like Claude Code

Options

Flag Description
-- COMMAND Run command as subprocess (recommended, no 2>&1 needed)
-v, --verbose Show full tracebacks and code blocks
-e, --errors-only Hide warnings, show only errors
--no-color Disable colored output
--raw Pass through unfiltered build output
-i, --interactive Toggle raw/filtered with keyboard
--url URL Fetch and process a remote build log
--tool mkdocs|sphinx|auto Force build tool detection (default: auto)
--share-state Write state for MCP server integration

MCP Server (for AI Assistants)

Enable AI code assistants to access build issues:

# Terminal 1: Run build tool with state sharing
mkdocs serve --livereload 2>&1 | docs-output-filter --share-state

# Terminal 2: AI assistant connects via MCP
docs-output-filter --mcp --watch

Add to Claude Code's MCP config (.claude/settings.local.json):

{
  "mcpServers": {
    "docs-output-filter": {
      "command": "docs-output-filter",
      "args": ["--mcp", "--watch"]
    }
  }
}

Documentation

Full documentation: https://ianhi.github.io/docs-output-filter/

Development

git clone https://github.com/ianhi/docs-output-filter
cd docs-output-filter
uv sync
uv run pre-commit install
uv run pytest

License

MIT

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

docs_output_filter-0.1.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

docs_output_filter-0.1.0-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for docs_output_filter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea3b5ffdd34efa592acdab0db404f33ead13cfbdf89ffdce607729efb5aab0ad
MD5 c0b91c848e8b22e8ef5ca9c4bd51bc69
BLAKE2b-256 bc52140b1d86a462fa188abf8fce8e5b10070de9c400ae337011d7f0e0bd2c5a

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on ianhi/docs-output-filter

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

File details

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

File metadata

File hashes

Hashes for docs_output_filter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cad42a440665b70f485a0c5dfb7eaf5f0a6e581a5a0b1c77cda7b12e7e3962a
MD5 23577af1f0639c0be7a44345439b916c
BLAKE2b-256 ced13abd187e379cbb29c20d25a4e240cc0eaeed226a1aa24488bc7315a7d180

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on ianhi/docs-output-filter

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