Updated for version 0.16.10
Introduction
RippleAPI is the official client library to the Ripple Consensus Ledger. Currently, RippleAPI is only available in JavaScript. Using RippleAPI, you can:
@@ -145,6 +146,14 @@ const api = new RippleAPI({ api.on('error', (errorCode, errorMessage) => { console.log(errorCode + ': ' + errorMessage); }); +api.on('connected', () => { + console.log('connected'); +}); +api.on('disconnected', (code) => { + // code - [close code](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent) sent by the server + // will be 1000 if this was normal closure + console.log('disconnected, code:', code); +}); api.connect().then(() => { /* insert code here */ }).then(() => { @@ -1351,7 +1360,7 @@ const api = new RippleAPI();{
@@ -4991,7 +5000,7 @@ return api.combine(signedTransactions);
resultCode
string
-The result code returned by rippled. List of tranasction responses
+The result code returned by rippled. List of transaction responses
resultMessage
@@ -5277,6 +5286,26 @@ return api.computeLedgerHash(ledger);
tooBusy: The server is too busy to help you now.
+connected
+This event is emitted after connection successfully opened.
+Example
+api.on('connected', () => {
+ console.log('Connection is open now.');
+});
+
+disconnected
+This event is emitted when connection is closed.
+Return Value
+The only parameter is a number containing the close code send by the server.
+Example
+api.on('disconnected', (code) => {
+ if (code !== 1000) {
+ console.log('Connection is closed due to error.');
+ } else {
+ console.log('Connection is closed normally.');
+ }
+});
+
diff --git a/tool/dactyl-config.yml b/tool/dactyl-config.yml
index 0bfe52692b..610891d2f0 100644
--- a/tool/dactyl-config.yml
+++ b/tool/dactyl-config.yml
@@ -97,10 +97,11 @@ pages:
category: References
html: reference-rippleapi.html
# Currently this is the only page that's fetched remotely.
- md: https://raw.githubusercontent.com/ripple/ripple-lib/0.16.7/docs/index.md
+ md: https://raw.githubusercontent.com/ripple/ripple-lib/0.16.10/docs/index.md
ripple.com: https://ripple.com/build/rippleapi/
filters:
- remove_doctoc
+ - add_version
sidebar: true
targets:
- local
diff --git a/tool/dactyl_build.py b/tool/dactyl_build.py
index 983bd34d47..31a2c16824 100755
--- a/tool/dactyl_build.py
+++ b/tool/dactyl_build.py
@@ -155,7 +155,7 @@ def parse_markdown(page, target=None, pages=None):
for filter_name in page_filters:
if "filter_markdown" in dir(filters[filter_name]):
logging.info("... applying markdown filter %s" % filter_name)
- md = filters[filter_name].filter_markdown(md)
+ md = filters[filter_name].filter_markdown(md, target=target, page=page)
# Actually parse the markdown
logger.info("... parsing markdown...")
@@ -166,7 +166,7 @@ def parse_markdown(page, target=None, pages=None):
for filter_name in page_filters:
if "filter_html" in dir(filters[filter_name]):
logging.info("... applying HTML filter %s" % filter_name)
- html = filters[filter_name].filter_html(html)
+ html = filters[filter_name].filter_html(html, target=target, page=page)
# Some filters would rather operate on a soup than a string.
# May as well parse once and re-serialize once.
@@ -176,7 +176,7 @@ def parse_markdown(page, target=None, pages=None):
for filter_name in page_filters:
if "filter_soup" in dir(filters[filter_name]):
logging.info("... applying soup filter %s" % filter_name)
- filters[filter_name].filter_soup(soup)
+ filters[filter_name].filter_soup(soup, target=target, page=page)
# ^ the soup filters apply to the same object, passed by reference
# Replace links for any non-default target
diff --git a/tool/filter_add_version.py b/tool/filter_add_version.py
new file mode 100644
index 0000000000..5b6776a249
--- /dev/null
+++ b/tool/filter_add_version.py
@@ -0,0 +1,31 @@
+################################################################################
+## Add version to markdown filter ##
+## Author: Rome Reginelli ##
+## Copyright: Ripple Labs, Inc. 2016 ##
+## ##
+## Adds a message to the beginning of a file with a version number, based on ##
+## the URL of the remotely-fetched markdown. ##
+################################################################################
+import re
+import logging
+
+def filter_markdown(md, target=None, page=None):
+ """Finds the version number and adds it to the start of the page."""
+ version_regex = r"https://raw.githubusercontent.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)/([A-Za-z0-9_-]+\.[A-Za-z0-9_.-]+)/.+\.md"
+
+ try:
+ version_match = re.match(version_regex, page["md"])
+ except (TypeError, KeyError):
+ logging.warning("couldn't get MD path from page %s" % page)
+ return md
+
+ try:
+ github_owner = version_match.group(1)
+ github_project = version_match.group(2)
+ vnum = version_match.group(3)
+ url = "https://github.com/%s/%s/releases/%s" % (github_owner, github_project, vnum)
+ md = ("Updated for version %s
"%(url, vnum))+md
+ except AttributeError:
+ logging.warning("version regex didn't match: %s" % version_match)
+
+ return md
diff --git a/tool/filter_buttonize.py b/tool/filter_buttonize.py
index f1b22cfa24..2a0d5ad24d 100644
--- a/tool/filter_buttonize.py
+++ b/tool/filter_buttonize.py
@@ -8,7 +8,7 @@
################################################################################
import re
-def filter_soup(soup):
+def filter_soup(soup, target=None, page=None):
"""make links ending in > render like buttons"""
buttonlinks = soup.find_all("a", string=re.compile(">$"))
for link in buttonlinks:
diff --git a/tool/filter_markdown_in_divs.py b/tool/filter_markdown_in_divs.py
index 65531b720f..6618828f52 100644
--- a/tool/filter_markdown_in_divs.py
+++ b/tool/filter_markdown_in_divs.py
@@ -9,7 +9,7 @@
## compatibility with those. ##
################################################################################
-def filter_markdown(md):
+def filter_markdown(md, target=None, page=None):
"""Python markdown requires markdown="1" on HTML block elements
that contain markdown. AND there's a bug where if you use
markdown.extensions.extra, it replaces code fences in HTML
diff --git a/tool/filter_multicode_tabs.py b/tool/filter_multicode_tabs.py
index be1e2f679b..0b5a2dae2e 100644
--- a/tool/filter_multicode_tabs.py
+++ b/tool/filter_multicode_tabs.py
@@ -10,7 +10,7 @@
################################################################################
import re
-def filter_html(html):
+def filter_html(html, target=None, page=None):
"""Uncomment multicode tab divs"""
MC_START_REGEX = re.compile("")
MC_END_REGEX = re.compile("")
diff --git a/tool/filter_remove_doctoc.py b/tool/filter_remove_doctoc.py
index 754f62d273..64acf75f9b 100644
--- a/tool/filter_remove_doctoc.py
+++ b/tool/filter_remove_doctoc.py
@@ -8,7 +8,7 @@
################################################################################
-def filter_markdown(md):
+def filter_markdown(md, target=None, page=None):
"""Strip out doctoc Table of Contents for RippleAPI"""
DOCTOC_START = ""
DOCTOC_END = ""
diff --git a/tool/filter_standardize_header_ids.py b/tool/filter_standardize_header_ids.py
index d1be8fdaff..2748065374 100644
--- a/tool/filter_standardize_header_ids.py
+++ b/tool/filter_standardize_header_ids.py
@@ -9,7 +9,7 @@
################################################################################
import re
-def filter_soup(soup):
+def filter_soup(soup, target=None, page=None):
"""replace underscores with dashes in h1,h2,etc. for backwards compatibility"""
headers = soup.find_all(name=re.compile("h[0-9]"), id=True)
for h in headers: