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

# Run directly (no install needed)
uvx docs-output-filter -- mkdocs build

# Or install permanently
uv tool install docs-output-filter

# Or 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
docs-output-filter --share-state -- mkdocs serve --livereload

# Terminal 2: Add MCP server to Claude Code (if installed)
claude mcp add --scope user --transport stdio docs-output-filter -- docs-output-filter --mcp --watch
# Or with uvx (no install needed)
claude mcp add --scope user --transport stdio docs-output-filter -- uvx docs-output-filter --mcp --watch

Documentation

Full documentation: https://ianhuntisaak.com/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.2.0.tar.gz (34.8 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.2.0-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docs_output_filter-0.2.0.tar.gz
  • Upload date:
  • Size: 34.8 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.2.0.tar.gz
Algorithm Hash digest
SHA256 51115ae58127719ae1e8947fba6f0b4440d3c1c7fcdf4f09edb9c5ff9e0165e2
MD5 8cdc37fd08b1daa87c68f98e6a2f5a98
BLAKE2b-256 099032546728f6b68b8d14097deb7a443724d620d9cbc3ec654859cfbe4eb73c

See more details on using hashes here.

Provenance

The following attestation bundles were made for docs_output_filter-0.2.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docs_output_filter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 917cdcbc336005fc7faa8c430c9e6d7ccb9f7b8a22f2831900a4e65e397e4eed
MD5 99de053b80c9ab17cf49d698a5857b4e
BLAKE2b-256 b723120029dbb04326876997305dfc0c9994e60cdd6948e9bf2427501dae7c70

See more details on using hashes here.

Provenance

The following attestation bundles were made for docs_output_filter-0.2.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