Repository navigation
docs(ruby): generate valid Ruby in doc code samples - #1294
Merged
Merged
Conversation
Contributor
API changelog (oasdiff)Doc-only edits (descriptions, examples) do not appear here. |
Model doc samples were not valid Ruby: unquoted strings, `null` for
missing examples, HTML-escaped arrays/hashes, a per-run `[B@...` value
for binary fields, and `require 'Phrase'` instead of the gem name.
Object params in API doc samples rendered as `{ ... }`.
- model_doc.mustache: require the gem name, quote strings, wrap
timestamps in Time.parse, use File.new for binary fields, and render
examples unescaped.
- Makefile: mustache can't tell a missing example ("null") from a real
one, so rewrite those to `nil` (and `{ ... }` to `{}`) after
generation.
Verified by parsing all 543 generated Ruby snippets with Prism: no
syntax errors, and every model sample argument is a literal.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jablan
force-pushed
the
fix/ruby-doc-samples
branch
from
September 23, 2026 14:11
3452aba to
7777abb
Compare
Sönke Behrendt (theSoenke)
approved these changes
Sep 23, 2026
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.
Why
The code samples in the generated Ruby model docs aren't valid Ruby, e.g. ScreenshotUpdateParameters.md:
Across all model docs:
require 'Phrase'instead of the gem name (246 docs), unquoted strings (335),nullfor missing examples (881), HTML-escaped arrays/hashes (["read",...], 92), and binary fields rendered as a per-run Java identity hash ([B@...). The latter also changes on every generation, causing no-op syncs to phrase-ruby. One API doc (UploadsApi.md) has{ ... }placeholders for object params.After:
Changes
model_doc.mustache:require '{{gemName}}'; strings (incl. enums) quoted, timestamps asTime.parse('...'), binary fields asFile.new('/path/to/file'), everything else via unescaped{{{example}}}.Makefile: the generator renders a missing example as the literal string"null"(and object params as{ ... }from its Java code), which mustache can't detect. Aperl -pistep after generation rewrites those tonil/{}inclients/ruby/docs/*.mdonly.Verification
docs/.',\or a newline (would break single-quoting) and no real"null"string example exists in the spec.🤖 Generated with Claude Code