mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 04:05:49 +00:00
rippleapi - update version and add a filter to mark the doc with currently-built version
This commit is contained in:
@@ -124,6 +124,7 @@
|
|||||||
</aside>
|
</aside>
|
||||||
<main class="main" role="main">
|
<main class="main" role="main">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<p style="margin-top: 1em; font-style: italic">Updated for <a href="https://github.com/ripple/ripple-lib/releases/0.16.10" title="view on GitHub">version 0.16.10</a></p>
|
||||||
<h1 id="introduction">Introduction</h1>
|
<h1 id="introduction">Introduction</h1>
|
||||||
<p>RippleAPI is the official client library to the Ripple Consensus Ledger. Currently, RippleAPI is only available in JavaScript.
|
<p>RippleAPI is the official client library to the Ripple Consensus Ledger. Currently, RippleAPI is only available in JavaScript.
|
||||||
Using RippleAPI, you can:</p>
|
Using RippleAPI, you can:</p>
|
||||||
@@ -145,6 +146,14 @@ const api = new RippleAPI({
|
|||||||
api.on('error', (errorCode, errorMessage) => {
|
api.on('error', (errorCode, errorMessage) => {
|
||||||
console.log(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(() => {
|
api.connect().then(() => {
|
||||||
/* insert code here */
|
/* insert code here */
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@@ -1351,7 +1360,7 @@ const api = new RippleAPI();
|
|||||||
<tr>
|
<tr>
|
||||||
<td>type</td>
|
<td>type</td>
|
||||||
<td><a href="#transaction-types">transactionType</a></td>
|
<td><a href="#transaction-types">transactionType</a></td>
|
||||||
<td>The type of the tranasction.</td>
|
<td>The type of the transaction.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>specification</td>
|
<td>specification</td>
|
||||||
@@ -4254,7 +4263,7 @@ const trustline = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
return api.preparePayment(address, trustline).then(prepared =>
|
return api.prepareTrustline(address, trustline).then(prepared =>
|
||||||
{/* ... */});
|
{/* ... */});
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<pre><code class="json">{
|
<pre><code class="json">{
|
||||||
@@ -4991,7 +5000,7 @@ return api.combine(signedTransactions);
|
|||||||
<tr>
|
<tr>
|
||||||
<td>resultCode</td>
|
<td>resultCode</td>
|
||||||
<td>string</td>
|
<td>string</td>
|
||||||
<td>The result code returned by rippled. <a href="http://pages.lightthenight.org/gba/SanFran15/ripple">List of tranasction responses</a></td>
|
<td>The result code returned by rippled. <a href="https://ripple.com/build/transactions/#full-transaction-response-list">List of transaction responses</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>resultMessage</td>
|
<td>resultMessage</td>
|
||||||
@@ -5277,6 +5286,26 @@ return api.computeLedgerHash(ledger);
|
|||||||
</code></pre>
|
</code></pre>
|
||||||
<pre><code>tooBusy: The server is too busy to help you now.
|
<pre><code>tooBusy: The server is too busy to help you now.
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
<h2 id="connected">connected</h2>
|
||||||
|
<p>This event is emitted after connection successfully opened.</p>
|
||||||
|
<h3 id="example-40">Example</h3>
|
||||||
|
<pre><code class="javascript">api.on('connected', () => {
|
||||||
|
console.log('Connection is open now.');
|
||||||
|
});
|
||||||
|
</code></pre>
|
||||||
|
<h2 id="disconnected">disconnected</h2>
|
||||||
|
<p>This event is emitted when connection is closed.</p>
|
||||||
|
<h3 id="return-value-32">Return Value</h3>
|
||||||
|
<p>The only parameter is a number containing the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent">close code</a> send by the server.</p>
|
||||||
|
<h3 id="example-41">Example</h3>
|
||||||
|
<pre><code class="javascript">api.on('disconnected', (code) => {
|
||||||
|
if (code !== 1000) {
|
||||||
|
console.log('Connection is closed due to error.');
|
||||||
|
} else {
|
||||||
|
console.log('Connection is closed normally.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -97,10 +97,11 @@ pages:
|
|||||||
category: References
|
category: References
|
||||||
html: reference-rippleapi.html
|
html: reference-rippleapi.html
|
||||||
# Currently this is the only page that's fetched remotely.
|
# 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/
|
ripple.com: https://ripple.com/build/rippleapi/
|
||||||
filters:
|
filters:
|
||||||
- remove_doctoc
|
- remove_doctoc
|
||||||
|
- add_version
|
||||||
sidebar: true
|
sidebar: true
|
||||||
targets:
|
targets:
|
||||||
- local
|
- local
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ def parse_markdown(page, target=None, pages=None):
|
|||||||
for filter_name in page_filters:
|
for filter_name in page_filters:
|
||||||
if "filter_markdown" in dir(filters[filter_name]):
|
if "filter_markdown" in dir(filters[filter_name]):
|
||||||
logging.info("... applying markdown filter %s" % 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
|
# Actually parse the markdown
|
||||||
logger.info("... parsing markdown...")
|
logger.info("... parsing markdown...")
|
||||||
@@ -166,7 +166,7 @@ def parse_markdown(page, target=None, pages=None):
|
|||||||
for filter_name in page_filters:
|
for filter_name in page_filters:
|
||||||
if "filter_html" in dir(filters[filter_name]):
|
if "filter_html" in dir(filters[filter_name]):
|
||||||
logging.info("... applying HTML filter %s" % 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.
|
# Some filters would rather operate on a soup than a string.
|
||||||
# May as well parse once and re-serialize once.
|
# 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:
|
for filter_name in page_filters:
|
||||||
if "filter_soup" in dir(filters[filter_name]):
|
if "filter_soup" in dir(filters[filter_name]):
|
||||||
logging.info("... applying soup filter %s" % 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
|
# ^ the soup filters apply to the same object, passed by reference
|
||||||
|
|
||||||
# Replace links for any non-default target
|
# Replace links for any non-default target
|
||||||
|
|||||||
31
tool/filter_add_version.py
Normal file
31
tool/filter_add_version.py
Normal file
@@ -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 = ("<p style='margin-top: 1em; font-style: italic'>Updated for <a href='%s' title='view on GitHub'>version %s</a></p>"%(url, vnum))+md
|
||||||
|
except AttributeError:
|
||||||
|
logging.warning("version regex didn't match: %s" % version_match)
|
||||||
|
|
||||||
|
return md
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def filter_soup(soup):
|
def filter_soup(soup, target=None, page=None):
|
||||||
"""make links ending in > render like buttons"""
|
"""make links ending in > render like buttons"""
|
||||||
buttonlinks = soup.find_all("a", string=re.compile(">$"))
|
buttonlinks = soup.find_all("a", string=re.compile(">$"))
|
||||||
for link in buttonlinks:
|
for link in buttonlinks:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
## compatibility with those. ##
|
## compatibility with those. ##
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
def filter_markdown(md):
|
def filter_markdown(md, target=None, page=None):
|
||||||
"""Python markdown requires markdown="1" on HTML block elements
|
"""Python markdown requires markdown="1" on HTML block elements
|
||||||
that contain markdown. AND there's a bug where if you use
|
that contain markdown. AND there's a bug where if you use
|
||||||
markdown.extensions.extra, it replaces code fences in HTML
|
markdown.extensions.extra, it replaces code fences in HTML
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def filter_html(html):
|
def filter_html(html, target=None, page=None):
|
||||||
"""Uncomment multicode tab divs"""
|
"""Uncomment multicode tab divs"""
|
||||||
MC_START_REGEX = re.compile("<!-- *<div class=['\"]multicode['\"][^>]*> *-->")
|
MC_START_REGEX = re.compile("<!-- *<div class=['\"]multicode['\"][^>]*> *-->")
|
||||||
MC_END_REGEX = re.compile("<!-- *</div> *-->")
|
MC_END_REGEX = re.compile("<!-- *</div> *-->")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
def filter_markdown(md):
|
def filter_markdown(md, target=None, page=None):
|
||||||
"""Strip out doctoc Table of Contents for RippleAPI"""
|
"""Strip out doctoc Table of Contents for RippleAPI"""
|
||||||
DOCTOC_START = "<!-- START doctoc generated TOC please keep comment here to allow auto update -->"
|
DOCTOC_START = "<!-- START doctoc generated TOC please keep comment here to allow auto update -->"
|
||||||
DOCTOC_END = "<!-- END doctoc generated TOC please keep comment here to allow auto update -->"
|
DOCTOC_END = "<!-- END doctoc generated TOC please keep comment here to allow auto update -->"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
import re
|
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"""
|
"""replace underscores with dashes in h1,h2,etc. for backwards compatibility"""
|
||||||
headers = soup.find_all(name=re.compile("h[0-9]"), id=True)
|
headers = soup.find_all(name=re.compile("h[0-9]"), id=True)
|
||||||
for h in headers:
|
for h in headers:
|
||||||
|
|||||||
Reference in New Issue
Block a user