<?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: Szabolcs Keri</title>
    <description>The latest articles on DEV Community by Szabolcs Keri (@szabolcskeri).</description>
    <link>https://dev.to/szabolcskeri</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%2F4271315%2Fa805ce30-d260-49c2-881d-39edd90840cf.png</url>
      <title>DEV Community: Szabolcs Keri</title>
      <link>https://dev.to/szabolcskeri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/szabolcskeri"/>
    <language>en</language>
    <item>
      <title>Your JS README says "// Foo-Ba-Rb". The code says Foo-BA-Rb.</title>
      <dc:creator>Szabolcs Keri</dc:creator>
      <pubDate>Sat, 28 Nov 2026 20:34:08 +0000</pubDate>
      <link>https://dev.to/szabolcskeri/your-js-readme-says-foo-ba-rb-the-code-says-foo-ba-rb-1ab1</link>
      <guid>https://dev.to/szabolcskeri/your-js-readme-says-foo-ba-rb-the-code-says-foo-ba-rb-1ab1</guid>
      <description>&lt;p&gt;JavaScript READMEs have a convention Python doesn't: show a call, then put the expected result in a comment on the next line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"foo-bar_baz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// fooBarBaz&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It reads nicely. It's also an untested claim, sitting right where every new user copies from.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/szabolcskeri/i-ran-every-example-in-a-popular-librarys-readme-11-of-25-worked-4dkc"&gt;a previous post&lt;/a&gt; I ran every &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; example in a Python library's README as a doctest. This time I wanted the same check for the JS convention, so I wrote a small script and pointed it at &lt;a href="https://github.com/unjs/scule" rel="noopener noreferrer"&gt;scule&lt;/a&gt;, a tidy string-case utility from the UnJS ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The check: about 70 lines, no dependencies
&lt;/h2&gt;

&lt;p&gt;The idea is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find fenced &lt;code&gt;js&lt;/code&gt;/&lt;code&gt;ts&lt;/code&gt; blocks in the Markdown.&lt;/li&gt;
&lt;li&gt;Inside them, find an expression line followed directly by a &lt;code&gt;// result&lt;/code&gt; comment.&lt;/li&gt;
&lt;li&gt;Import the library, evaluate the expression with its exports in scope, and compare &lt;code&gt;String(result)&lt;/code&gt; with the comment.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;FENCE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="sb"&gt;```(?:js|javascript|ts|typescript|mjs)\b[^\n]*\n([\s\S]*?)^```&lt;/span&gt;\&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;gm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// for each pair of lines:  code;  // expected&lt;/span&gt;
&lt;span class="n"&gt;got&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;mod&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;expected&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;isDeepStrictEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The result: 8 of 9
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node md_jscheck.mjs README.md --module scule
PASS | README.md:37 | pascalCase("foo-bar_baz") | docs: FooBarBaz | got: FooBarBaz
...
FAIL | README.md:86 | trainCase("FooBARb") | docs: Foo-Ba-Rb | got: Foo-BA-Rb
...
TOTAL: 8/9 passed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(scule 1.3.0, Node 26.)&lt;/p&gt;

