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.3.1.tar.gz (34.9 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.3.1-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docs_output_filter-0.3.1.tar.gz
  • Upload date:
  • Size: 34.9 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.3.1.tar.gz
Algorithm Hash digest
SHA256 eac706befcf539b415036bb027a59b4148a182f22eb97585750add82b39ce113
MD5 f5fb4497ec726fb549cc581bf2adb9f2
BLAKE2b-256 b8b45136f05c352b086617a831b4dfda154602ec41a35334f23ff1e3873e4a4d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for docs_output_filter-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2339c703a15ad2b3f399cac144c7f2abf41f615e62316153c41f93907caae774
MD5 b3ec65503b2946779ddfe2e65b238bf2
BLAKE2b-256 aab779221d0b64873a0487c94a9029ed5ecf5edba25bcb9d36254b3757a17d6a

See more details on using hashes here.

Provenance

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