readme_yard 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/docs/index.html ADDED
@@ -0,0 +1,397 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1 id="readme-yard">Readme Yard 🌿</h1>
61
+
62
+ <p><a href="https://badge.fury.io/rb/readme_yard"><img src="https://badge.fury.io/rb/readme_yard.svg" alt="Gem Version"></a></p>
63
+
64
+ <p><strong>Code Version: 0.5.0</strong></p>
65
+
66
+ <p>Build a better README with <a href="https://yardoc.org">YARD</a>
67
+ by generating it straight from the source.</p>
68
+
69
+ <p>This gem aims to minimize the effort needed to keep your
70
+ README, documentation, and source code synced, useful,
71
+ and correct. Among its features, it introduces the @readme tag
72
+ that enables you to embed code comments directly into README sections,
73
+ eliminating redundancy and keeping documentation consistent
74
+ across your codebase and project README.</p>
75
+
76
+ <p>Look at the <a href="https://github.com/mattruzicka/readme_yard/blob/main/README_YARD.md">README_YARD.md</a>
77
+ template for this project to see how it works.
78
+ If you&#39;re reading the README, that means this text is here
79
+ because the custom <code>{@readme ReadmeYard}</code> markdown tag is in
80
+ README_YARD.md and <code>readme build</code> was run at the command line.</p>
81
+
82
+ <hr>
83
+
84
+ <p>⚠️ <strong>Generated file warning</strong> – Edit README_YARD.md, not README.md. Changes to README.md will be lost when running <code>readme build</code>.</p>
85
+
86
+ <p><strong>Future Work</strong></p>
87
+
88
+ <ul>
89
+ <li>Implement safeguards to prevent accidental edits to README.md</li>
90
+ <li>Support bidirectional editing through git integration</li>
91
+ </ul>
92
+
93
+ <p><a href="#contributing">PRs are welcome</a> for these improvements.</p>
94
+
95
+ <hr>
96
+
97
+ <h2 id="table-of-contents">Table of Contents</h2>
98
+
99
+ <ul>
100
+ <li><a href="#installation">Installation</a></li>
101
+ <li><a href="#getting-started">Getting Started</a></li>
102
+ <li><a href="#command-line-usage">Command Line Usage</a></li>
103
+ <li><a href="#tag-usage">Tag Usage</a></li>
104
+ <li><a href="#readme-tag">Readme Tag</a></li>
105
+ <li><a href="#standalone-tag-usage">Standalone Tag Usage</a></li>
106
+ <li><a href="#example-tag">Example Tag</a></li>
107
+ <li><a href="#contributing">Contributing</a></li>
108
+ <li><a href="https://mattruzicka.github.io/readme_yard/">Documentation</a></li>
109
+ </ul>
110
+
111
+ <hr>
112
+
113
+ <h2 id="installation">Installation</h2>
114
+
115
+ <p>Add <a href="https://rubygems.org/gems/readme_yard">gem &quot;readme_yard&quot;</a> to your Gemfile and run <code>bundle install</code> or install it yourself with: <code>gem install readme_yard</code></p>
116
+
117
+ <p><strong>Note:</strong> As of version 0.3.0, Readme Yard requires Ruby 3.0 or higher.</p>
118
+
119
+ <h2 id="getting-started">Getting Started</h2>
120
+
121
+ <p>Run <code>readme build</code> at the command line. This creates a README_YARD.md file if there isn&#39;t one by copying your existing README.md file.</p>
122
+
123
+ <p>README_YARD.md is the template from which <code>readme build</code> generates the README. Readme Yard adds the ability to embed and reference your source code in your README via README_YARD.md.</p>
124
+
125
+ <p>See <a href="#tag-usage">Tag Usage</a>.</p>
126
+
127
+ <hr>
128
+
129
+ <h2 id="command-line-usage">Command Line Usage</h2>
130
+
131
+ <p><code>readme</code> - Prints command line usage.</p>
132
+
133
+ <p><code>readme build</code> - Reads from README_YARD.md and writes to README.md.</p>
134
+
135
+ <p><code>readme yard</code> - Same as <code>readme build</code> + generates yard docs.</p>
136
+
137
+ <p><code>readme version</code> - Prints the current version of ReadmeYard.</p>
138
+
139
+ <hr>
140
+
141
+ <h2 id="tag-usage">Tag Usage</h2>
142
+
143
+ <p>Readme Yard uses YARD tags and custom markdown tags. YARD tags live inside Ruby source code. The markdown tags live inside README_YARD.md.</p>
144
+
145
+ <p>When the Readme Yard build process encounters a tag in README_YARD.md, it searches the Ruby source code for its YARD tag counterpart, formats the output, and embeds it in the README file.</p>
146
+
147
+ <h3 id="tag-reference-table">Tag Reference Table</h3>
148
+
149
+ <table><thead>
150
+ <tr>
151
+ <th>Tag Type</th>
152
+ <th>YARD Syntax (in source code)</th>
153
+ <th>Markdown Syntax (in README_YARD.md)</th>
154
+ <th>Standalone Tag*</th>
155
+ <th>Purpose</th>
156
+ </tr>
157
+ </thead><tbody>
158
+ <tr>
159
+ <td>Readme</td>
160
+ <td><code>@readme</code></td>
161
+ <td><code>{@readme ObjectPath}</code></td>
162
+ <td>N/A</td>
163
+ <td>General purpose tag to embed content from source code</td>
164
+ </tr>
165
+ <tr>
166
+ <td>Readme (comment)</td>
167
+ <td><code>@readme comment</code></td>
168
+ <td><code>{@readme ObjectPath}</code></td>
169
+ <td><code>{@comment ObjectPath}</code></td>
170
+ <td>Embeds only the comment from source code</td>
171
+ </tr>
172
+ <tr>
173
+ <td>Readme (code)</td>
174
+ <td><code>@readme code</code></td>
175
+ <td><code>{@readme ObjectPath}</code></td>
176
+ <td><code>{@code ObjectPath}</code></td>
177
+ <td>Embeds only code implementation</td>
178
+ </tr>
179
+ <tr>
180
+ <td>Readme (source)</td>
181
+ <td><code>@readme source</code></td>
182
+ <td><code>{@readme ObjectPath}</code></td>
183
+ <td><code>{@source ObjectPath}</code></td>
184
+ <td>Embeds both comments and code</td>
185
+ </tr>
186
+ <tr>
187
+ <td>Readme (value)</td>
188
+ <td><code>@readme value</code></td>
189
+ <td><code>{@readme ObjectPath}</code></td>
190
+ <td><code>{@value ObjectPath}</code></td>
191
+ <td>Embeds a Ruby value as a Ruby code block</td>
192
+ </tr>
193
+ <tr>
194
+ <td>Readme (string)</td>
195
+ <td><code>@readme string</code></td>
196
+ <td><code>{@readme ObjectPath}</code></td>
197
+ <td><code>{@string ObjectPath}</code></td>
198
+ <td>Embeds a Ruby string as normal text</td>
199
+ </tr>
200
+ <tr>
201
+ <td>Example</td>
202
+ <td><code>@example</code></td>
203
+ <td><code>{@example ObjectPath}</code></td>
204
+ <td>N/A</td>
205
+ <td>Embeds example code from YARD @example tags</td>
206
+ </tr>
207
+ </tbody></table>
208
+
209
+ <blockquote>
210
+ <p>*Standalone tags allow embedding content without requiring corresponding YARD tags in source code. See <a href="#standalone-tag-usage">Standalone Tag Usage</a> for details.</p>
211
+ </blockquote>
212
+
213
+ <h3 id="examples">Examples</h3>
214
+
215
+ <p>The next line is a code snippet if you&#39;re looking at the <a href="https://github.com/mattruzicka/readme_yard/blob/main/README.md">README</a> and <code>{@readme ReadmeYard::ExampleTag.hello_world}</code> if you&#39;re looking at <a href="https://github.com/mattruzicka/readme_yard/blob/main/README_YARD.md">README_YARD.md</a>.</p>
216
+
217
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#
218
+ </span><span class='comment'># @example
219
+ </span><span class='comment'># ReadmeYard::ExampleTag.hello_world #=&gt; &quot;Hello 🌎 🌍 🌏&quot;
220
+ </span><span class='comment'>#
221
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_hello_world'>hello_world</span>
222
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Hello 🌎 🌍 🌏</span><span class='tstring_end'>&quot;</span></span>
223
+ <span class='kw'>end</span>
224
+ </code></pre>
225
+
226
+ <p>The markdown tag tells Readme Yard to parse the <code>@readme</code> tag located above the <code>hello_world</code> class method located in <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard/example_tag.rb">lib/readme_yard/example_tag.rb</a>.</p>
227
+
228
+ <p>To use another &quot;meta&quot; example, <code>{@readme ReadmeYard}</code> is used at the top of this project&#39;s README_YARD.md file to generate the first few sentences of this README. <code>ReadmeYard</code> references the class located in <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard.rb">lib/readme_yard.rb</a>.</p>
229
+
230
+ <p>Last one, <code>{@readme ReadmeYard#command_line_usage}</code> is used to generate the &quot;Command Line Usage&quot; section above from the comments of the <code>command_line_usage</code> instance method located in <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard.rb">lib/readme_yard.rb</a>. This method is extra meta: it returns the result of formatting its own comments as markdown. In this way, the usage instructions in the comments, the README, and as printed at the command line will always be in sync.</p>
231
+
232
+ <hr>
233
+
234
+ <h2 id="readme-tag">Readme Tag</h2>
235
+
236
+ <p><strong>Markdown</strong> syntax: <code>{@readme ObjectPath}</code></p>
237
+
238
+ <p><strong>YARD</strong> syntax: <code>@example &lt;name&gt;</code></p>
239
+
240
+ <p>By default, only the text nested under a @readme tag
241
+ will be embedded in the final output. The default
242
+ embed behavior can be changed through the use of tag names.</p>
243
+
244
+ <h3 id="embed-comments">Embed comments</h3>
245
+
246
+ <p><strong>Usage:</strong></p>
247
+
248
+ <pre class="code ruby"><code class="ruby"><span class='comment'># @readme comment
249
+ </span></code></pre>
250
+
251
+ <p>This example <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard/comment_tag.rb">@readme comment</a> tag embeds the below code snippet via the <code>{@readme ReadmeYard::CommentTag.format_tag}</code> markdown tag.</p>
252
+
253
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#
254
+ </span><span class='comment'># This comment is in the README because `@readme comment`
255
+ </span><span class='comment'># is below (in the source code).
256
+ </span><span class='comment'>#
257
+ </span></code></pre>
258
+
259
+ <h3 id="embed-ruby-code">Embed Ruby code</h3>
260
+
261
+ <p><strong>Usage:</strong></p>
262
+
263
+ <pre class="code ruby"><code class="ruby"><span class='comment'># @readme code
264
+ </span></code></pre>
265
+
266
+ <p>This example <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard/code_tag.rb">@readme code</a> tag embeds the below code snippet via the <code>{@readme ReadmeYard::CodeTag.format_tag}</code> markdown tag.</p>
267
+
268
+ <pre class="code ruby"><code class="ruby"><span class='kw'>def</span> <span class='id identifier rubyid_format_tag'>format_tag</span><span class='lparen'>(</span><span class='id identifier rubyid_yard_object'>yard_object</span><span class='comma'>,</span> <span class='id identifier rubyid__tag'>_tag</span><span class='rparen'>)</span>
269
+ <span class='const'>ExampleTag</span><span class='period'>.</span><span class='id identifier rubyid_format_ruby'>format_ruby</span><span class='lparen'>(</span><span class='id identifier rubyid_yard_object'>yard_object</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='rparen'>)</span>
270
+ <span class='kw'>end</span>
271
+ </code></pre>
272
+
273
+ <h3 id="embed-ruby-comments-and-code">Embed Ruby comments and code</h3>
274
+
275
+ <p><strong>Usage:</strong></p>
276
+
277
+ <pre class="code ruby"><code class="ruby"><span class='comment'># @readme source
278
+ </span></code></pre>
279
+
280
+ <p>This example <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard/source_tag.rb">@readme source</a> tag embeds the below code snippet via the <code>{@readme ReadmeYard::SourceTag.format_tag}</code> markdown tag.</p>
281
+
282
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#
283
+ </span><span class='comment'># The comment and code for ReadmeYard::SourceTag#format_tag
284
+ </span><span class='comment'># is in the README because `@readme source` is below (in the source code).
285
+ </span><span class='comment'>#
286
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_format_tag'>format_tag</span><span class='lparen'>(</span><span class='id identifier rubyid_yard_object'>yard_object</span><span class='comma'>,</span> <span class='id identifier rubyid__tag'>_tag</span><span class='rparen'>)</span>
287
+ <span class='id identifier rubyid_text'>text</span> <span class='op'>=</span> <span class='const'>CommentTag</span><span class='period'>.</span><span class='id identifier rubyid_format_docstring_as_comment'>format_docstring_as_comment</span><span class='lparen'>(</span><span class='id identifier rubyid_yard_object'>yard_object</span><span class='rparen'>)</span>
288
+ <span class='id identifier rubyid_text'>text</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_yard_object'>yard_object</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
289
+ <span class='const'>ExampleTag</span><span class='period'>.</span><span class='id identifier rubyid_format_ruby'>format_ruby</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='rparen'>)</span>
290
+ <span class='kw'>end</span>
291
+ </code></pre>
292
+
293
+ <h3 id="embed-a-ruby-value-as-a-ruby-code-block">Embed a Ruby value as a Ruby code block</h3>
294
+
295
+ <p><strong>Usage:</strong></p>
296
+
297
+ <pre class="code ruby"><code class="ruby"><span class='comment'># @readme value
298
+ </span></code></pre>
299
+
300
+ <p>This example <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard/value_tag.rb">@readme value</a> tag embeds the below code snippet via the <code>{@value ReadmeYard::ValueTag::EXAMPLE}</code> markdown tag.</p>
301
+
302
+ <pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='label'>key:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>value</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
303
+ </code></pre>
304
+
305
+ <h3 id="embed-a-ruby-string-as-normal-text">Embed a Ruby string as normal text</h3>
306
+
307
+ <p><strong>Usage:</strong></p>
308
+
309
+ <p>Because a <a href="https://github.com/mattruzicka/readme_yard/blob/main/lib/readme_yard/string_tag.rb">@readme string</a> tag:</p>
310
+
311
+ <pre class="code ruby"><code class="ruby"><span class='comment'># @readme string
312
+ </span></code></pre>
313
+
314
+ <p>Is located above this constant:</p>
315
+
316
+ <pre class="code ruby"><code class="ruby"><span class='const'>XZAMPLE</span> <span class='op'>=</span> <span class='heredoc_beg'>&lt;&lt;~STRING</span>
317
+ <span class='tstring_content'> I heard you like self-documenting Ruby, so I wrote
318
+ </span><span class='tstring_content'> self-documenting Ruby for your self-documenting Ruby.
319
+ </span><span class='heredoc_end'>STRING
320
+ </span></code></pre>
321
+
322
+ <p>We see can see its string value as simple text below:</p>
323
+
324
+ <p>I heard you like self-documenting Ruby, so I wrote
325
+ self-documenting Ruby for your self-documenting Ruby.</p>
326
+
327
+ <hr>
328
+
329
+ <h2 id="standalone-tag-usage">Standalone Tag Usage</h2>
330
+
331
+ <p>While using the <code>@readme</code> tag in your source code is recommended because it makes the README&#39;s dependency on source code explicit, sometimes it&#39;s useful to embed source code snippets directly without it. This is especially valuable when a source object can only contain one <code>@readme</code> tag, but you want to highlight multiple aspects of the object.</p>
332
+
333
+ <p>You can use any of these tags directly in README_YARD.md without requiring a corresponding <code>@readme</code> tag in the source code:</p>
334
+
335
+ <ul>
336
+ <li><code>{@comment ObjectPath}</code> - Embeds comments only</li>
337
+ <li><code>{@code ObjectPath}</code> - Embeds code only</li>
338
+ <li><code>{@source ObjectPath}</code> - Embeds both comments and code</li>
339
+ <li><code>{@value ObjectPath}</code> - Embeds a Ruby value as a Ruby code block</li>
340
+ <li><code>{@string ObjectPath}</code> - Embeds a Ruby string as plain text</li>
341
+ </ul>
342
+
343
+ <p>For example, in the StringTag section above, we used both:</p>
344
+
345
+ <ul>
346
+ <li><code>{@code ReadmeYard::StringTag::XZAMPLE}</code> to show the constant definition</li>
347
+ <li><code>{@string ReadmeYard::StringTag::XZAMPLE}</code> to display the string value as text</li>
348
+ </ul>
349
+
350
+ <p>The standalone tag usage provides more flexibility when documenting your code and doesn&#39;t require modifications to the source files.</p>
351
+
352
+ <hr>
353
+
354
+ <h2 id="example-tag">Example Tag</h2>
355
+
356
+ <p><strong>Markdown</strong> syntax: <code>{@example ObjectPath}</code></p>
357
+
358
+ <p><strong>YARD</strong> syntax: <code>@example</code></p>
359
+
360
+ <p>The Example Tag leverages YARD&#39;s standard <code>@example</code> tag syntax, allowing you to
361
+ include example code in your README directly from source files. This saves time and
362
+ ensures your README stays in sync with your YARD documentation</p>
363
+
364
+ <p><strong>Usage:</strong></p>
365
+
366
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#
367
+ </span><span class='comment'># @example
368
+ </span><span class='comment'># ReadmeYard::ExampleTag.hello_world #=&gt; &quot;Hello 🌎 🌍 🌏&quot;
369
+ </span><span class='comment'>#
370
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_hello_world'>hello_world</span>
371
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Hello 🌎 🌍 🌏</span><span class='tstring_end'>&quot;</span></span>
372
+ <span class='kw'>end</span>
373
+ </code></pre>
374
+
375
+ <p>The below example code is generated from <code>{@example ReadmeYard::ExampleTag.hello_world}</code> because, as you can see above, the &quot;hello_world&quot; class method has an <code>@example</code> tag.</p>
376
+
377
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="ReadmeYard.html" title="ReadmeYard (class)">ReadmeYard</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ReadmeYard/ExampleTag.html" title="ReadmeYard::ExampleTag (class)">ExampleTag</a></span></span><span class='period'>.</span><span class='id identifier rubyid_hello_world'><span class='object_link'><a href="ReadmeYard/ExampleTag.html#hello_world-class_method" title="ReadmeYard::ExampleTag.hello_world (method)">hello_world</a></span></span> <span class='comment'>#=&gt; &quot;Hello 🌎 🌍 🌏&quot;
378
+ </span></code></pre>
379
+
380
+ <hr>
381
+
382
+ <h2 id="contributing">Contributing</h2>
383
+
384
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/mattruzicka/readme_yard">https://github.com/mattruzicka/readme_yard</a>.</p>
385
+
386
+ <p>Thanks for reading me, the README that documents how to document the README with code that documents itself 🤯</p>
387
+ </div></div>
388
+
389
+ <div id="footer">
390
+ Generated on Fri May 9 00:45:02 2025 by
391
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
392
+ 0.9.37 (ruby-3.4.2).
393
+ </div>
394
+
395
+ </div>
396
+ </body>
397
+ </html>