Skip to content

Commit

Permalink
docs: fix broken links in undici webpage (nodejs#3807)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo authored and flakey5 committed Nov 14, 2024
1 parent 68ef190 commit ec94d0c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/docs/api/BalancedPool.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Extends: `undici.Dispatcher`

A pool of [Pool](Pool.md) instances connected to multiple upstreams.
A pool of [Pool](/docs/docs/api/Pool.md) instances connected to multiple upstreams.

Requests are not guaranteed to be dispatched in order of invocation.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/MockClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Extends: `undici.Client`

A mock client class that implements the same api as [MockPool](MockPool.md).
A mock client class that implements the same api as [MockPool](/docs/docs/api/MockPool.md).

## `new MockClient(origin, [options])`

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/Pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Extends: `undici.Dispatcher`

A pool of [Client](Client.md) instances connected to the same upstream target.
A pool of [Client](/docs/docs/api/Client.md) instances connected to the same upstream target.

Requests are not guaranteed to be dispatched in order of invocation.

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/api/api-lifecycle.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Client Lifecycle

An Undici [Client](Client.md) can be best described as a state machine. The following list is a summary of the various state transitions the `Client` will go through in its lifecycle. This document also contains detailed breakdowns of each state.
An Undici [Client](/docs/docs/api/Client.md) can be best described as a state machine. The following list is a summary of the various state transitions the `Client` will go through in its lifecycle. This document also contains detailed breakdowns of each state.

> This diagram is not a perfect representation of the undici Client. Since the Client class is not actually implemented as a state-machine, actual execution may deviate slightly from what is described below. Consider this as a general resource for understanding the inner workings of the Undici client rather than some kind of formal specification.
Expand Down Expand Up @@ -28,7 +28,7 @@ stateDiagram-v2
[*] --> idle
idle --> pending : connect
idle --> destroyed : destroy/close
pending --> idle : timeout
pending --> destroyed : destroy
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/best-practices/mocking-request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mocking Request

Undici has its own mocking [utility](../api/MockAgent.md). It allow us to intercept undici HTTP requests and return mocked values instead. It can be useful for testing purposes.
Undici has its own mocking [utility](/docs/docs/api/MockAgent.md). It allow us to intercept undici HTTP requests and return mocked values instead. It can be useful for testing purposes.

Example:

Expand Down Expand Up @@ -73,7 +73,7 @@ const badRequest = await bankTransfer('1234567890', '100')
assert.deepEqual(badRequest, { message: 'bank account not found' })
```

Explore other MockAgent functionality [here](../api/MockAgent.md)
Explore other MockAgent functionality [here](/docs/docs/api/MockAgent.md)

## Debug Mock Value

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/best-practices/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Connecting through a proxy is possible by:

- Using [ProxyAgent](../api/ProxyAgent.md).
- Using [ProxyAgent](/docs/docs/api/ProxyAgent.md).
- Configuring `Client` or `Pool` constructor.

The proxy url should be passed to the `Client` or `Pool` constructor, while the upstream server url
Expand Down
2 changes: 1 addition & 1 deletion docs/docsify/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* [MockErrors](/docs/api/MockErrors.md "Undici API - MockErrors")
* [API Lifecycle](/docs/api/api-lifecycle.md "Undici API - Lifecycle")
* [Diagnostics Channel Support](/docs/api/DiagnosticsChannel.md "Diagnostics Channel Support")
* [Debug](/docs/api/Debug.md.md "Undici API - Debugging Undici")
* [Debug](/docs/api/Debug.md "Undici API - Debugging Undici")
* [WebSocket](/docs/api/WebSocket.md "Undici API - WebSocket")
* [MIME Type Parsing](/docs/api/ContentType.md "Undici API - MIME Type Parsing")
* [CacheStorage](/docs/api/CacheStorage.md "Undici API - CacheStorage")
Expand Down
37 changes: 36 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,42 @@
noCompileLinks: [
'benchmarks/.*'
],
relativePath: true
relativePath: true,
markdown: {
renderer: {
// Mimic markedjs/marked behavior just modify href - https://github.com/markedjs/marked/blob/master/src/Renderer.ts#L178-L191
link(href, title, text) {
const originalHref = href;

if (href.startsWith('./')) {
// Use absolute path (e.g. ./docs/api.md => /docs/api.md) if href starts with ./ (e.g. ./api.md)
href = href.slice(1);
}

// Check for /docs/docs/ in the href and remove duplication it if present
href = href.startsWith('/docs/docs/') ? href.replace('/docs/', '/') : href;

// Check for /docs/ in the href and remove it if present
if (href.startsWith('/docs/')) {
// ignore paths /docs/api/ and /docs/best-practices/ in /docs/docs directory
if (!/^(\/docs\/(?:api|best-practices))(?:\/|$)/.test(href)) {
href = href.includes('/docs/') ? href.replace('/docs/', '/') : href;
}
}

let target = '';
if (originalHref.startsWith('http')) {
// External link - default behavior is to open in a new window
return `<a href="${originalHref}" ${title}" target="_blank" rel="noopener noreferrer">${text}</a>`;
}

title = title ? `title="${title}"` : '';
let out = `<a href="#${href}" ${title}">${text}</a>`;

return out;
},
},
},
}
</script>
<!-- Docsify v4 -->
Expand Down

0 comments on commit ec94d0c

Please sign in to comment.