Skip to content

Commit 2be0653

Browse files
authored
Merge pull request #1027 from honzajavorek/honzajavorek/language-markers
style: use consistent code example language markers
2 parents d698aa9 + c77578b commit 2be0653

27 files changed

+161
-163
lines changed

sources/academy/platform/deploying_your_code/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ For this section, we'll be turning this example project into an actor:
4747
<Tabs groupId="main">
4848
<TabItem value="JavaScript" label="JavaScript">
4949

50-
```javascript
50+
```js
5151
// index.js
5252
const addAllNumbers = (...nums) => nums.reduce((total, curr) => total + curr, 0);
5353

@@ -57,7 +57,7 @@ console.log(addAllNumbers(1, 2, 3, 4)); // -> 10
5757
</TabItem>
5858
<TabItem value="Python" label="Python">
5959

60-
```python
60+
```py
6161
# index.py
6262
def add_all_numbers (nums):
6363
total = 0

sources/academy/platform/deploying_your_code/inputs_outputs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Cool! When we run `node index.js`, we see **20**.
9090

9191
Alternatively, when writing in a language other than JavaScript, we can create our own `get_input()` function which utilizes the Apify API when the actor is running on the platform. For this example, we are using the [Apify Client](../getting_started/apify_client.md) for Python to access the API.
9292

93-
```Python
93+
```py
9494
# index.py
9595
from apify_client import ApifyClient
9696
from os import environ
@@ -164,7 +164,7 @@ Just as with the custom `get_input()` utility function, you can write a custom `
164164

165165
> You can read and write your output anywhere; however, it is standard practice to use a folder named **storage**.
166166
167-
```Python
167+
```py
168168
# index.py
169169
from apify_client import ApifyClient
170170
from os import environ

sources/academy/platform/getting_started/apify_client.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ After installing the package, let's make a file named **client** and import the
4343
<Tabs groupId="main">
4444
<TabItem value="Node.js" label="Node.js">
4545

46-
```javascript
46+
```js
4747
// client.js
4848
import { ApifyClient } from 'apify-client';
4949
```
5050

5151
</TabItem>
5252
<TabItem value="Python" label="Python">
5353

54-
```python
54+
```py
5555
# client.py
5656
from apify_client import ApifyClient
5757

@@ -69,7 +69,7 @@ Before we can use the client though, we must create a new instance of the `Apify
6969
<Tabs groupId="main">
7070
<TabItem value="Node.js" label="Node.js">
7171

72-
```javascript
72+
```js
7373
const client = new ApifyClient({
7474
token: 'YOUR_TOKEN',
7575
});
@@ -78,7 +78,7 @@ const client = new ApifyClient({
7878
</TabItem>
7979
<TabItem value="Python" label="Python">
8080

81-
```python
81+
```py
8282
client = ApifyClient(token='YOUR_TOKEN')
8383

8484
```
@@ -93,7 +93,7 @@ Now that we've got our instance, we can point to an Actor using the [`client.act
9393
<Tabs groupId="main">
9494
<TabItem value="Node.js" label="Node.js">
9595

