Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 669e5bf

Browse files
Feature/preprocess (#50)
* add source preprocessing script * refactor quickstarts folder name for extraction * update path to extract to * add shortcode for code sections * update netlify build * add code section usage to readme * refactor quickstart references
1 parent 020ecfd commit 669e5bf

28 files changed

+479
-161
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ public/
44
.idea/*
55
.idea
66
.DS_Store
7+
8+
# Local Netlify folder
9+
.netlify

README.md

+39-7
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,45 @@ All content can be found in the `/content` directory. The structure of the websi
2929

3030
### Links
3131

32-
- [1.1](#types--primitives) **external**: When you insert an external link use the `external-link` shortcode
32+
- [1.1](#types--primitives) **external**: When you insert an external link use the `external-link` shortcode
3333

34-
```markdown
35-
{{< external-link href="https://app.dfuse.io" title="dfuseio" >}}
36-
{{< external-link href="https://app.dfuse.io">}}
37-
```
34+
```markdown
35+
{{< external-link href="https://app.dfuse.io" title="dfuseio" >}}
36+
{{< external-link href="https://app.dfuse.io">}}
37+
```
3838

3939
- [1.2](#types--primitives) **internal references**: Please put all _internal references_ as _full paths_, for greppability and refactoring.
4040

41+
### Example code
42+
43+
Use the following begin and end tags to indicate code sections that need to be referenced:
44+
45+
```javascript
46+
// CODE:BEGIN:quickstarts_javascript_node_eos_section1
47+
function() {
48+
var some = "code"
49+
}
50+
// CODE:END:quickstarts_javascript_node_eos_section1
51+
```
52+
53+
Section names need to follow the path of the file from project root.
54+
For example the example snippet is from the file:
55+
56+
```markdown
57+
├── quickstarts
58+
│ └── javascript
59+
│ └── node
60+
│ └── index.eos.js
61+
├── guides
62+
└── ...
63+
```
64+
65+
When hugo builds the site, the code sections are extracted and stored in the `data` folder in project root.
66+
Example code can then be referenced with the following shortcode:
67+
```go
68+
{{< code-section "quickstarts_javascript_node_eos_section1" >}}
69+
```
70+
4171
## Lexicon guide
4272

4373
- web application
@@ -51,17 +81,19 @@ All content can be found in the `/content` directory. The structure of the websi
5181

5282
Any commit to master automatically triggers a deployment. For this reason, the master branch is locked, requiring all changes to go through an approved pull request.
5383

54-
5584
Reference
5685
ETH -=> Endpoint ALPHA
5786

5887
<new> side menu
5988

60-
6189
alpha (red)
6290
beta (yeallo-orangy)
6391
stage (light gray)
6492
add sub-title to graphql shortcode
6593
fix
6694

6795
refactor pages
96+
97+
```
98+
99+
```

content/guides/eosio/getting-started/javascript-quickstart.md

+64-35
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ the {{< external-link title="dfuse JS client library" href="https://github.com/d
4646

4747
Here are a few of its key features:
4848

49-
* Handles API token issuance
50-
* Refreshes your API token upon expiration
51-
* Automatically reconnects if the connection closes
52-
* Supports `Browsers` and `Node.js` environments
49+
- Handles API token issuance
50+
- Refreshes your API token upon expiration
51+
- Automatically reconnects if the connection closes
52+
- Supports `Browsers` and `Node.js` environments
5353

5454
You can add it to your project using Yarn or NPM.
5555

@@ -104,11 +104,16 @@ the dfuse client using the API key you created in the first step and the network
104104
connect to.
105105

106106
Valid networks can be found at [EOSIO API Endpoints]({{< ref "reference/eosio/endpoints" >}})
107-
108107
{{< tabs "create-client" >}}
109-
{{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="4:9" >}}
110-
{{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="1:6" >}}
111-
{{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="1:11" >}}
108+
{{< tab lang="javascript" title="Node.js" >}}
109+
{{< code-section "quickstarts_javascript_node_eos_section1" >}}
110+
{{< /tab >}}
111+
{{< tab lang="javascript" title="Bundler" >}}
112+
{{< code-section "quickstarts_javascript_bundler_eos_section1" >}}
113+
{{< /tab >}}
114+
{{< tab lang="javascript" title="Browser" >}}
115+
{{< code-section "quickstarts_javascript_browser_eos_section1" >}}
116+
{{< /tab >}}
112117
{{< /tabs >}}
113118

114119
## 4. Stream your first results
@@ -120,14 +125,20 @@ to you, you get to choose and pick only what you are interested in.
120125
{{< alert type="note" >}}
121126
Want to inspect the full set of available fields you can retrieve?
122127

123-
* [GraphQL API Reference]({{< ref "/reference/eosio/graphql" >}})
124-
* {{< external-link href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0=" title="GraphiQL, online query editor with completion and docs">}}
125-
{{< /alert >}}
128+
- [GraphQL API Reference]({{< ref "/reference/eosio/graphql" >}})
129+
- {{< external-link href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0=" title="GraphiQL, online query editor with completion and docs">}}
130+
{{< /alert >}}
126131

127132
{{< tabs "define-query">}}
128-
{{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="11:17" >}}
129-
{{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="8:14" >}}
130-
{{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="13:21" >}}
133+
{{< tab lang="javascript" title="Node.js" >}}
134+
{{< code-section "quickstarts_javascript_node_eos_section2" >}}
135+
{{< /tab >}}
136+
{{< tab lang="javascript" title="Bundler" >}}
137+
{{< code-section "quickstarts_javascript_bundler_eos_section2" >}}
138+
{{< /tab >}}
139+
{{< tab lang="javascript" title="Browser" >}}
140+
{{< code-section "quickstarts_javascript_browser_eos_section2" >}}
141+
{{< /tab >}}
131142
{{< /tabs >}}
132143

133144
Next, you create the GraphQL subscription to stream transfers as they come. You will use the `searchTransactionsForward` operation, with the `"receiver:eosio.token action:transfer -data.quantity:'0.0001 EOS'"` query (See the [Search Query Language reference here]({{< ref "/reference/eosio/search-terms" >}})). This basically means, give me all transactions containing one or more
@@ -137,16 +148,23 @@ You can combine the dfuse client instance we created in step 3 with the GraphQL
137148
a `main` function:
138149

139150
{{< tabs "execute-query">}}
140-
{{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="19:43" >}}
141-
{{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="16:52" >}}
142-
{{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="23:60" >}}
151+
{{< tab lang="javascript" title="Node.js" >}}
152+
{{< code-section "quickstarts_javascript_node_eos_section3" >}}
153+
{{< /tab >}}
154+
{{< tab lang="javascript" title="Bundler" >}}
155+
{{< code-section "quickstarts_javascript_bundler_eos_section3" >}}
156+
{{< /tab >}}
157+
{{< tab lang="javascript" title="Browser" >}}
158+
{{< code-section "quickstarts_javascript_browser_eos_section3" >}}
159+
{{< /tab >}}
143160
{{< /tabs >}}
144161

145162
The function passed as the 2nd parameter to `client.graphql()` will be called every time a new result is returned
146163
by the API. And here is a sample of the prints you will receive as a result of executing the streaming operation
147164
above:
148165

149166
<!-- **Note** We use python for all languages for a nicer output rendering -->
167+
150168
{{< highlight "python" >}}
151169
Transfer eosbetdice11 -> eosbetbank11 [0.0500 EOS]
152170
Transfer newdexpublic -> gq4tcnrwhege [2.8604 EOS]
@@ -161,19 +179,26 @@ Transfer bluebetproxy -> bluebetbulls [0.6000 EOS]
161179
Here the small glue code containing the `main` function, imports and other helper functions to run the example:
162180

163181
{{< tabs "support-code">}}
164-
{{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="45:45" >}}
165-
{{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="54:54" >}}
166-
{{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="61:63" >}}
182+
{{< tab lang="javascript" title="Node.js" >}}
183+
{{< code-section "quickstarts_javascript_node_eos_section4" >}}
184+
{{< /tab >}}
185+
{{< tab lang="javascript" title="Bundler" >}}
186+
{{< code-section "quickstarts_javascript_bundler_eos_section4" >}}
187+
{{< /tab >}}
188+
{{< tab lang="javascript" title="Browser" >}}
189+
{{< code-section "quickstarts_javascript_browser_eos_section4" >}}
190+
{{< /tab >}}
167191
{{< /tabs >}}
168192

169193
{{< tabs "full-working">}}
170194

171195
{{< tab lang="shell" title="Node.js">}}
172196
git clone https://github.com/dfuse-io/docs
173-
cd docs/quickstarts/javascript/node.js
197+
cd docs/quickstarts/javascript/node
174198
npm install
175199

176200
# Replace 'server_abcdef12345678900000000000' with your own API key!
201+
177202
DFUSE_API_KEY=server_abcdef12345678900000000000 node index.eosio.js
178203
{{< /tab >}}
179204

@@ -183,34 +208,38 @@ cd docs/quickstarts/javascript/bundler
183208
npm install
184209

185210
# Replace 'web_abcdef12345678900000000000' with your own API key!
211+
186212
DFUSE_API_KEY=web_abcdef12345678900000000000 npm run build:eosio
187213

188214
# Open `index.eosio.html` directly in your favorite Browser
189-
open index.eosio.html # Mac
190-
xdg-open index.eosio.html # Ubuntu
191-
start index.eosio.thml # Windows
215+
216+
open index.eosio.html # Mac
217+
xdg-open index.eosio.html # Ubuntu
218+
start index.eosio.thml # Windows
192219
{{< /tab >}}
193220

194221
{{< tab lang="shell" title="Browser">}}
195222
git clone https://github.com/dfuse-io/docs
196223
cd docs/quickstarts/javascript/browser
224+
197225
# Manually edit index.eosio.html changing `web_abcdef12345678900000000000` with your own API key
198226

199227
# Open `index.eosio.html` directly in your favorite Browser
200-
open index.eosio.html # Mac
201-
xdg-open index.eosio.html # Ubuntu
202-
start index.eosio.thml # Windows
228+
229+
open index.eosio.html # Mac
230+
xdg-open index.eosio.html # Ubuntu
231+
start index.eosio.thml # Windows
203232
{{< /tab >}}
204233

205234
{{< /tabs >}}
206235

207236
## 6. What's next?
208237

209-
* [GraphQL API Reference]({{< ref "/reference/eosio/graphql" >}})
210-
* [REST API Reference]({{< ref "/reference/eosio/rest" >}})
211-
* [WebSocket API Reference]({{< ref "/reference/eosio/websocket" >}})
212-
* [Check dfuse Core Concepts]({{< ref "/guides/core-concepts" >}})
213-
* [Look at one of our tutorials]({{< ref "/guides/eosio/tutorials" >}})
214-
* {{< external-link title="The `@dfuse/client-js` overview document" href="https://github.com/dfuse-io/client-js/blob/master/README.md#dfuse-javascripttypescript-client-library" >}}
215-
* {{< external-link title="The `@dfuse/client-js` quick API reference" href="https://github.com/dfuse-io/client-js/blob/master/README.md#api" >}} ({{< external-link title="Full API reference" href="https://dfuse-io.github.io/client-js/" >}})
216-
* {{< external-link title="GraphiQL, online query editor with completion and docs" href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0=" >}}
238+
- [GraphQL API Reference]({{< ref "/reference/eosio/graphql" >}})
239+
- [REST API Reference]({{< ref "/reference/eosio/rest" >}})
240+
- [WebSocket API Reference]({{< ref "/reference/eosio/websocket" >}})
241+
- [Check dfuse Core Concepts]({{< ref "/guides/core-concepts" >}})
242+
- [Look at one of our tutorials]({{< ref "/guides/eosio/tutorials" >}})
243+
- {{< external-link title="The `@dfuse/client-js` overview document" href="https://github.com/dfuse-io/client-js/blob/master/README.md#dfuse-javascripttypescript-client-library" >}}
244+
- {{< external-link title="The `@dfuse/client-js` quick API reference" href="https://github.com/dfuse-io/client-js/blob/master/README.md#api" >}} ({{< external-link title="Full API reference" href="https://dfuse-io.github.io/client-js/" >}})
245+
- {{< external-link title="GraphiQL, online query editor with completion and docs" href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0=" >}}

content/guides/eosio/getting-started/other-languages.md

+32-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ The code from the examples on this page can be found {{< external-link href="htt
1818
The JWT is a token with a short expiration period, used to communicate with dfuse services. You will have to implement token caching and manage renewal upon expiration. See [Authentication]({{< relref "/guides/core-concepts/authentication" >}}) for more details.
1919

2020
{{< tabs "generate-jwt">}}
21-
{{< tab-code title="Go" filename="./quickstarts/go/main-eos.go" range="21:39" >}}
22-
{{< tab-code title="Python" filename="./quickstarts/python/main.py" range="17:28" >}}
21+
{{< tab title="Go" lang="go">}}
22+
{{< code-section "quickstarts_go_eos_section2" >}}
23+
{{< /tab >}}
24+
{{< tab title="Python" lang="python">}}
25+
{{< code-section "quickstarts_python_eos_section2" >}}
26+
{{< /tab >}}
2327
{{< tab title="Shell" lang="shell" >}}
2428
curl https://auth.dfuse.io/v1/auth/issue -s \
2529
--data-binary '{"api_key":"server_abcdef12345678900000000000"}'
@@ -79,8 +83,12 @@ requests and streams you need to do, it should be properly cached at the appropr
7983
level for your use case.
8084

8185
{{< tabs "create-client" >}}
82-
{{< tab-code title="Go" filename="./quickstarts/go/main-eos.go" range="41:59" >}}
83-
{{< tab-code title="Python" filename="./quickstarts/python/main.py" range="30:41" >}}
86+
{{< tab title="Go" lang="go">}}
87+
{{< code-section "quickstarts_go_eos_section3" >}}
88+
{{< /tab >}}
89+
{{< tab title="Python" lang="python">}}
90+
{{< code-section "quickstarts_python_eos_section3" >}}
91+
{{< /tab >}}
8492
{{< /tabs >}}
8593

8694
## 5. Stream your first results
@@ -97,17 +105,25 @@ Want to inspect the full set of available fields you can retrieve?
97105
{{< /alert >}}
98106

99107
{{< tabs "define-query">}}
100-
{{< tab-code title="Go" filename="./quickstarts/go/main-eos.go" range="126:144" >}}
101-
{{< tab-code title="Python" filename="./quickstarts/python/main.py" range="73:78" >}}
108+
{{< tab title="Go" lang="go">}}
109+
{{< code-section "quickstarts_go_eos_section4" >}}
110+
{{< /tab >}}
111+
{{< tab title="Python" lang="python">}}
112+
{{< code-section "quickstarts_python_eos_section4" >}}
113+
{{< /tab >}}
102114
{{< /tabs >}}
103115

104116
And we can finally define the code needed to perform your first stream using
105117
dfuse Search. This snippet initiates the connection with dfuse servers and starts
106118
streaming transfers forever.
107119

108120
{{< tabs "run-query">}}
109-
{{< tab-code title="Go" filename="./quickstarts/go/main-eos.go" range="146:180" >}}
110-
{{< tab-code title="Python" filename="./quickstarts/python/main.py" range="80:94" >}}
121+
{{< tab title="Go" lang="go">}}
122+
{{< code-section "quickstarts_go_eos_section5" >}}
123+
{{< /tab >}}
124+
{{< tab title="Python" lang="python">}}
125+
{{< code-section "quickstarts_python_eos_section5" >}}
126+
{{< /tab >}}
111127
{{< /tabs >}}
112128

113129
And here is a sample of the prints you will receive from the standard output after running the example above:
@@ -127,8 +143,14 @@ Transfer bluebetproxy -> bluebetbulls [0.6000 EOS]
127143
Here is the small glue code containing the `main` function, imports and other helper functions to run the example:
128144

129145
{{< tabs "support-code">}}
130-
{{< tab-code title="Go" filename="./quickstarts/go/main-eos.go" range="1:19,182:201" >}}
131-
{{< tab-code title="Python" filename="./quickstarts/python/main.py" range="1:15,96:104" >}}
146+
{{< tab title="Go" lang="go">}}
147+
{{< code-section "quickstarts_go_eos_section1" >}}
148+
{{< code-section "quickstarts_go_eos_section6" >}}
149+
{{< /tab >}}
150+
{{< tab title="Python" lang="python">}}
151+
{{< code-section "quickstarts_python_eos_section1" >}}
152+
{{< code-section "quickstarts_python_eos_section6" >}}
153+
{{< /tab >}}
132154
{{< /tabs >}}
133155

134156
If you prefer, you can directly clone our ready-made repository with all the quick start

0 commit comments

Comments
 (0)