<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: [NSObject init]</title>
    <description>The latest articles on DEV Community by [NSObject init] (@unurgunite).</description>
    <link>https://dev.to/unurgunite</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3865705%2F611faf9b-9d32-4f26-9d94-f3d5946a2581.jpeg</url>
      <title>DEV Community: [NSObject init]</title>
      <link>https://dev.to/unurgunite</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/unurgunite"/>
    <language>en</language>
    <item>
      <title>Keeping YARD and RBS in sync without going insane</title>
      <dc:creator>[NSObject init]</dc:creator>
      <pubDate>Tue, 06 Oct 2026 08:42:43 +0000</pubDate>
      <link>https://dev.to/unurgunite/keeping-yard-and-rbs-in-sync-without-going-insane-46g4</link>
      <guid>https://dev.to/unurgunite/keeping-yard-and-rbs-in-sync-without-going-insane-46g4</guid>
      <description>&lt;p&gt;I run docscribe daily on client Rails apps. I cannot share that code, so every example below is synthetic and verified against docscribe 1.6.2 on Ruby 3.4.5.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comments lie
&lt;/h2&gt;

&lt;p&gt;This is the shape I keep finding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# @param [String] count&lt;/span&gt;
&lt;span class="c1"&gt;# @return [String]&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="p"&gt;:,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:)&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"verbose!"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;  &lt;span class="c1"&gt;# Boolean&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;times&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;send_ping&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;# Integer&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt;                       &lt;span class="c1"&gt;# Integer&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comment says two Strings in, one String out. The code takes a flag and a count and returns the count. Anyone who trusts the comment calls it wrong: &lt;code&gt;"false"&lt;/code&gt; is truthy, and &lt;code&gt;"3"&lt;/code&gt; has no &lt;code&gt;times&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F33desvcnjqvxq2q3a77y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F33desvcnjqvxq2q3a77y.png" alt="before/after YARD fix" width="799" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What &lt;code&gt;docscribe -a&lt;/code&gt; actually does
&lt;/h2&gt;

&lt;p&gt;Safe mode adds what is missing and leaves the rest alone. On the file above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docscribe &lt;span class="nt"&gt;-a&lt;/span&gt; notify_demo.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# @param [String] count&lt;/span&gt;
&lt;span class="c1"&gt;# @param [Object] verbose Param documentation.&lt;/span&gt;
&lt;span class="c1"&gt;# @return [String]&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="p"&gt;:,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:)&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"verbose!"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;times&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;send_ping&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It added the missing &lt;code&gt;@param verbose&lt;/code&gt;. It did not touch the lying &lt;code&gt;String&lt;/code&gt; tags. That is the contract: safe mode never rewrites a type you wrote. &lt;code&gt;-A&lt;/code&gt; rebuilds the block from scratch; I always &lt;code&gt;git diff&lt;/code&gt; after it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj9y7xnyb2pt68tp9gw6y.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj9y7xnyb2pt68tp9gw6y.gif" alt="terminal run: cat, docscribe -a, cat" width="790" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where types really get fixed
&lt;/h2&gt;

&lt;p&gt;Type correction lives in &lt;code&gt;update_types&lt;/code&gt;, fed by RBS. Given this signature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Object
  def notify: (bool verbose, Integer count) -&amp;gt; Integer
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docscribe update_types &lt;span class="nt"&gt;--rbs&lt;/span&gt; &lt;span class="nt"&gt;--sig-dir&lt;/span&gt; sig notify.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# @param [Boolean] verbose&lt;/span&gt;
&lt;span class="c1"&gt;# @param [Integer] count&lt;/span&gt;
&lt;span class="c1"&gt;# @return [Integer]&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="p"&gt;:,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:)&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"verbose!"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;times&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;send_ping&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;count&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No prose placeholders here because the original had no descriptions to keep. When descriptions exist, &lt;code&gt;update_types&lt;/code&gt; keeps them.&lt;/p&gt;

&lt;p&gt;The reverse direction exists too: &lt;code&gt;docscribe rbs&lt;/code&gt; generates &lt;code&gt;.rbs&lt;/code&gt; from YARD. Types flow both ways, YARD stays the human-readable cache in the middle.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;source:&lt;/code&gt; tells the editor which fix to offer
&lt;/h2&gt;

&lt;p&gt;Every change in 1.6.2 carries &lt;code&gt;source: rbs | infer | syntax&lt;/code&gt; through JSON, SARIF, and daemon responses. The IDE uses it to pick the right lightbulb: &lt;code&gt;rbs&lt;/code&gt; offers "Update types", anything else offers "Fix YARD". That one field is what makes the VS Code and RubyMine plugins feel fast instead of noisy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rails specifics I use daily
&lt;/h2&gt;

&lt;p&gt;Types from &lt;code&gt;schema.rb&lt;/code&gt;, not from code. &lt;code&gt;t.boolean :is_admin&lt;/code&gt; becomes &lt;code&gt;@!attribute [r] is_admin&lt;/code&gt; returning &lt;code&gt;Boolean&lt;/code&gt; in the model, via the collector plugin in &lt;code&gt;examples/plugins&lt;/code&gt;. No hand-written docs for columns.&lt;/p&gt;

&lt;p&gt;One daemon per project serves both editor plugins over a Unix socket JSON-RPC (&lt;code&gt;check&lt;/code&gt;, &lt;code&gt;fix&lt;/code&gt;, &lt;code&gt;check_batch&lt;/code&gt;, &lt;code&gt;update_types&lt;/code&gt;, &lt;code&gt;ping&lt;/code&gt;). When the daemon is off, the plugins fall back to CLI. CI mode runs on exit codes (&lt;code&gt;0&lt;/code&gt; clean, &lt;code&gt;1&lt;/code&gt; missing docs, &lt;code&gt;2&lt;/code&gt; errors) plus &lt;code&gt;check_for_comments&lt;/code&gt;, with &lt;code&gt;json&lt;/code&gt;/&lt;code&gt;sarif&lt;/code&gt; output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Live demo and install: &lt;a href="https://unurgunite.github.io/docscribe" rel="noopener noreferrer"&gt;https://unurgunite.github.io/docscribe&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source: &lt;a href="https://github.com/unurgunite/docscribe" rel="noopener noreferrer"&gt;https://github.com/unurgunite/docscribe&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Gem: &lt;a href="https://rubygems.org/gems/docscribe" rel="noopener noreferrer"&gt;https://rubygems.org/gems/docscribe&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next in 1.7.0
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;docscribe sorbet&lt;/code&gt; - same YARD to signature flow as &lt;code&gt;docscribe rbs&lt;/code&gt;, but generating &lt;code&gt;.rbi&lt;/code&gt;/sig blocks for &lt;code&gt;srb tc&lt;/code&gt;. Plus &lt;code&gt;validate_types&lt;/code&gt; on by default (opt-out with &lt;code&gt;--no-validate-types&lt;/code&gt;). Plus tighter metaprogramming support: better types for &lt;code&gt;define_method&lt;/code&gt; and DSL-generated methods, less &lt;code&gt;Object&lt;/code&gt; fallback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;Heuristics, not a prover, so metaprogramming lands in &lt;code&gt;Object&lt;/code&gt; today. Each release narrows that gap.&lt;/p&gt;

&lt;p&gt;Question I keep asking: do you keep YARD and RBS in sync by hand, or did you give up on one of them?&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>yard</category>
      <category>rbs</category>
      <category>docscribe</category>
    </item>
  </channel>
</rss>
