Code samples: READMEs and smarter parsing

This commit is contained in:
mDuo13
2021-10-27 17:37:05 -07:00
parent acb0698940
commit 7c3ff821f0
14 changed files with 69 additions and 9 deletions

View File

@@ -1,3 +1,5 @@
# Escrow # Escrows
Create, finish, and cancel [Escrows](https://xrpl.org/escrow.html) using conditional or time-based release. Create, finish, and cancel [Escrows](https://xrpl.org/escrow.html) using conditional or time-based release.
Examples from the [Escrow Tutorials](https://xrpl.org/use-escrows.html).

View File

@@ -0,0 +1,5 @@
# Freezes
Freeze and unfreeze issued tokens, check freeze status, or give up the ability to freeze tokens.
Examples from the [Freeze tutorials](https://xrpl.org/use-tokens.html).

View File

@@ -0,0 +1,9 @@
# Get Started
Introductory code samples showing how to connect to the XRP Ledger and query it for data.
For more context, see the Get Started tutorial for your preferred language:
- [Python](https://xrpl.org/get-started-using-python.html)
- [Java](https://xrpl.org/get-started-using-java.html)
- [JavaScript](https://xrpl.org/get-started-using-javascript.html)

View File

@@ -0,0 +1,5 @@
# Issue a Fungible Token
Configure issuer settings and issue fungible tokens to a hot wallet.
For an interactive tutorial demonstrating the function of these code samples, see [Issue a Fungible Token](https://xrpl.org/issue-a-fungible-token.html).

View File

@@ -0,0 +1,5 @@
# Cryptographic Key Derivation
Derive secp256k1 or Ed25519 key pairs from seeds in any of the XRP Ledger's encodings and formats.
For background and diagrams, see [Key Derivation](https://xrpl.org/cryptographic-keys.html#key-derivation).

View File

@@ -0,0 +1,3 @@
# Monitor Incoming Payments with WebSocket
Use the WebSocket protocol to watch for incoming payments to an XRP Ledger address, _without_ using a client library.

View File

@@ -0,0 +1,5 @@
# Require Destination Tags
Require incoming payments to your account to specify a [Destination Tag](https://xrpl.org/source-and-destination-tags.html) so you know whom to credit.
Examples from the [Require Destination Tags tutorial](https://xrpl.org/require-destination-tags.html).

View File

@@ -0,0 +1,5 @@
# Secure Signing
Sign transactions from the security of your own machine.
For more information and more options, see [Set Up Secure Signing](https://xrpl.org/set-up-secure-signing.html).

View File

@@ -0,0 +1,5 @@
# Send XRP
Send a direct XRP payment to another account in the XRP Ledger.
Examples from the interactive [Send XRP tutorial](https://xrpl.org/send-xrp.html).

View File

@@ -1,8 +1,11 @@
# Submit and Verify # Submit and Verify
Example JavaScript code using ripple-lib to submit a signed transaction blob and wait until it has a final result. Example code to submit a signed transaction blob and wait until it has a final result.
Example usage: - [submit-and-verify.js](js/submit-and-verify.js): ripple-lib 1.x version.
- [submit-and-verify2.js](js/submit-and-verify2.js): xrpl.js 2.x version. Unlike the submitAndWait() method built into xrpl.js, this checks the server's available history and returns a different code when the transaction's status is unknowable with the server's available history versus if the transaction was _definitely_ not confirmed by consensus.
Example usage (ripple-lib 1.x):
```js ```js
// example testnet creds. Don't use for real // example testnet creds. Don't use for real

View File

@@ -0,0 +1,5 @@
# Transaction Serialization
Convert transactions and other XRPL data from JSON to their canonical binary format for signing or cryptographic verification.
For a detailed explanation, see [Serialization](https://xrpl.org/serialization.html).

View File

@@ -0,0 +1,5 @@
# Tickets
Create a Ticket and use it to send a transaction out of the usual Sequence order.
For more context, see the interactive [Use Tickets tutorial](https://xrpl.org/use-tickets.html).

View File

@@ -39,9 +39,8 @@
"go": "assets/img/logos/golang.svg", "go": "assets/img/logos/golang.svg",
"java": "assets/img/logos/java.svg", "java": "assets/img/logos/java.svg",
"js": "assets/img/logos/javascript.svg", "js": "assets/img/logos/javascript.svg",
"json-rpc": "assets/img/logos/globe.svg",
"py": "assets/img/logos/python.svg", "py": "assets/img/logos/python.svg",
"websocket": "assets/img/logos/globe.svg", "http": "assets/img/logos/globe.svg",
} %} } %}
{% for card in code_samples %} {% for card in code_samples %}

View File

@@ -13,7 +13,7 @@ import re
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from markdown import markdown from markdown import markdown
cs_dir = "content/_code-samples/" #TODO: make a configurable field cs_dir = "content/_code-samples/"
skip_dirs = [ skip_dirs = [
"node_modules", "node_modules",
".git", ".git",
@@ -48,7 +48,7 @@ def all_code_samples():
cs = { cs = {
"path": dirpath, "path": dirpath,
"langs": dirnames, "langs": sorted(list(set(["http" if d in ("websocket", "json-rpc") else d for d in dirnames]))),
} }
if "README.md" in filenames: if "README.md" in filenames:
@@ -62,7 +62,10 @@ def all_code_samples():
else: else:
cs["title"] = to_title_case(os.path.basename(dirpath)) cs["title"] = to_title_case(os.path.basename(dirpath))
p = soup.find("p") # first paragraph defines the blurb p = soup.find("p") # first paragraph defines the blurb
cs["description"] = p.get_text() if p:
cs["description"] = p.get_text()
else:
cs["description"] = ""
else: else:
cs["title"] = to_title_case(os.path.basename(dirpath)) cs["title"] = to_title_case(os.path.basename(dirpath))
@@ -70,7 +73,8 @@ def all_code_samples():
cs["href"] = dirpath cs["href"] = dirpath
cses.append(cs) cses.append(cs)
return cses # Current sort value: alphabetical by title.
return sorted(cses, key=lambda x: x["title"])
export = { export = {
"all_code_samples": all_code_samples, "all_code_samples": all_code_samples,