Skip to content

Add CLI document info preflight#2193

Open
godlovesmei wants to merge 2 commits into
microsoft:mainfrom
godlovesmei:feat/cli-info-metadata
Open

Add CLI document info preflight#2193
godlovesmei wants to merge 2 commits into
microsoft:mainfrom
godlovesmei:feat/cli-info-metadata

Conversation

@godlovesmei

Copy link
Copy Markdown

Summary

  • Add markitdown --info FILE for lightweight local document metadata as JSON.
  • Detect the likely converter using existing StreamInfo guesses and converter accepts() checks.
  • Avoid running the full conversion pipeline; unsupported files return JSON with detected_converter: null and a warning.

Fixes #2182

Testing

  • uv run --with-editable 'packages/markitdown[all]' python -m pytest packages/markitdown/tests/test_cli_misc.py -q
  • uv run --with-editable 'packages/markitdown[all]' python -m pytest packages/markitdown/tests/test_cli_vectors.py -q
  • uv run --with-editable 'packages/markitdown[all]' python -m compileall -q packages/markitdown/src packages/markitdown/tests/test_cli_misc.py
  • git diff --check

Copilot AI review requested due to automatic review settings July 5, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a lightweight “document preflight” capability to MarkItDown’s CLI and Python API so callers can retrieve basic metadata (and the likely converter) as JSON without running a full conversion.

Changes:

  • Add DocumentInfo and MarkItDown.get_local_document_info() to inspect local files and detect an applicable converter via StreamInfo guesses + accepts() checks.
  • Add markitdown --info FILE CLI flag to emit the DocumentInfo payload as JSON and exit.
  • Add CLI tests covering the JSON shape for a supported XLSX and an unsupported binary file.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/markitdown/tests/test_cli_misc.py Adds CLI coverage for --info JSON output and unsupported-file warning behavior.
packages/markitdown/src/markitdown/_markitdown.py Introduces DocumentInfo, preflight inspection API, and refactors converter kwargs construction.
packages/markitdown/src/markitdown/main.py Implements --info CLI flag and JSON emission path.
packages/markitdown/src/markitdown/init.py Exports DocumentInfo as part of the public package API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/markitdown/src/markitdown/__main__.py Outdated
Comment thread packages/markitdown/src/markitdown/__main__.py Outdated
Comment thread packages/markitdown/src/markitdown/_markitdown.py Outdated
@godlovesmei

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add \markitdown --info FILE\ flag to emit document metadata as JSON (no full conversion)

2 participants