Skip to content

Add dedicated CLI options reference documentation #13973

@FazeelUsmani

Description

@FazeelUsmani

Problem

Currently, pytest's command-line options are only documented in the pytest --help output. While comprehensive, this format has limitations:

  • Not easily searchable - Users must scan through the entire help text
  • Not browsable online - Help text isn't part of the web documentation
  • Difficult to discover - Users may not know what options exist for their use case
  • Hard to reference - Can't easily link to specific options in discussions or other docs

This addresses the long-standing issue #4492 which requests CLI usage documentation be added to the online docs.

Proposed Solution

Add a dedicated "CLI Options Reference" page in the documentation (doc/en/how-to/cli-options.rst) that:

  1. Organizes options by category for easier navigation:

    • Running and Selecting Tests
    • Output and Verbosity
    • Debugging and Profiling
    • Logging
    • Coverage and Reporting
    • Warnings
    • Fixtures
    • Caching
    • Configuration
  2. Provides context and examples for commonly-used options

  3. Cross-references to related comprehensive documentation sections

  4. Makes options discoverable through the searchable online docs

Example Structure

Running and Selecting Tests
----------------------------

-k EXPRESSION
    Only run tests matching the given expression
    See: :ref:`mark examples`

-x, --exitfirst
    Exit instantly on first error or failed test

Implementation Approach

Rather than auto-generating docs with sphinx-argparse (as suggested in #4492), I propose a manually curated reference that:

  • Focuses on commonly-used options
  • Provides helpful context and usage examples
  • Organizes logically by use case
  • Links to detailed documentation where applicable

Trade-offs:

  • ✅ More user-friendly and contextual
  • ✅ Better organized for learning
  • ❌ Requires manual maintenance to stay in sync

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: docsdocumentation improvement, missing or needing clarificationtype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions