Skip to content

Commit 9b3117d

Browse files
committed
Update doc
1 parent 7e7abdf commit 9b3117d

1 file changed

Lines changed: 194 additions & 72 deletions

File tree

docs/index.html

Lines changed: 194 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,86 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta name="description" content="SheetRuby - mruby VM in your spreadsheet">
7-
<title>SheetRuby Documentation</title>
7+
<meta name="description" content="SheetRuby - Run Ruby code in Google Sheets using mruby/edge">
8+
<title>SheetRuby - mruby VM in your spreadsheet</title>
89
<style>
910
* {
1011
margin: 0;
1112
padding: 0;
1213
box-sizing: border-box;
1314
}
14-
15+
1516
body {
1617
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
1718
line-height: 1.6;
1819
color: #333;
1920
background: #f5f5f5;
2021
}
21-
22+
2223
header {
2324
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
2425
color: white;
2526
padding: 2rem 0;
2627
text-align: center;
27-
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
28+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
2829
}
29-
30+
3031
header h1 {
3132
font-size: 2.5rem;
3233
margin-bottom: 0.5rem;
3334
}
34-
35+
3536
header p {
3637
font-size: 1.2rem;
3738
opacity: 0.9;
3839
}
39-
40+
4041
.container {
4142
max-width: 1200px;
4243
margin: 2rem auto;
4344
padding: 0 2rem;
4445
}
45-
46+
4647
.card {
4748
background: white;
4849
border-radius: 8px;
4950
padding: 2rem;
5051
margin-bottom: 2rem;
51-
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
52+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
5253
}
53-
54+
5455
.card h2 {
5556
color: #667eea;
5657
margin-bottom: 1rem;
5758
font-size: 1.8rem;
5859
}
59-
60-
.card p {
61-
margin-bottom: 1rem;
62-
}
63-
64-
.features {
65-
display: grid;
66-
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
67-
gap: 1.5rem;
68-
margin-top: 2rem;
69-
}
70-
71-
.feature-card {
72-
background: white;
73-
border-radius: 8px;
74-
padding: 1.5rem;
75-
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
76-
transition: transform 0.3s ease;
60+
61+
.card h3 {
62+
color: #764ba2;
63+
margin-top: 1.5rem;
64+
margin-bottom: 0.8rem;
65+
font-size: 1.3rem;
7766
}
78-
79-
.feature-card:hover {
80-
transform: translateY(-5px);
81-
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
67+
68+
.card p,
69+
.card li {
70+
margin-bottom: 0.8rem;
8271
}
83-
84-
.feature-card h3 {
85-
color: #667eea;
86-
margin-bottom: 0.5rem;
72+
73+
.card ul,
74+
.card ol {
75+
margin-left: 2rem;
76+
margin-bottom: 1rem;
8777
}
88-
78+
8979
.cta {
9080
text-align: center;
9181
margin: 3rem 0;
9282
}
93-
83+
9484
.btn {
9585
display: inline-block;
9686
padding: 0.8rem 2rem;
@@ -100,81 +90,213 @@
10090
border-radius: 5px;
10191
font-weight: bold;
10292
transition: transform 0.3s ease;
93+
margin: 0.5rem;
10394
}
104-
95+
10596
.btn:hover {
10697
transform: scale(1.05);
10798
}
108-
99+
109100
footer {
110101
background: #333;
111102
color: white;
112103
text-align: center;
113104
padding: 2rem 0;
114105
margin-top: 4rem;
115106
}
116-
107+
117108
code {
118109
background: #f4f4f4;
119110
padding: 0.2rem 0.5rem;
120111
border-radius: 3px;
121112
font-family: 'Courier New', monospace;
113+
font-size: 0.9em;
114+
}
115+
116+
pre {
117+
background: #2d2d2d;
118+
color: #f8f8f2;
119+
padding: 1rem;
120+
border-radius: 5px;
121+
overflow-x: auto;
122+
margin: 1rem 0;
123+
}
124+
125+
pre code {
126+
background: none;
127+
padding: 0;
128+
color: inherit;
129+
}
130+
131+
.example {
132+
background: #f9f9f9;
133+
border-left: 4px solid #667eea;
134+
padding: 1rem;
135+
margin: 1rem 0;
136+
}
137+
138+
.example strong {
139+
color: #667eea;
140+
display: block;
141+
margin-bottom: 0.5rem;
142+
}
143+
144+
a {
145+
color: #667eea;
146+
text-decoration: none;
147+
}
148+
149+
a:hover {
150+
text-decoration: underline;
122151
}
123152
</style>
124153
</head>
154+
125155
<body>
126156
<header>
127-
<h1>🔷 SheetRuby</h1>
128-
<p>Bring the power of mruby VM to your spreadsheets</p>
157+
<h1>🔷 sheetruby</h1>
158+
<p>Run Ruby code in Google Sheets using mruby/edge</p>
129159
</header>
130160

131161
<div class="container">
132162
<div class="card">
133-
<h2>Welcome to SheetRuby</h2>
163+
<h2>What is sheetruby?</h2>
134164
<p>
135-
SheetRuby is an innovative project that embeds the <strong>mruby Virtual Machine</strong>
136-
into spreadsheet applications, enabling you to write Ruby code directly in your spreadsheets.
137-
</p>
138-
<p>
139-
This documentation provides everything you need to get started with SheetRuby,
140-
from installation to advanced usage patterns.
165+
sheetruby embeds the <a href="https://github.com/udzura/mrubyedge" target="_blank">mruby/edge</a> VM
166+
into Google Apps Script, allowing you to execute Ruby code directly in your spreadsheets.
167+
It compiles to WebAssembly and runs entirely within Google Sheets' Apps Script environment.
141168
</p>
142169
</div>
143170

144-
<div class="features">
145-
<div class="feature-card">
146-
<h3>🚀 Fast & Lightweight</h3>
147-
<p>Built on mruby, designed for embedded systems with minimal overhead.</p>
171+
<div class="card">
172+
<h2>How to Use</h2>
173+
<ol>
174+
<li>Open your Google Spreadsheet</li>
175+
<li>Go to <strong>Extensions</strong><strong>Apps Script</strong></li>
176+
<li>Copy the contents of
177+
<code><a href="https://github.com/mrubyedge/sheetruby/blob/v0.2.0/combined.js" target="_blank">combined.js</a></code>
178+
and paste it into the script editor</li>
179+
<li>Save the script</li>
180+
<li>Return to your spreadsheet - the <code>EVAL_RUBY_SCRIPT()</code> function is now available!</li>
181+
</ol>
182+
</div>
183+
184+
<div class="card">
185+
<h2><code>EVAL_RUBY_SCRIPT()</code> Function Specification</h2>
186+
<pre><code>EVAL_RUBY_SCRIPT(ruby_code, [arg1], [arg2], [arg3])</code></pre>
187+
188+
<h3>Parameters</h3>
189+
<ul>
190+
<li><strong>First argument (required)</strong>: Ruby script code
191+
<ul>
192+
<li>Can be a string literal or reference to a cell</li>
193+
</ul>
194+
</li>
195+
<li><strong>Arguments 2-4 (optional)</strong>: Data to pass to the Ruby script
196+
<ul>
197+
<li>Can reference cells or ranges</li>
198+
<li>Accessible in Ruby as global variables <code>$arg1</code>, <code>$arg2</code>,
199+
<code>$arg3</code></li>
200+
<li>Currently supports up to 3 arguments</li>
201+
</ul>
202+
</li>
203+
</ul>
204+
205+
<h3>Type Handling</h3>
206+
<ul>
207+
<li><strong>Single cell</strong>: Type is automatically inferred (number, string, boolean)</li>
208+
<li><strong>Multiple cells</strong>: Passed as a 2D array (Array of Arrays)</li>
209+
<li><strong>Return value</strong>: Type is automatically inferred from Ruby result via JSON
210+
serialization</li>
211+
</ul>
212+
213+
<h3>Examples</h3>
214+
215+
<div class="example">
216+
<strong>Basic calculation:</strong>
217+
<pre><code>=EVAL_RUBY_SCRIPT("1 + 2")
218+
# => 3</code></pre>
148219
</div>
149-
<div class="feature-card">
150-
<h3>💎 Ruby Syntax</h3>
151-
<p>Write elegant Ruby code in your spreadsheet cells and formulas.</p>
220+
221+
<div class="example">
222+
<strong>Using cell references:</strong>
223+
<pre><code>=EVAL_RUBY_SCRIPT("$arg1 * 2", A1)
224+
# If A1 = 21, returns 42</code></pre>
152225
</div>
153-
<div class="feature-card">
154-
<h3>🔧 Extensible</h3>
155-
<p>Add custom functions and integrate with your existing tools.</p>
226+
227+
<div class="example">
228+
<strong>Array processing:</strong>
229+
<pre><code>=EVAL_RUBY_SCRIPT("$arg1.map { |x| x * $arg2 }", A1:A3, B1)
230+
# If A1:A3 = [[1], [2], [3]] and B1 = 10
231+
# Returns [10, 20, 30]</code></pre>
156232
</div>
157-
<div class="feature-card">
158-
<h3>📊 Data Processing</h3>
159-
<p>Process complex data transformations with Ruby's powerful features.</p>
233+
234+
<div class="example">
235+
<strong>Multiple arguments:</strong>
236+
<pre><code>=EVAL_RUBY_SCRIPT("$arg1 + $arg2 + $arg3", A1, B1, C1)
237+
# Sum of three cells</code></pre>
238+
</div>
239+
240+
<div class="example">
241+
<strong>String manipulation:</strong>
242+
<pre><code>=EVAL_RUBY_SCRIPT("$arg1.upcase", A1)
243+
# If A1 = "hello", returns "HELLO"</code></pre>
244+
</div>
245+
246+
<div class="example">
247+
<strong>Math functions (with mrubyedge-math):</strong>
248+
<pre><code>=EVAL_RUBY_SCRIPT("Math.sqrt($arg1)", 16)
249+
# => 4.0</code></pre>
160250
</div>
161251
</div>
162252

163253
<div class="card">
164-
<h2>Quick Example</h2>
165-
<p>Write Ruby directly in your spreadsheet cells:</p>
166-
<p><code>=(1..10).map { |n| n * 2 }.sum</code></p>
167-
<p>This Ruby expression calculates the sum of the first 10 even numbers!</p>
254+
<h2>Building from Source</h2>
255+
256+
<h3>Prerequisites</h3>
257+
258+
<p><strong>1. Install Emscripten SDK</strong></p>
259+
<pre><code>git clone https://github.com/emscripten-core/emsdk.git
260+
cd emsdk
261+
./emsdk install latest
262+
./emsdk activate latest
263+
source ./emsdk_env.sh</code></pre>
264+
265+
<p><strong>2. Install Rust with the wasm32-unknown-emscripten target:</strong></p>
266+
<pre><code>rustup target add wasm32-unknown-emscripten</code></pre>
267+
268+
<p><strong>3. Set the BINDGEN_EXTRA_CLANG_ARGS environment variable:</strong></p>
269+
<pre><code>export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$EMSDK/upstream/emscripten/cache/sysroot"</code></pre>
270+
271+
<h3>Build</h3>
272+
<pre><code>make build</code></pre>
273+
<p>This will generate
274+
<code><a href="https://github.com/mrubyedge/sheetruby/blob/v0.2.0/combined.js" target="_blank">combined.js</a></code>
275+
in the project root.</p>
276+
</div>
277+
278+
<div class="card">
279+
<h2>Contributing</h2>
280+
<p>Bug reports and contributions are welcome! Please feel free to:</p>
281+
<ul>
282+
<li>Report issues on <a href="https://github.com/mrubyedge/sheetruby/issues" target="_blank">GitHub
283+
Issues</a></li>
284+
<li>Submit pull requests</li>
285+
<li>Share your use cases and feedback</li>
286+
</ul>
168287
</div>
169288

170289
<div class="cta">
171-
<a href="https://github.com/mrubyedge/sheetruby" class="btn">View on GitHub</a>
290+
<a href="https://github.com/mrubyedge/sheetruby" class="btn" target="_blank">View on GitHub</a>
291+
<a href="https://github.com/udzura/mrubyedge" class="btn" target="_blank">mruby/edge Project</a>
172292
</div>
173293
</div>
174294

175295
<footer>
176-
<p>&copy; 2026 mruby/edge. Licensed under BSD 3-Clause License.</p>
177-
<p>SheetRuby - Making spreadsheets programmable with Ruby</p>
296+
<p>&copy; 2026 mruby/edge. See <a href="https://github.com/mrubyedge/sheetruby/blob/main/LICENSE"
297+
style="color: white;">LICENSE</a> for details.</p>
298+
<p>sheetruby - Making spreadsheets programmable with Ruby</p>
178299
</footer>
179300
</body>
180-
</html>
301+
302+
</html>

0 commit comments

Comments
 (0)