Add # put comments to your R scripts:
That’s it! You’ll see a flowchart like this:
flowchart TD
load(["Load Data"])
clean["Clean Data"]
report[["Generate Report"]]
%% Connections
load --> clean
clean --> report
%% Styling
classDef inputStyle fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e40af
class load inputStyle
classDef processStyle fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#5b21b6
class clean processStyle
classDef outputStyle fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#15803d
class report outputStyle
# Create a temporary file with annotations
temp_file <- tempfile(fileext = ".R")
writeLines(c(
'# put label:"Extract", output:"raw.csv"',
'data <- read.csv("source.csv")',
'',
'# put label:"Transform", input:"raw.csv", output:"clean.csv"',
'clean <- transform(data)',
'',
'# put label:"Load", input:"clean.csv", output:"database"',
'write_to_db(clean)'
), temp_file)
# Scan and visualize
workflow <- put(temp_file)
#> Warning: Validation issues in file12b43cd84b7f.R line 7:
#> File reference missing extension: database
``` r
cat(put_diagram(workflow, output = "raw"))
flowchart TD dfd6ff32_6c82_4258_9a58_0daf3407a622[“Extract”] cc1b245d_a37b_4d35_96f3_b5fbdf83ba7a[“Transform”] b283cf55_d109_49bb_8adf_91256e5bb69d[“Load”]
%% Connections
dfd6ff32_6c82_4258_9a58_0daf3407a622 --> cc1b245d_a37b_4d35_96f3_b5fbdf83ba7a
cc1b245d_a37b_4d35_96f3_b5fbdf83ba7a --> b283cf55_d109_49bb_8adf_91256e5bb69d
unlink(temp_file)
---
## Annotation Syntax at a Glance
| Field | Purpose | Required |
|-------|---------|----------|
| `label` | Human-readable name | Yes |
| `input` | Files/data consumed | No |
| `output` | Files/data produced | No |
| `id` | Unique identifier | No (auto-generated) |
| `node_type` | `input`, `process`, `output`, `decision`, `start`, `end` | No (defaults to `process`) |
**Multiple inputs/outputs:** Use commas: `input:"a.csv, b.csv"`
---
## Multi-Language Support
putior works with 30+ languages. Comment prefix is auto-detected:
| Language | Annotation |
|----------|------------|
| R, Python, Shell | `# put label:"..."` |
| SQL, Lua | `-- put label:"..."` |
| JavaScript, Go, Rust | `// put label:"..."` |
| MATLAB | `% put label:"..."` |
---
## Common Patterns
### Scan a Directory
``` r
workflow <- put("./src/")
put_diagram(workflow)
# Core functions
put(path) # Extract annotations
put_diagram(workflow) # Generate Mermaid diagram
put_auto(path) # Auto-detect workflow (no annotations)
put_generate(path) # Generate annotation suggestions
# Useful options
put("./", recursive = TRUE) # Include subdirectories
put_diagram(wf, theme = "github", direction = "LR")
put_diagram(wf, show_artifacts = FALSE) # Hide data filesNeed help? Run ?put or
?put_diagram for full documentation.
| Guide | Description |
|---|---|
| Annotation Guide | Complete syntax reference |
| Features Tour | Auto-detection, themes, logging |
| API Reference | Function documentation |
| Showcase | Real-world examples |
| Quick Reference | At-a-glance reference card |
| Troubleshooting | Common issues and solutions |
| AI Integration | MCP/ACP integration guide |