Concept Flow - YARD for documentation
Write Ruby code
Add YARD comments
Run YARD tool
YARD parses comments
Generate HTML docs
Open docs in browser
YARD reads special comments in Ruby code and creates easy-to-read HTML documentation.
class Calculator # Adds two numbers # @param a [Integer] # @param b [Integer] # @return [Integer] def add(a, b) a + b end end
| Step | Action | Input/Code | YARD Processing | Output/Result |
|---|---|---|---|---|
| 1 | Read Ruby code | class Calculator ... end | Identify classes and methods | Found class Calculator and method add |
| 2 | Read comments | # Adds two numbers\n# @param a [Integer]\n# @param b [Integer]\n# @return [Integer] | Parse YARD tags | Extract method description and param info |
| 3 | Build documentation model | Parsed code and comments | Create structured doc objects | Method add documented with params and return |
| 4 | Generate HTML | Documentation model | Convert to HTML pages | HTML files created for Calculator and add |
| 5 | Open docs | HTML files | Render in browser | User sees formatted docs with descriptions and types |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|
| code | Ruby source code | Same | Same | Same | Same |
| comments | Raw comments | Parsed YARD tags | Same | Same | Same |
| doc_model | Empty | Empty | Filled with method info | Same | Same |
| html_docs | null | null | null | Created | Same |
YARD documents Ruby code by reading special comments. Use @param and @return tags to describe methods. Run YARD tool to generate HTML docs. Docs show method details and types clearly. Helps others understand your code easily.