96-
```javascript
96+
```js
9797
const run = await client.actor('YOUR_USERNAME/adding-actor').call({
9898
num1: 4,
9999
num2: 2,
@@ -103,7 +103,7 @@ const run = await client.actor('YOUR_USERNAME/adding-actor').call({
103103
</TabItem>
104104
<TabItem value="Python" label="Python">
105105

106-
```python
106+
```py
107107
run = client.actor('YOUR_USERNAME/adding-actor').call(run_input={
108108
'num1': 4,
109109
'num2': 2
@@ -127,14 +127,14 @@ The `run` variable we created in the last section points to the **run info** obj
127127
<Tabs groupId="main">
128128
<TabItem value="Node.js" label="Node.js">
129129

130-
```javascript
130+
```js
131131
const dataset = client.dataset(run.defaultDatasetId);
132132
```
133133

134134
</TabItem>
135135
<TabItem value="Python" label="Python">
136136

137-
```python
137+
```py
138138
dataset = client.dataset(run['defaultDatasetId'])
139139

140140
```
@@ -147,7 +147,7 @@ Finally, we can download the items in the dataset by using the **list items** fu
147147
<Tabs groupId="main">
148148
<TabItem value="Node.js" label="Node.js">
149149

150-
```javascript
150+
```js
151151
const { items } = await dataset.listItems();
152152

153153
console.log(items);
@@ -156,7 +156,7 @@ console.log(items);
156156
</TabItem>
157157
<TabItem value="Python" label="Python">
158158

159-
```python
159+
```py
160160
items = dataset.list_items().items
161161

162162
print(items)
@@ -171,7 +171,7 @@ The final code for running the actor and fetching its dataset items looks like t
171171
<Tabs groupId="main">
172172
<TabItem value="Node.js" label="Node.js">
173173

174-
```javascript
174+
```js
175175
// client.js
176176
import { ApifyClient } from 'apify-client';
177177

@@ -194,7 +194,7 @@ console.log(items);
194194
</TabItem>
195195
<TabItem value="Python" label="Python">
196196

197-
```python
197+
```py
198198
# client.py
199199
from apify_client import ApifyClient
200200

@@ -227,14 +227,14 @@ First, we'll create a pointer to our actor, similar to before (except this time,
227227
<Tabs groupId="main">
228228
<TabItem value="Node.js" label="Node.js">
229229

230-
```javascript
230+
```js
231231
const actor = client.actor('YOUR_USERNAME/adding-actor');
232232
```
233233

234234
</TabItem>
235235
<TabItem value="Python" label="Python">
236236

237-
```python
237+
```py
238238
actor = client.actor('YOUR_USERNAME/adding-actor')
239239

240240
```
@@ -247,7 +247,7 @@ Then, we'll just call the `.update()` method on the `actor` variable we created
247247
<Tabs groupId="main">
248248
<TabItem value="Node.js" label="Node.js">
249249

250-
```javascript
250+
```js
251251
await actor.update({
252252
defaultRunOptions: {
253253
build: 'latest',
@@ -260,7 +260,7 @@ await actor.update({
260260
</TabItem>
261261
<TabItem value="Python" label="Python">
262262

263-
```python
263+
```py
264264
actor.update(default_run_build='latest', default_run_memory_mbytes=256, default_run_timeout_secs=20)
265265

266266
```

sources/academy/platform/getting_started/creating_actors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ When you click on the **Use locally** button, you'll be presented with instructi
7070

7171
With the Apify CLI installed, you can simply run the following commands in your terminal:
7272

73-
```bash
73+
```shell
7474
apify create my-actor -t getting_started_node
7575
```
7676

77-
```bash
77+
```shell
7878
cd my-actor
7979
apify run
8080
```

sources/academy/tutorials/api/retry_failed_requests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The additional complication is that the [Request](https://crawlee.dev/api/core/c
1717

1818
A simplified code example can look like this:
1919

20-
```typescript
20+
```ts
2121
// The code is similar for both Crawlee-only but uses a different API
2222
import { Actor } from 'apify';
2323

sources/academy/tutorials/api/run_actor_and_retrieve_data_via_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ You can skip most of this tutorial by following this code example that calls Goo
9494
<Tabs groupId="main">
9595
<TabItem value="Node.js" label="Node.js">
9696

97-
```javascript
97+
```js
9898
import { ApifyClient } from 'apify-client';
9999

100100
const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
@@ -116,7 +116,7 @@ items.forEach((item) => {
116116
</TabItem>
117117
<TabItem value="Python" label="Python">
118118

119-
```python
119+
```py
120120
from apify_client import ApifyClient
121121
client = ApifyClient(token='YOUR_API_TOKEN')
122122

sources/academy/tutorials/apify_scrapers/puppeteer_scraper.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ returns `true`.
387387
> See [`page.waitFor()`](https://pptr.dev/#?product=Puppeteer&show=api-pagewaitforselectororfunctionortimeout-options-args)
388388
in the Puppeteer documentation.
389389

390-
```javascript
390+
```js
391391
// Waits for 2 seconds.
392392
await page.waitFor(2000);
393393
// Waits until an element with id "my-id" appears in the page.
@@ -401,7 +401,7 @@ The selector may never be found and the function might never return `true`, so t
401401
a timeout. The default is `30` seconds. You can override it by providing an options object as the second parameter,
402402
with a `timeout` property.
403403

404-
```javascript
404+
```js
405405
await page.waitFor('.bad-class', { timeout: 5000 });
406406
```
407407

@@ -433,7 +433,7 @@ div.show-more > button
433433

434434
Now that we know what to wait for, we just plug it into the `waitFor()` function.
435435

436-
```javascript
436+
```js
437437
await page.waitFor('div.show-more > button');
438438
```
439439

@@ -443,7 +443,7 @@ We have a unique selector for the button and we know that it's already rendered
443443
of cake. We'll use the Puppeteer `page` again to issue the click. Puppeteer will actually simulate dragging the mouse
444444
and making a left mouse click in the element.
445445

446-
```javascript
446+
```js
447447
await page.click('div.show-more > button');
448448
```
449449

@@ -453,7 +453,7 @@ This will show the next page of actors.
453453

454454
We've shown two function calls, but how do we make this work together in the `pageFunction`?
455455

456-
```javascript
456+
```js
457457
async function pageFunction(context) {
458458

459459
// ...

sources/academy/tutorials/node_js/avoid_eacces_error_in_actor_builds.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ slug: /node-js/avoid-eacces-error-in-actor-builds
77

88
Sometimes when building an actor using a custom Dockerfile, you might receive errors like:
99

10-
```Bash
10+
```shell
1111
Missing write access to ...
1212
```
1313

1414
or
1515

16-
```Bash
16+
```shell
1717
EACCES: permission denied
1818
```
1919

2020
This problem is usually caused by the fact that by default, the `COPY` Dockerfile instruction copies files as the root user (with UID and GID of 0), while your Dockerfile probably uses another user to copy files and run commands.
2121

2222
To fix this problem, make sure the `COPY`  instruction in Dockerfile uses the `--chown` flag. For example, instead of
2323

24-
```Bash
24+
```shell
2525
COPY . ./
2626
```
2727

2828
use
2929

30-
```Bash
30+
```shell
3131
COPY --chown=myuser:myuser . ./
3232
```
3333

sources/academy/tutorials/node_js/multiple-runs-scrape.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The Orchestrator Actor orchestrates the parallel execution of scraper Actor runs
4040
It runs multiple instances of the scraper Actor and passes the request queue and dataset to them.
4141
For the Actor's base structure, we use Apify CLI and create a new Actor with the following command and use the [Empty TypeScript Actor template](https://apify.com/templates/ts-empty).
4242

43-
```bash
43+
```shell
4444
apify create orchestrator-actor
4545
````
4646

@@ -60,7 +60,7 @@ Here’s the breakdown of the necessary input:
6060
</TabItem>
6161
<TabItem value="main.ts" label="main.ts">
6262

63-
```typescript
63+
```ts
6464
import { Actor, log } from 'apify';
6565
6666
interface Input {
@@ -73,7 +73,7 @@ interface Input {
7373
await Actor.init();
7474
7575
const {
76-
parallelRunsCount= 1,
76+
parallelRunsCount = 1,
7777
targetActorId,
7878
targetActorInput = {},
7979
targetActorRunOptions = {},
@@ -90,7 +90,7 @@ if (!targetActorId) throw new Error('Missing the "targetActorId" input!');
9090
9191
The Orchestrator Actor will reuse its default dataset and request queue. The dataset stores the results of the scraping process, and the request queue is used as shared storage for processing requests.
9292
93-
```typescript
93+
```ts
9494
import { Actor } from 'apify';
9595
9696
const requestQueue = await Actor.openRequestQueue();
@@ -103,7 +103,7 @@ const dataset = await Actor.openDataset();
103103
The Orchestrator Actor will maintain the state of the scraping runs to track progress and manage continuity. It will record the state of Actor runs, initializing this tracking with the first run.
104104
This persistent state ensures that, in migration or restart (resurrection) cases, the Actor can resume the same runs without losing progress.
105105
106-
```typescript
106+
```ts
107107
import { Actor, log } from 'apify';
108108
109109
const { apifyClient } = Actor;
@@ -154,7 +154,7 @@ Additionally, by registering for abort events, the Actor can terminate all paral
154154
155155
Once you have the Orchestrator Actor ready, you can push it to Apify using the following command from the root directory of the Actor project:
156156
157-
```bash
157+
```shell
158158
apify push
159159
```
160160
@@ -173,7 +173,7 @@ By running this command, you will be prompted to provide the Actor ID, which you
173173
The Scraper Actor performs website scraping. It operates using the request queue and dataset provided by the Orchestrator Actor.
174174
You will need to integrate your chosen scraper logic into this framework. The only thing you need to do is utilize the request queue and dataset initialized by the Orchestrator Actor.
175175
176-
```typescript
176+
```ts
177177
import { Actor } from 'apify';
178178
179179
interface Input {
@@ -207,7 +207,7 @@ You can check [full code example](https://github.com/apify/apify-docs/tree/maste
207207
208208
You need to push the Scraper Actor to Apify using the following command from the root directory of the Actor project:
209209
210-
```bash
210+
```shell
211211
apify push
212212
```
213213

0 commit comments

Comments
 (0)