Skip to content

Add doc_comment_code_block_small_heuristics, to override use_small_heuristics in doc code #6616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joshtriplett
Copy link
Member

This (unstable) configuration option allows overriding use_small_heuristics for doc code. This is particularly useful for code that wants to use use_small_heuristics = "Max" internally but present doctests and examples using use_small_heuristics = "Default".

This has come up before in the context of formatting the standard library, which uses use_small_heuristics = "Max" internally, but wants to present documentation and examples in the style most people will normally see.

This allows overriding `use_small_heuristics` in doc code. This is
particularly useful for code that wants to use
`use_small_heuristics = "Max"` internally but present doctests and
examples using `use_small_heuristics = "Default"`.
This test is based on the `use_small_heuristics` tests. It tests that
the code *outside* the doc comment gets formatted using `Max`, while the
code inside doc comments gets formatted using `Default`.
@joshtriplett joshtriplett force-pushed the doc-comment-use-small-heuristics branch from 190fe00 to a0dc042 Compare July 25, 2025 22:55
@ytmimi
Copy link
Contributor

ytmimi commented Jul 28, 2025

is doc_comment_code_block_width not enough to override the width settings when formatting code blocks?

@joshtriplett
Copy link
Member Author

@ytmimi No, because if you're using use_small_heuristics = "Max", then the equivalent of doc_comment_code_block_small_heuristics = "Default" would require manually setting all the other widths that "Max" overrode.

@ytmimi
Copy link
Contributor

ytmimi commented Jul 28, 2025

It wasn't originally clear to me but now I understand. You want a way to override all width settings when formatting code blocks in doc comments.

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

Successfully merging this pull request may close these issues.

3 participants