Skip to content

Commit f3d5152

Browse files
Move JS module rdoc into .rb file to include example section
rdoc somehow ignore the section in .c
1 parent 5136535 commit f3d5152

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

ext/js/js-core.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -457,25 +457,6 @@ static VALUE _rb_js_proc_to_js(VALUE obj) {
457457
return jsvalue_s_new(rb_js_abi_host_proc_to_js_function((uint32_t)obj));
458458
}
459459

460-
/*
461-
* Document-module: JS
462-
*
463-
* The JS module provides a way to interact with JavaScript from Ruby.
464-
*
465-
* == Example
466-
*
467-
* A simple eval and object access:
468-
*
469-
* require 'js'
470-
* JS.eval("return 1 + 2") # => 3
471-
* JS.global[:document].write("Hello, world!")
472-
* JS.global[:document].addEventListner("click") do |event|
473-
* puts event # => # [object MouseEvent]
474-
* puts event[:detail] # => 1
475-
* end
476-
*
477-
*/
478-
479460
/*
480461
* Document-class: JS::Object
481462
*

ext/js/lib/js.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
require "js.so"
22

3+
# The JS module provides a way to interact with JavaScript from Ruby.
4+
#
5+
# == Example
6+
#
7+
# require 'js'
8+
# JS.eval("return 1 + 2") # => 3
9+
# JS.global[:document].write("Hello, world!")
10+
# JS.global[:document].addEventListner("click") do |event|
11+
# puts event # => # [object MouseEvent]
12+
# puts event[:detail] # => 1
13+
# end
14+
#
15+
module JS
16+
end
17+
318
class JS::Object
419
def method_missing(sym, *args, &block)
520
if self[sym].typeof == "function"

0 commit comments

Comments
 (0)