Skip to content

Example style guide, syntax_tree formatter, 80-column examples - #19

Draft
tony wants to merge 12 commits into
masterfrom
example-style
Draft

tony wants to merge 12 commits into
masterfrom
example-style

Conversation

@tony

@tony tony commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
  • Syntax Tree formats Ruby at 100 columns for source and 80 under examples/.
  • The compatibility workflow checks formatting and uses the shared example-width action for tracked Markdown and example sources.
  • Standard keeps formatting and linting the maintainer scripts.

The original merge order calls for the shared site’s 80-column layout at laptop widths. This pass verified the Ruby change on Linux. Docs layout dependency

What changed

Policy

  • .github/WRITING.md includes the shared example rules and explains the files, source markers, width and excerpt commands for Ruby. AGENTS.md links to that section.

Tooling

  1. scripts/format uses the locked Syntax Tree version until formatting is stable, then refreshes copied examples and API source links. --check is read-only.
  2. The single mechanical commit reformats the current Ruby sources and refreshes their checked-in example excerpts and API references across 183 files. Mechanical commit
  3. Compatibility checks format and example width before building release artifacts on pull requests and pushes to master.
  4. .git-blame-ignore-revs lists the formatter commit. Run git config blame.ignoreRevsFile .git-blame-ignore-revs to skip that layout change locally.
  5. The pinned shared width action reads .github/example-width.toml and checks Markdown and Ruby, YAML and JSON example sources. The manifest keeps its expected output intact. The allowlist records the deliberately wide example in WRITING.md. Shared checker
  6. CONTRIBUTING documents both checks. The changelog negative test removes a file from the copied gemspec's file list, so its mutation works after formatting the list.

Examples

  • Name the greeting worker, the MCP initializer parts and long Ruby expressions. Wrap the release commands and client configuration, then regenerate the excerpts.

Evidence

  • Syntax Tree 6.3.0 applies different widths to actual Ruby examples with --print-width. An unformatted line caused the read-only gate to fail and left the source bytes intact. The shared checker rejected a wide Markdown line and a stale allow entry. Both gates passed on the rebased source. Syntax Tree usage
  • Linux on Ruby 4.0.7 and tmux 3.3a and 3.8 passed the complete unit, integration, packaging, RBS and docs checks with zero skips. Each cell verified 184 rendered pages. Each ran 370 unit, 342 integration and 8 installed-gem tests. The final cells took 122.37 and 134.44 seconds. Tested head
  • The formatter exposed a dependency on gemspec whitespace in the changelog test. That test used to remove a contiguous line of filenames. Its fixture now removes the file from the copied specification’s actual file list. Original test · Fixture correction
  • The original comparison of four formatters and the Ripper/Prism maintenance consideration are dated evidence from the earlier branch. Original formatter check · Syntax Tree parser

How to verify

$ mise exec -- bundle exec scripts/format --check

Download the same checker used by CI and run it from the checkout. Pinned shared checker

$ python3 /path/to/check_example_width.py --root .
$ mise exec -- bundle exec scripts/examples/examples --check
$ mise exec -- bundle exec scripts/check outer

@tony
tony force-pushed the example-style branch 4 times, most recently from f4b87f5 to 7e5382c Compare October 4, 2026 16:54
@tony
tony force-pushed the example-style branch 5 times, most recently from 7d63629 to 412e01d Compare October 4, 2026 23:18
@tony
tony force-pushed the example-style branch 3 times, most recently from 8fe9a89 to 53893ed Compare October 5, 2026 05:56
@tony
tony force-pushed the example-style branch 5 times, most recently from da1eed4 to 1cee3c5 Compare October 5, 2026 23:20
@tony
tony force-pushed the example-style branch 2 times, most recently from a462f2f to c6391cc Compare October 11, 2026 06:22
@tony
tony force-pushed the example-style branch 2 times, most recently from 93e1747 to 9c0ef68 Compare October 11, 2026 10:45
@tony
tony force-pushed the example-style branch 2 times, most recently from f950125 to ba04a4e Compare October 11, 2026 12:53
tony added 12 commits December 5, 2026 11:57
why: Ruby examples need a width that fits the site's code blocks, and
contributors need a check they can run before posting an update.

what:
- Format source at 100 columns and examples at 80 with syntax_tree.
- Keep Standard in charge of scripts and refresh copied examples and API
  source links after a write.
why: The format check needs a clean baseline for current Ruby code and
the examples people copy from the documentation.

what:
- Run the formatter over the current sources and examples.
- Regenerate the marked excerpts and API source links.
why: The compatibility workflow reports Ruby source that drifts from
the format used for the checked-in examples.

what:
- Check Ruby formatting before the release artifact dry run.
- Document the write and read-only commands in CONTRIBUTING.
why: Git blame can skip layout changes when tracing the history of a
line.

what:
- Add the formatter commit to .git-blame-ignore-revs.
why: The capture example starts a greeting worker before sending input
and checking its screen and exit status.

what:
- Name the greeting command and refresh its two README excerpts.
why: The initializer supplies both client metadata and capabilities,
while the authored program needs its shell commands in order.

what:
- Name the client metadata and capabilities in the CLI initializer.
- Join the three shell commands without changing their bytes.
why: The release example fits the code block when the command is copied
with a version number.

what:
- Continue the command after the timing prefix.
why: Example width, markers, and sync rules were unwritten, so authors
could not tell which lines a formatter owns and which a width check
would own.

what:
- Add the shared Examples section after Markdown and examples
- Add the repository's limit, formatter scope, example markers and sync
  commands, with a real before and after
- Anchor the Code blocks rules the shared section links to
why: Agents editing an example program or code block need to find the
Examples rules.

what:
- Add code examples to the WRITING.md routing line and link the section
why: Readers copy Ruby programs, client configuration and shell commands
from fixed-width code blocks. The shared action verifies those lines
along with the port's example policy and exceptions.

what:
- Run the pinned width action in compatibility and document its local
  read-only check.
- Name the remaining long expressions, wrap the commands and refresh
  copied excerpts.
why: Formatting the workspace gemspec put each shipped file on its own
line. The negative case needs to remove the file whatever its layout.

what:
- Remove the changelog through the copied gemspec's file list.
why: Contributors can check format and example width before release.

what:
- Record the formatter and example width check under 0.1.4.

This branch was previously deployed

1 inactive (outdated) deployment
docs-preview — cca64163 Deployed Oct 12, 2026 by tony via publish (pr-19, pr, false, docs-preview, true) / publish #159
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.

1 participant