Skip to content

Commit

Permalink
Improve docs, bump package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmkng committed Aug 15, 2019
1 parent 1ffdb77 commit ad847c7
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.15.5 / 2019-08-15
====================
- This release just updates some dependencies (not Puppeteer).

0.15.4 / 2019-08-02
====================
- **DEPRECATED**: `dataset.delete()`, `keyValueStore.delete()` and `requestQueue.delete()` methods have been
Expand Down
3 changes: 3 additions & 0 deletions docs/api/RequestQueue.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ Adds a request to the queue.
If a request with the same `uniqueKey` property is already present in the queue, it will not be updated. You can find out whether this happened from
the resulting [`QueueOperationInfo`](../typedefs/queueoperationinfo) object.

To add multiple requests to the queue by extracting links from a webpage, see the [`Apify.utils.enqueueLinks()`](utils#utils.enqueueLinks) helper
function.

<table>
<thead>
<tr>
Expand Down
10 changes: 6 additions & 4 deletions docs/api/puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ objects.
a combination of <code>url</code>, <code>method</code> and <code>payload</code> which enables crawling of websites that navigate using form submits
(POST requests).</p>
<p> <strong>Example:</strong></p>
<pre><code class="language-javascript"> function transformRequestFunction(request) {
request.userData.foo = &#39;bar&#39;;
request.useExtendedUniqueKey = true;
return request;
<pre><code class="language-javascript"> {
transformRequestFunction: (request) =&gt; {
request.userData.foo = &#39;bar&#39;;
request.useExtendedUniqueKey = true;
return request;
}
}</code></pre>
</td></tr><tr>
<td><code>[options.waitForPageIdleSecs]</code></td><td><code>number</code></td><td><code>1</code></td>
Expand Down
11 changes: 10 additions & 1 deletion docs/api/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,21 @@ objects.
<td><code>[options.transformRequestFunction]</code></td><td><code>function</code></td><td></td>
</tr>
<tr>
<td colspan="3"><p>Just before a new <a href="request"><code>Request</code></a> is constructed and enqueued to the <a href="requestqueue"><code>RequestQueue</code></a>, this function can be used
<td colspan="3"><p><strong>Signature:</strong> (<a href="request"><code>Request</code></a>): <a href="request"><code>Request</code></a></p>
<p> Just before a new <a href="request"><code>Request</code></a> is constructed and enqueued to the <a href="requestqueue"><code>RequestQueue</code></a>, this function can be used
to remove it or modify its contents such as <code>userData</code>, <code>payload</code> or, most importantly <code>uniqueKey</code>. This is useful
when you need to enqueue multiple <code>Requests</code> to the queue that share the same URL, but differ in methods or payloads,
or to dynamically update or create <code>userData</code>.</p>
<p> For example: by adding <code>keepUrlFragment: true</code> to the <code>request</code> object, URL fragments will not be removed
when <code>uniqueKey</code> is computed.</p>
<p> <strong>Example:</strong></p>
<pre><code class="language-javascript"> {
transformRequestFunction: (request) =&gt; {
request.userData.foo = &#39;bar&#39;;
request.keepUrlFragment = true;
return request;
}
}</code></pre>
</td></tr></tbody>
</table>
<a name="utils.requestAsBrowser"></a>
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
"lint:fix": "./node_modules/.bin/eslint ./src ./test --ext .js,.jsx --fix"
},
"dependencies": {
"@apify/http-request": "^1.0.5",
"@apify/http-request": "^1.0.6",
"@apify/ps-tree": "^1.1.3",
"apify-client": "^0.5.24",
"apify-shared": "^0.1.55",
"cheerio": "^1.0.0-rc.2",
"apify-client": "^0.5.25",
"apify-shared": "^0.1.56",
"cheerio": "^1.0.0-rc.3",
"content-type": "^1.0.4",
"express": "^4.17.1",
"fs-extra": "^8.1.0",
Expand Down
10 changes: 6 additions & 4 deletions src/enqueue_links/click_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ const STARTING_Z_INDEX = 2147400000;
*
* **Example:**
* ```javascript
* function transformRequestFunction(request) {
* request.userData.foo = 'bar';
* request.useExtendedUniqueKey = true;
* return request;
* {
* transformRequestFunction: (request) => {
* request.userData.foo = 'bar';
* request.useExtendedUniqueKey = true;
* return request;
* }
* }
* ```
* @param {number} [options.waitForPageIdleSecs=1]
Expand Down
13 changes: 13 additions & 0 deletions src/enqueue_links/enqueue_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,26 @@ import { constructPseudoUrlInstances, createRequests, addRequestsToQueueInBatche
* If `pseudoUrls` is an empty array, `null` or `undefined`, then the function
* enqueues all links found on the page.
* @param {Function} [options.transformRequestFunction]
* **Signature:** ({@link Request}): {@link Request}
*
* Just before a new {@link Request} is constructed and enqueued to the {@link RequestQueue}, this function can be used
* to remove it or modify its contents such as `userData`, `payload` or, most importantly `uniqueKey`. This is useful
* when you need to enqueue multiple `Requests` to the queue that share the same URL, but differ in methods or payloads,
* or to dynamically update or create `userData`.
*
* For example: by adding `keepUrlFragment: true` to the `request` object, URL fragments will not be removed
* when `uniqueKey` is computed.
*
* **Example:**
* ```javascript
* {
* transformRequestFunction: (request) => {
* request.userData.foo = 'bar';
* request.keepUrlFragment = true;
* return request;
* }
* }
* ```
* @return {Promise<QueueOperationInfo[]>}
* Promise that resolves to an array of {@link QueueOperationInfo} objects.
* @memberOf utils
Expand Down
3 changes: 3 additions & 0 deletions src/request_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export class RequestQueue {
* it will not be updated. You can find out whether this happened from the resulting
* {@link QueueOperationInfo} object.
*
* To add multiple requests to the queue by extracting links from a webpage,
* see the [`Apify.utils.enqueueLinks()`](utils#utils.enqueueLinks) helper function.
*
* @param {Request|Object} request {@link Request} object or vanilla object with request data.
* Note that the function sets the `uniqueKey` and `id` fields to the passed object.
* @param {Object} [options]
Expand Down

0 comments on commit ad847c7

Please sign in to comment.