summaryrefslogtreecommitdiff
path: root/doc/en
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2015-03-07 15:16:37 +0100
committerSébastien Helleu <flashcode@flashtux.org>2015-03-07 16:52:30 +0100
commit300d1ad44e81ff832d622e5e4137995f1649c7f6 (patch)
tree34128e4eacdab2da72f0cc9a8089d74153346c1a /doc/en
parentbed4ee1f355326ecdd9945fb8b5371cea6cd1509 (diff)
downloadweechat-300d1ad44e81ff832d622e5e4137995f1649c7f6.zip
doc: add Javascript plugin in docs
Diffstat (limited to 'doc/en')
-rw-r--r--doc/en/autogen/plugin_api/completions.asciidoc2
-rw-r--r--doc/en/autogen/plugin_api/hdata.asciidoc34
-rw-r--r--doc/en/autogen/plugin_api/infolists.asciidoc2
-rw-r--r--doc/en/autogen/plugin_api/plugins_priority.asciidoc2
-rw-r--r--doc/en/autogen/user/javascript_commands.asciidoc22
-rw-r--r--doc/en/weechat_dev.en.asciidoc65
-rw-r--r--doc/en/weechat_plugin_api.en.asciidoc24
-rw-r--r--doc/en/weechat_scripting.en.asciidoc44
-rw-r--r--doc/en/weechat_user.en.asciidoc58
9 files changed, 191 insertions, 62 deletions
diff --git a/doc/en/autogen/plugin_api/completions.asciidoc b/doc/en/autogen/plugin_api/completions.asciidoc
index d06f93f47..66da8e0fb 100644
--- a/doc/en/autogen/plugin_api/completions.asciidoc
+++ b/doc/en/autogen/plugin_api/completions.asciidoc
@@ -46,6 +46,8 @@
| irc | nick | nicks of current IRC channel
+| javascript | javascript_script | list of scripts
+
| lua | lua_script | list of scripts
| perl | perl_script | list of scripts
diff --git a/doc/en/autogen/plugin_api/hdata.asciidoc b/doc/en/autogen/plugin_api/hdata.asciidoc
index 637e5253d..86a48dc3d 100644
--- a/doc/en/autogen/plugin_api/hdata.asciidoc
+++ b/doc/en/autogen/plugin_api/hdata.asciidoc
@@ -222,6 +222,40 @@
** lists:
*** 'irc_servers'
*** 'last_irc_server'
+* 'javascript_callback': callback of a script
+** plugin: javascript
+** variables:
+*** 'script' (pointer, hdata: "javascript_script")
+*** 'function' (string)
+*** 'data' (string)
+*** 'config_file' (pointer, hdata: "config_file")
+*** 'config_section' (pointer, hdata: "config_section")
+*** 'config_option' (pointer, hdata: "config_option")
+*** 'hook' (pointer)
+*** 'buffer' (pointer, hdata: "buffer")
+*** 'bar_item' (pointer, hdata: "bar_item")
+*** 'upgrade_file' (pointer)
+*** 'prev_callback' (pointer, hdata: "javascript_callback")
+*** 'next_callback' (pointer, hdata: "javascript_callback")
+* 'javascript_script': list of scripts
+** plugin: javascript
+** variables:
+*** 'filename' (string)
+*** 'interpreter' (pointer)
+*** 'name' (string)
+*** 'author' (string)
+*** 'version' (string)
+*** 'license' (string)
+*** 'description' (string)
+*** 'shutdown_func' (string)
+*** 'charset' (string)
+*** 'callbacks' (pointer, hdata: "javascript_callback")
+*** 'unloading' (integer)
+*** 'prev_script' (pointer, hdata: "javascript_script")
+*** 'next_script' (pointer, hdata: "javascript_script")
+** lists:
+*** 'last_script'
+*** 'scripts'
* 'lua_callback': callback of a script
** plugin: lua
** variables:
diff --git a/doc/en/autogen/plugin_api/infolists.asciidoc b/doc/en/autogen/plugin_api/infolists.asciidoc
index 6f6990f9f..7e8e0119b 100644
--- a/doc/en/autogen/plugin_api/infolists.asciidoc
+++ b/doc/en/autogen/plugin_api/infolists.asciidoc
@@ -18,6 +18,8 @@
| irc | irc_server | list of IRC servers | server pointer (optional) | server name (wildcard "*" is allowed) (optional)
+| javascript | javascript_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional)
+
| logger | logger_buffer | list of logger buffers | logger pointer (optional) | -
| lua | lua_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional)
diff --git a/doc/en/autogen/plugin_api/plugins_priority.asciidoc b/doc/en/autogen/plugin_api/plugins_priority.asciidoc
index d5a171b0b..8156259db 100644
--- a/doc/en/autogen/plugin_api/plugins_priority.asciidoc
+++ b/doc/en/autogen/plugin_api/plugins_priority.asciidoc
@@ -8,5 +8,5 @@
. xfer (6000)
. irc (5000)
. relay (4000)
-. guile, lua, perl, python, ruby, tcl (3000)
+. guile, javascript, lua, perl, python, ruby, tcl (3000)
. script (2000)
diff --git a/doc/en/autogen/user/javascript_commands.asciidoc b/doc/en/autogen/user/javascript_commands.asciidoc
new file mode 100644
index 000000000..033797446
--- /dev/null
+++ b/doc/en/autogen/user/javascript_commands.asciidoc
@@ -0,0 +1,22 @@
+[[command_javascript_javascript]]
+[command]*`javascript`* list/load/unload scripts::
+
+----
+/javascript list|listfull [<name>]
+ load [-q] <filename>
+ autoload
+ reload|unload [-q] [<name>]
+
+ list: list loaded scripts
+listfull: list loaded scripts (verbose)
+ load: load a script
+autoload: load all scripts in "autoload" directory
+ reload: reload a script (if no name given, unload all scripts, then load all scripts in "autoload" directory)
+ unload: unload a script (if no name given, unload all scripts)
+filename: script (file) to load
+ name: a script name (name used in call to "register" function)
+ -q: quiet mode: do not display messages
+
+Without argument, this command lists all loaded scripts.
+----
+
diff --git a/doc/en/weechat_dev.en.asciidoc b/doc/en/weechat_dev.en.asciidoc
index 976bb9471..6a2e2260b 100644
--- a/doc/en/weechat_dev.en.asciidoc
+++ b/doc/en/weechat_dev.en.asciidoc
@@ -46,35 +46,36 @@ The main WeeChat directories are:
[width="100%",cols="1v,5",options="header"]
|===
-| Directory | Description
-| src/ | Root of sources
-| core/ | Core functions: entry point, internal structures
-| gui/ | Functions for buffers, windows, ... (used by all interfaces)
-| curses/ | Curses interface
-| plugins/ | Plugin and scripting API
-| alias/ | Alias plugin
-| aspell/ | Aspell plugin
-| charset/ | Charset plugin
-| exec/ | Exec plugin
-| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat)
-| irc/ | IRC (Internet Relay Chat) plugin
-| logger/ | Logger plugin (write messages displayed to files)
-| relay/ | Relay plugin (irc proxy + relay for remote interfaces)
-| script/ | Scripts manager
-| python/ | Python scripting API
-| perl/ | Perl scripting API
-| ruby/ | Ruby scripting API
-| lua/ | Lua scripting API
-| tcl/ | Tcl scripting API
-| guile/ | Guile (scheme) scripting API
-| trigger/ | Trigger plugin
-| xfer/ | Xfer plugin (IRC DCC file/chat)
-| tests/ | Tests
-| unit/ | Unit tests
-| core/ | Unit tests for core functions
-| doc/ | Documentation
-| po/ | Translations files (gettext)
-| debian/ | Debian packaging
+| Directory | Description
+| src/ | Root of sources
+| core/ | Core functions: entry point, internal structures
+| gui/ | Functions for buffers, windows, ... (used by all interfaces)
+| curses/ | Curses interface
+| plugins/ | Plugin and scripting API
+| alias/ | Alias plugin
+| aspell/ | Aspell plugin
+| charset/ | Charset plugin
+| exec/ | Exec plugin
+| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat)
+| irc/ | IRC (Internet Relay Chat) plugin
+| logger/ | Logger plugin (write messages displayed to files)
+| relay/ | Relay plugin (irc proxy + relay for remote interfaces)
+| script/ | Scripts manager
+| python/ | Python scripting API
+| perl/ | Perl scripting API
+| ruby/ | Ruby scripting API
+| lua/ | Lua scripting API
+| tcl/ | Tcl scripting API
+| guile/ | Guile (scheme) scripting API
+| javascript/ | Javascript scripting API
+| trigger/ | Trigger plugin
+| xfer/ | Xfer plugin (IRC DCC file/chat)
+| tests/ | Tests
+| unit/ | Unit tests
+| core/ | Unit tests for core functions
+| doc/ | Documentation
+| po/ | Translations files (gettext)
+| debian/ | Debian packaging
|===
[[sources]]
@@ -215,6 +216,10 @@ WeeChat "core" is located in following directories:
| irc-sasl.c | SASL authentication with IRC server
| irc-server.c | I/O communication with IRC server
| irc-upgrade.c | Save/restore of IRC data when upgrading WeeChat
+| javascript/ | Javascript plugin
+| weechat-js.cpp | Main javascript functions (load/unload scripts, execute javascript code)
+| weechat-js-api.cpp | Javascript scripting API functions
+| weechat-js-v8.cpp | Javascript v8 functions
| logger/ | Logger plugin
| logger.c | Main logger functions
| logger-buffer.c | Logger buffer list management
@@ -1031,7 +1036,7 @@ Then you can load this script in your WeeChat, and setup path to your '/doc' dir
Then create this alias to build files:
----
-/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen
+/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen
----
And use command `/doc` to build all files, for all languages.
diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc
index ea8ea38d2..449fbc86e 100644
--- a/doc/en/weechat_plugin_api.en.asciidoc
+++ b/doc/en/weechat_plugin_api.en.asciidoc
@@ -7985,6 +7985,26 @@ List of signals sent by WeeChat and plugins:
String: server name + "," + nick |
A nick in notify list is back (away status removed)
+| javascript | javascript_script_loaded +
+ _(WeeChat ≥ 1.2)_ |
+ String: path to script |
+ Javascript script loaded
+
+| javascript | javascript_script_unloaded +
+ _(WeeChat ≥ 1.2)_ |
+ String: path to script |
+ Javascript script unloaded
+
+| javascript | javascript_script_installed +
+ _(WeeChat ≥ 1.2)_ |
+ String: comma-separated list of paths to scripts installed |
+ Javascript script(s) installed
+
+| javascript | javascript_script_removed +
+ _(WeeChat ≥ 1.2)_ |
+ String: comma-separated list of scripts removed |
+ Javascript script(s) removed
+
| logger | logger_start |
Pointer: buffer |
Start logging for buffer
@@ -8565,6 +8585,8 @@ Five signals can be sent to install a script, according to language:
* 'ruby_script_install'
* 'lua_script_install'
* 'tcl_script_install'
+* 'guile_script_install'
+* 'javascript_script_install'
The callback will do following actions when receiving signal:
@@ -8603,6 +8625,8 @@ Five signals can be sent to remove list of scripts, according to language:
* 'ruby_script_remove'
* 'lua_script_remove'
* 'tcl_script_remove'
+* 'guile_script_remove'
+* 'javascript_script_remove'
For each script in list, the callback will unload then remove script.
diff --git a/doc/en/weechat_scripting.en.asciidoc b/doc/en/weechat_scripting.en.asciidoc
index d4bb03e73..44dd440f8 100644
--- a/doc/en/weechat_scripting.en.asciidoc
+++ b/doc/en/weechat_scripting.en.asciidoc
@@ -28,6 +28,7 @@ script languages:
* lua
* tcl
* guile (scheme)
+* javascript
[NOTE]
Almost all examples in this doc are written in Python, but API is the same for
@@ -82,6 +83,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt
** config_new_option
** bar_new
+==== Javascript
+
+* Functions are called with `weechat.xxx(arg1, arg2, ...);`
+
[[register_function]]
=== Register function
@@ -162,6 +167,14 @@ weechat::print "" "Hello, from tcl script!"
(weechat:print "" "Hello, from scheme script!")
----
+* javascript:
+
+[source,javascript]
+----
+weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
+weechat.print("", "Hello, from javascript script!");
+----
+
[[load_script]]
=== Load script
@@ -174,17 +187,19 @@ It is recommended to use the "script" plugin to load scripts, for example:
/script load script.lua
/script load script.tcl
/script load script.scm
+/script load script.js
----
Each language has also its own command:
----
-/python load python/script.py
-/perl load perl/script.pl
-/ruby load ruby/script.rb
-/lua load lua/script.lua
-/tcl load tcl/script.tcl
-/guile load guile/script.scm
+/python load script.py
+/perl load script.pl
+/ruby load script.rb
+/lua load script.lua
+/tcl load script.tcl
+/guile load script.scm
+/javascript load script.js
----
You can make link in directory 'language/autoload' to autoload script when
@@ -343,6 +358,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
----
+* javascript:
+
+[source,javascript]
+----
+function timer_cb(data, remaining_calls) {
+ weechat.print("", "timer! data=" + data);
+ return weechat.WEECHAT_RC_OK;
+}
+
+weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
+----
+
[[script_api]]
== Script API
@@ -520,7 +547,8 @@ weechat.prnt(buffer, "message on #weechat channel")
----
[NOTE]
-Print function is called `print` in Perl/Ruby/Lua/Tcl and `prnt` in Python.
+Print function is called `print` in Perl/Ruby/Lua/Tcl/Guile/Javascript and
+`prnt` in Python.
[[buffers_send_text]]
==== Send text to buffer
@@ -783,7 +811,7 @@ def config_cb(data, option, value):
# ...
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
-# for other languages, change "python" with your language ("perl", "ruby", "lua" or "tcl")
+# for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript)
----
[[config_options_weechat]]
diff --git a/doc/en/weechat_user.en.asciidoc b/doc/en/weechat_user.en.asciidoc
index 4f78218d2..d76bc78ff 100644
--- a/doc/en/weechat_user.en.asciidoc
+++ b/doc/en/weechat_user.en.asciidoc
@@ -139,6 +139,9 @@ compile WeeChat.
| guile-2.0-dev | ≥ 2.0 | |
Guile (scheme) plugin
+| libv8-dev | | |
+ Javascript plugin
+
| asciidoc | ≥ 8.5.0 | |
Build man page and documentation
@@ -245,6 +248,9 @@ List of commonly used options:
| ENABLE_IRC | `ON`, `OFF` | ON |
Compile <<irc_plugin,IRC plugin>>.
+| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
+ Compile <<scripts_plugins,Javascript plugin>>.
+
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
Support of large files.
@@ -281,7 +287,7 @@ List of commonly used options:
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
Compile <<scripts_plugins,script plugins>> (Python, Perl, Ruby, Lua, Tcl,
- Guile).
+ Guile, Javascript).
| ENABLE_TCL | `ON`, `OFF` | ON |
Compile <<scripts_plugins,Tcl plugin>>.
@@ -1773,26 +1779,27 @@ Examples to load, unload or list plugins:
Default plugins are:
-[width="50%",cols="^1,5",options="header"]
-|===
-| Plugin | Description
-| alias | Define alias for commands
-| aspell | Spell checking for command line
-| charset | Charset decoding/encoding for buffers
-| exec | Execution of external commands in WeeChat
-| fifo | FIFO pipe used to remotely send commands to WeeChat
-| irc | IRC chat protocol
-| logger | Log buffers to files
-| relay | Relay data via network
-| script | Scripts manager
-| python | Python scripting API
-| perl | Perl scripting API
-| ruby | Ruby scripting API
-| lua | Lua scripting API
-| tcl | Tcl scripting API
-| guile | Guile (scheme) scripting API
-| trigger | Text replacement and command execution on events triggered by WeeChat/plugins
-| xfer | File transfer and direct chat
+[width="100%",cols="^1,5",options="header"]
+|===
+| Plugin | Description
+| alias | Define alias for commands
+| aspell | Spell checking for command line
+| charset | Charset decoding/encoding for buffers
+| exec | Execution of external commands in WeeChat
+| fifo | FIFO pipe used to remotely send commands to WeeChat
+| irc | IRC chat protocol
+| logger | Log buffers to files
+| relay | Relay data via network
+| script | Scripts manager
+| python | Python scripting API
+| perl | Perl scripting API
+| ruby | Ruby scripting API
+| lua | Lua scripting API
+| tcl | Tcl scripting API
+| guile | Guile (scheme) scripting API
+| javascript | Javascript scripting API
+| trigger | Text replacement and command execution on events triggered by WeeChat/plugins
+| xfer | File transfer and direct chat
|===
To learn more about plugin or script development (through API), please read
@@ -2857,8 +2864,8 @@ The URI must always end with "/weechat" (for 'irc' and 'weechat' protocols).
[[scripts_plugins]]
=== Scripts plugins
-WeeChat provides 6 scripting plugins: Python, Perl, Ruby, Lua, Tcl and Guile
-(scheme).
+WeeChat provides 7 scripting plugins: Python, Perl, Ruby, Lua, Tcl, Guile
+(scheme) and Javascript.
These plugins can load, execute and unload scripts for these languages.
Another plugin called "script" is a scripts manager and is used to load/unload
@@ -2920,6 +2927,11 @@ include::autogen/user/tcl_commands.asciidoc[]
include::autogen/user/guile_commands.asciidoc[]
+[[javascript_commands]]
+==== Javascript commands
+
+include::autogen/user/javascript_commands.asciidoc[]
+
[[trigger_plugin]]
=== Trigger plugin