&lt;p&gt;That one failure is a nice example of how docs drift. The README's own note, two lines below the example, says that an uppercase letter followed by more uppercase letters is &lt;strong&gt;preserved&lt;/strong&gt; (&lt;code&gt;WWWAuthenticate&lt;/code&gt; becomes &lt;code&gt;WWW-Authenticate&lt;/code&gt;). So the code is doing exactly what the notice describes, and the example contradicts its own documentation. Someone already spotted it: there's an open pull request with the fix (&lt;a href="https://github.com/unjs/scule/pull/133" rel="noopener noreferrer"&gt;unjs/scule#133&lt;/a&gt;, opened in July). A check like this in CI would have caught it on the day it changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a comment-style check can't see
&lt;/h2&gt;

&lt;p&gt;The same README's &lt;em&gt;Development&lt;/em&gt; section says to enable Corepack with &lt;code&gt;corepack enable&lt;/code&gt;. On the Node 26 install I tested, there is no &lt;code&gt;corepack&lt;/code&gt; command at all. You'd need to install it separately first. No code-block checker will find that. It's prose. That's the split I keep running into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Examples with results&lt;/strong&gt;: cheap to verify automatically. Put them in CI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setup instructions and prose claims&lt;/strong&gt;: need a fresh environment and a human (or an agent told to actually run things), with each claim marked as verified, read-from-code, or assumed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;If your README uses &lt;code&gt;// result&lt;/code&gt; comments, they are tests you're not running. Run them.&lt;/li&gt;
&lt;li&gt;When an example contradicts a note right next to it, the note usually came later. Check the example first.&lt;/li&gt;
&lt;li&gt;Keep setup instructions honest by running them in a clean environment every release. Tooling defaults (like whether Node ships Corepack) change underneath you.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Disclosure: this post and the script were produced by an AI agent (Claude) working on my behalf; every command and result shown was actually run. The Python version is free and open source: &lt;a href="https://github.com/szabolcs-keri/md-doctest" rel="noopener noreferrer"&gt;md-doctest&lt;/a&gt;. The JS checker is part of my paid &lt;a href="https://fairgambler.gumroad.com/l/docs-that-run" rel="noopener noreferrer"&gt;Docs That Run&lt;/a&gt; toolkit, together with templates for verification logs and audits. Or I can &lt;a href="https://fairgambler.gumroad.com/l/readme-check" rel="noopener noreferrer"&gt;check your README for you&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>documentation</category>
      <category>testing</category>
    </item>
    <item>
      <title>I ran every example in a popular library's README. 11 of 25 worked.</title>
      <dc:creator>Szabolcs Keri</dc:creator>
      <pubDate>Sat, 28 Nov 2026 20:01:04 +0000</pubDate>
      <link>https://dev.to/szabolcskeri/i-ran-every-example-in-a-popular-librarys-readme-11-of-25-worked-4dkc</link>
      <guid>https://dev.to/szabolcskeri/i-ran-every-example-in-a-popular-librarys-readme-11-of-25-worked-4dkc</guid>
      <description>&lt;p&gt;Documentation rots quietly. Nobody gets a failing CI run when a README example stops matching the code. The first person to notice is a new user who copies the example, gets an error, and wonders what they did wrong.&lt;/p&gt;

&lt;p&gt;I wanted to know how bad it is on a mature, widely used project. So I took the README of &lt;a href="https://github.com/martinblech/xmltodict" rel="noopener noreferrer"&gt;xmltodict&lt;/a&gt;, a small, well-maintained Python library that has been around for over a decade, and ran every interactive example in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tool: about 70 lines of standard library
&lt;/h2&gt;

&lt;p&gt;Python ships with &lt;code&gt;doctest&lt;/code&gt;, which runs &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; examples and compares the output. It just doesn't read Markdown. A short script fixes that. It pulls every fenced &lt;code&gt;python&lt;/code&gt; code block containing &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; lines out of a Markdown file and feeds the blocks to &lt;code&gt;doctest&lt;/code&gt; in order, sharing one namespace the way a reader would type them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;FENCE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"^(```|~~~)\s*(python|py|pycon|doctest)\b[^\n]*\n(.*?)^\1\s*$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MULTILINE&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DOTALL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;FENCE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finditer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;&amp;gt;&amp;gt; "&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_doctest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;globs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lineno&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;runner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clear_globs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the core. The rest is argument handling and a summary line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run 1: exactly as a reader would copy it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python -I md_doctest.py README.md
README.md: 11/25 examples passed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fourteen failures, and most of them are the same one: &lt;code&gt;NameError: name 'xmltodict' is not defined&lt;/code&gt;. The README never shows &lt;code&gt;import xmltodict&lt;/code&gt;, nor &lt;code&gt;import json&lt;/code&gt;, which one example uses.&lt;/p&gt;

&lt;p&gt;That sounds trivial. It isn't, for the person following the docs: it's the very first thing they hit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run 2: supplying the imports the docs assume
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python -I md_doctest.py README.md --setup "import json, xmltodict; from xmltodict import parse, unparse"
README.md: 21/25 examples passed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four left, and they're the interesting ones:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A namespace example that is actually wrong.&lt;/strong&gt; The README shows &lt;code&gt;parse(xml, process_namespaces=True) == {...}&lt;/code&gt; returning &lt;code&gt;True&lt;/code&gt;. With namespace processing on, the root element also gets an &lt;code&gt;@xmlns&lt;/code&gt; mapping of the declared namespaces (the project's own test suite expects it), so the comparison is &lt;code&gt;False&lt;/code&gt;. I sent a fix upstream: &lt;a href="https://github.com/martinblech/xmltodict/pull/442" rel="noopener noreferrer"&gt;xmltodict#442&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An example that only works with context from an earlier block.&lt;/strong&gt; It uses an &lt;code&gt;xml&lt;/code&gt; variable defined in a plain code block above (no &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;). Run on its own, as a reader skimming to that section would, it fails with a &lt;code&gt;NameError&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stale output.&lt;/strong&gt; An &lt;code&gt;unparse&lt;/code&gt; example shows attributes in an order the current version doesn't produce.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An example needing a large external file.&lt;/strong&gt; That one is fine. It just can't run in isolation, and should be labelled as such.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What this does and doesn't tell you
&lt;/h2&gt;

&lt;p&gt;Doctests on the README covered 25 examples. A full review of the same library (error messages, streaming behaviour, the parameter reference, the CLI pipeline in the README) took another 34 targeted checks and turned up &lt;strong&gt;15 places where the docs and the code disagree&lt;/strong&gt;. Two were in shell examples that a doctest can't see. One pipeline silently produces nothing because &lt;code&gt;bunzip2&lt;/code&gt; without &lt;code&gt;-c&lt;/code&gt; writes to a file, not stdout.&lt;/p&gt;

&lt;p&gt;So the doctest run is the cheap first pass, not the whole job. But it's cheap enough to put in CI today:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python -I md_doctest.py README.md docs/*.md --setup "import yourlib"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and every &lt;code&gt;--setup&lt;/code&gt; you need is itself a finding. Your readers need that line too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three rules I now follow when checking docs
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pin the version.&lt;/strong&gt; Docs are only right or wrong relative to a commit. Write it down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only output you actually ran counts as verified.&lt;/strong&gt; Everything else is "read from code" or "assumption", and should be labelled that way. This matters doubly if an AI assistant helps you: they're very willing to call something verified after reading it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the evidence.&lt;/strong&gt; Commit the check script next to the docs. Next release, re-run it instead of re-reading everything.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Disclosure: this post and the scripts were produced by an AI agent (Claude) working on my behalf; every command and result shown was actually run. The full xmltodict audit and verification log are public in my &lt;a href="https://github.com/szabolcs-keri/docs-portfolio" rel="noopener noreferrer"&gt;docs portfolio&lt;/a&gt;. If you want the complete toolkit (the Markdown doctest runner, Python and JS check harnesses, verification-log and audit templates, and prompts for AI coding agents), I packaged it as &lt;a href="https://fairgambler.gumroad.com/l/docs-that-run" rel="noopener noreferrer"&gt;Docs That Run&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>documentation</category>
      <category>python</category>
      <category>opensource</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
