Repository navigation
Conversation
tony
force-pushed
the
example-style
branch
29 times, most recently
from
October 10, 2026 11:37
00156f1 to
d101c8a
Compare
why: The command that runs the format, lint, vet and test gates in each module was one 174-column line. what: - Continue the module loop one gate per line, as the shell takes them
tony
force-pushed
the
example-style
branch
20 times, most recently
from
October 11, 2026 21:27
64b6cfb to
b6ab033
Compare
why: Nine `Example*_complete` functions in the tmux package share one setup and cleanup block, and pkg.go.dev renders each body as a code block. Each ran past 80 columns (tabs counted as 4) in the cleanup-deadline comment, its `context.WithTimeout` call and a 93-column kill-error test: - api_new_server_example_test.go: 6 lines, up to 97, with an `errors.Join` call and the `NewSessionRequest` literal - api_pane_capture_example_test.go and api_pane_send_keys_example_test.go: 7 lines each, up to 103, with the literal, the `SendKeys` call and a capture comment - api_server_new_session_example_test.go: 7 lines, up to 97, with both literals and a duplicate-session `errors.Join` - api_server_search_sessions_example_test.go: 5 lines, up to 97, with the unexpected-load message - api_server_panes_example_test.go, api_server_sessions_example_test.go, api_server_windows_example_test.go and api_session_new_window_example_test.go: 5 lines each, up to 97, with the literal what: - Rewrap the cleanup-deadline comment and put the arguments of `context.WithTimeout` on lines of their own, in all nine - Assign `server.Kill(cleanup)` to `err` before testing it, and name the wrapped error `stopErr`, in all nine - Put each `NewSessionRequest` field on its own line, in both calls in new-session - Put the `errors.Join` arguments on lines of their own in new-server and new-session - Bind `keys` before `pane.SendKeys` and rewrap the capture comment in pane-capture and send-keys - Shorten search's unexpected-load message to fit 80 columns
why: The root module, which holds the tmux package, does not run golines, so the package's Example functions kept 82 lines over 80 columns, up to 103 wide (tabs counted as 4). pkg.go.dev renders each Example body as a code block. 81 of them can be rewrapped; the other is a `// Output:` line a test compares, which stays whole. what: - Put the arguments of long calls on lines of their own, mostly `server.NewSession`, `pane.SendKeys`, and `server.WaitFor`, and the `context.WithTimeout` cleanup deadlines - Spread the `tmux.Poll` callbacks and the `server.Cmd` and `server.SetOption` arguments one per line - Rewrap two comments
why: The benchmarks README printed a results table in an untagged fence. An untagged fence counts as code, and its six rows run 88 to 91 columns. The table is program output, so the fence says so. what: - Tag the results fence in benchmarks/README.md `text`
why: BENCHMARKS.md printed eleven result tables in untagged fences. An untagged fence counts as code, and their rows run 84 to 91 columns. The tables are program output, so the fences say so, as benchmarks/README.md does after `Tag the output fence`. what: - Tag the eleven results fences in BENCHMARKS.md `text`
why: Two console commands in BENCHMARKS.md ran past 80: the tmux command's `-bench` line listed three full benchmark names (87 columns), and the workspace command sat on one 107-column line. what: - Continue the workspace benchmark command, one flag per line, and join its two names into `Benchmark(DecodeDocument|Normalize)` - Join the three tmux benchmark names into one alternation, Benchmark(LoadBufferFrom|SaveBufferTo|CaptureScrollback), which selects the same benchmarks
why: Four console commands in CONTRIBUTING.md ran 81 to 157 columns. what: - Continue the TMUX_TMPDIR setup, the pinned golangci-lint run, the newest-release test, and the govulncheck loop one flag or command per line, as the shell takes them
why: Two console commands in the MCP testing skill ran 87 and 93 columns. what: - Continue the TMUX_TMPDIR setup one command per line - Put the driver's environment argument on its own line and feed its plan through a heredoc
why: Examples had no width rule, so each author broke lines by taste and the formatter's breaks went unreviewed. The shared section states one rule for each port that adopts it; the local block names this repository's tools and markers. what: - Add the shared Examples section after Code blocks - Add In this repository: limit, unformatted surfaces, markers, and never-break output with its sync commands - Show the fast-path capture check before and after
why: The routing line named prose, commit messages and comments but no code example, so it did not send an agent writing an example program, an Example function or a Markdown code block to the width rules. what: - Name code examples (example programs, Example functions, Markdown code blocks) in the AGENTS.md line that routes to .github/WRITING.md, and link its Examples section
why: golines wraps Go source in the examples module and nothing else. On the tree right after golines ran, this checker and config report 256 lines over 80 columns. 8 are inside the examples module, where golines cannot break them; the other 248 are in code golines never reads: - 159 on surfaces a reader sees rendered: the Example functions in the tmux and tmuxq packages and the mcp module, which render on pkg.go.dev; fenced code in README files; and code in doc comments, such as the ScriptedTmux snippet. The root module cannot scope golines to example_test.go files: a formatter exclusion applies to every formatter at once. https://github.com/golangci/golangci-lint/blob/v2.14.0/.golangci.reference.yml#L4816-L4835 - 72 in BENCHMARKS.md, CONTRIBUTING.md and a skill page. - 17 in the example programs under mcp/examples and workspace/examples, which sit in the mcp and workspace modules. The `Examples(style[format])` commit gives the libtmux.org widths. golines wraps at max-len with tabs counted as tab-len columns, which is the same measure the checker uses: https://github.com/golangci/golines/blob/v0.15.0/README.md#L57-L60 The checker is one shared script, so the rule reads the same in each port that adopts it. Its `--self-test` plants the failures it reports, and CI runs it first. Alternatives considered: - The lll linter: it reads neither Markdown fences nor doc comments, and counts a tab as one column unless tab-width is set. https://github.com/golangci/golangci-lint/blob/v2.14.0/.golangci.reference.yml#L2221-L2228 - Enable golines in the root module: it would also rewrap library code that is not an example. - Rewrap by hand and trust review: nothing stops the next example from scrolling sideways again. what: - Add internal/tools/check_example_width.py, run with Python 3 and its standard library only - Add .github/example-width.toml: every Markdown page, the files the check reads (example programs, tests, and the examples module's go.mod and .golangci.yml, which a reader copies), one exclude for examples/LICENSE, which is license text, the checker and shared-text digests, and four allowed lines, each with a reason and written with its leading tab as `\t`: two `// docs:<name>` marker lines the README generator reads whole, one `// Output:` line a test compares, and the wide Bad line in the WRITING.md port block - Set allow_ceiling to the number of allow entries - Run the self-test and then the check as a step of the `generated` job in tests.yml - Document the command in CONTRIBUTING.md beside the other gates
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gofumpt never wraps a line, so example code ran to 113 columns (142 counting the
// docs:marker lines, which stay whole). golines (bundled in golangci-lint) now wraps the examples module at 80 columns, and a stdlib Python check holds Example functions, every Markdown page and doc-comment code to 80 in CI. Merge after libtmux/docs#101 deploys: it makes 80 columns fit a libtmux.org code block from 1024 px up.What changed
Policy
.github/WRITING.mdgains an## Examplessection after## Code blocks: the shared text plus an "In this repository" block (limit and config, what golines does not reach,Examplefunctions with// Output:,// docs:<name>markers andgo generate ./...), with a before/after of the fast-path capture check.AGENTS.mdroutes examples to it.Tooling
examples/.golangci.ymlenables golines atmax-len: 80,tab-len: 4, and the examples module is reformatted.internal/tools/check_example_width.pyand.github/example-width.tomlread every**/*.mdpage, plus the example programs, theirgo.modand.golangci.yml,Examplefunctions and doc comments golines cannot reach. The checker runs as a step of thegeneratedjob. Four[[allow]]entries, each with a reason: two// docs:<name>marker lines the README generator reads whole, one// Output:JSON line a test compares, and the deliberately wide Bad line in WRITING.md's port block.examples/LICENSEis excluded with a reason.Examples
go generate ./...intmux/.Evidence
max-lensetting, and counts a tab astab-lencolumns, the same measure the checker uses. golines stays out of the root module because a formatter exclusion applies to every formatter at once;Examples(style[format]): Wrap example code at 80weighs the other options.shorten-commentsstays off because it would split// docs:markers. On the golines commit's parent,golangci-lint fmt ./...(v2.14.0) inexamples/and thengo generate ./...intmux/reproduce that commit byte for byte.CI(fix): Align lint tools with patched Go, golangci-lint 2.14.0 with gofumpt 0.12.0; this branch leaves both as they are.How to verify
$ python3 internal/tools/check_example_width.py --self-test$ python3 internal/tools/check_example_width.py$ (cd examples && golangci-lint run ./...)$ go generate ./...$ (cd mcp && go generate ./...)$ git diff --exit-code