diff --git a/api_links_test.ts b/api_links_test.ts new file mode 100644 index 000000000..b82d1b2b3 --- /dev/null +++ b/api_links_test.ts @@ -0,0 +1,73 @@ +import { walk } from "@std/fs"; +import { assert } from "@std/assert"; + +const DIRS_TO_CHECK = ["./runtime"]; + +/** + * Find unlinked `Deno.*` API references in markdown prose. + * + * Matches: `Deno.serve` `Deno.readFile()` `Deno.FsFile` + * Ignores: [`Deno.serve`](/api/deno/~/Deno.serve) (already linked) + * Ignores: references inside fenced code blocks + */ +function findUnlinkedDenoApis( + content: string, +): { line: number; api: string }[] { + const lines = content.split("\n"); + const results: { line: number; api: string }[] = []; + let inCodeBlock = false; + + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + + if (/^```/.test(line)) { + inCodeBlock = !inCodeBlock; + continue; + } + if (inCodeBlock) continue; + + // Match `Deno.something` or `Deno.something()` NOT preceded by [ + const regex = /(? { + const allUnlinked: { file: string; line: number; api: string }[] = []; + + for (const dir of DIRS_TO_CHECK) { + for await ( + const entry of walk(dir, { + exts: [".md", ".mdx"], + skip: [/migration_guide\.md$/], + }) + ) { + const content = await Deno.readTextFile(entry.path); + for (const { line, api } of findUnlinkedDenoApis(content)) { + allUnlinked.push({ file: entry.path, line, api }); + } + } + } + + if (allUnlinked.length > 0) { + const report = allUnlinked.map( + ({ file, line, api }) => + `${file}:${line} — \`${api}\` → [\`${api}\`](/api/deno/~/${api})`, + ); + console.log( + `\nFound ${allUnlinked.length} unlinked Deno API references:\n`, + ); + console.log(report.join("\n")); + console.log(); + } + + assert( + allUnlinked.length === 0, + `${allUnlinked.length} unlinked Deno API references found (see above)`, + ); +}); diff --git a/runtime/fundamentals/debugging.md b/runtime/fundamentals/debugging.md index 7019c3336..3d889e0cd 100644 --- a/runtime/fundamentals/debugging.md +++ b/runtime/fundamentals/debugging.md @@ -67,8 +67,7 @@ deno run --inspect-brk your_script.ts ## Example with Chrome DevTools Let's try debugging a program using Chrome Devtools. For this, we'll use -[@std/http/file-server](https://jsr.io/@std/http#file-server), a static file -server. +[`@std/http/file-server`](/runtime/reference/std/http/), a static file server. Use the `--inspect-brk` flag to break execution on the first line: diff --git a/runtime/fundamentals/ffi.md b/runtime/fundamentals/ffi.md index f74a8c366..1487c8424 100644 --- a/runtime/fundamentals/ffi.md +++ b/runtime/fundamentals/ffi.md @@ -20,8 +20,9 @@ allows you to: - Access operating system APIs and hardware features not directly available in JavaScript -Deno's FFI implementation is based on the `Deno.dlopen` API, which loads dynamic -libraries and creates JavaScript bindings to the functions they export. +Deno's FFI implementation is based on the +[`Deno.dlopen`](/api/deno/~/Deno.dlopen) API, which loads dynamic libraries and +creates JavaScript bindings to the functions they export. ## Security considerations @@ -53,7 +54,7 @@ Always ensure you trust the native libraries you're loading through FFI. The basic pattern for using FFI in Deno involves: 1. Defining the interface for the native functions you want to call -2. Loading the dynamic library using `Deno.dlopen()` +2. Loading the dynamic library using [`Deno.dlopen()`](/api/deno/~/Deno.dlopen) 3. Calling the loaded functions Here's a simple example loading a C library: @@ -300,8 +301,8 @@ Before using FFI, consider these alternatives: - [WebAssembly](/runtime/reference/wasm/), for portable native code that runs within Deno's sandbox. -- Use `Deno.command` to execute external binaries and subprocesses with - controlled permissions. +- Use [`Deno.command`](/api/deno/~/Deno.command) to execute external binaries + and subprocesses with controlled permissions. - Check whether [Deno's native APIs](/api/deno) already provide the functionality you need. diff --git a/runtime/fundamentals/http_server.md b/runtime/fundamentals/http_server.md index ea0de25dc..1ed79b242 100644 --- a/runtime/fundamentals/http_server.md +++ b/runtime/fundamentals/http_server.md @@ -25,9 +25,9 @@ HTTP/1.1 and HTTP/2. ### A "Hello World" server -The `Deno.serve` function takes a handler function that will be called for each -incoming request, and is expected to return a response (or a promise resolving -to a response). +The [`Deno.serve`](/api/deno/~/Deno.serve) function takes a handler function +that will be called for each incoming request, and is expected to return a +response (or a promise resolving to a response). Here is an example of a server that returns a "Hello, World!" response for each request: @@ -47,13 +47,14 @@ To run this server, you can use the `deno run` command: deno run --allow-net server.ts ``` -There are many more examples of using `Deno.serve` in the -[Examples collection](/examples/#network). +There are many more examples of using [`Deno.serve`](/api/deno/~/Deno.serve) in +the [Examples collection](/examples/#network). ### Listening on a specific port -By default `Deno.serve` will listen on port `8000`, but this can be changed by -passing in a port number in options bag as the first or second argument: +By default [`Deno.serve`](/api/deno/~/Deno.serve) will listen on port `8000`, +but this can be changed by passing in a port number in options bag as the first +or second argument: ```js title="server.ts" // To listen on port 4242. @@ -159,8 +160,10 @@ memory. Be aware that the response body stream is "cancelled" when the client hangs up the connection. Make sure to handle this case. This can surface itself as an -error in a `write()` call on a `WritableStream` object that is attached to the -response body `ReadableStream` object (for example through a `TransformStream`). +error in a `write()` call on a [`WritableStream`](/api/web/~/WritableStream) +object that is attached to the response body +[`ReadableStream`](/api/web/~/ReadableStream) object (for example through a +[`TransformStream`](/api/web/~/TransformStream)). ### HTTPS support @@ -240,10 +243,11 @@ be compressed automatically: Deno can upgrade incoming HTTP requests to a WebSocket. This allows you to handle WebSocket endpoints on your HTTP servers. -To upgrade an incoming `Request` to a WebSocket you use the -`Deno.upgradeWebSocket` function. This returns an object consisting of a -`Response` and a web standard `WebSocket` object. The returned response should -be used to respond to the incoming request. +To upgrade an incoming [`Request`](/api/web/~/Request) to a WebSocket you use +the [`Deno.upgradeWebSocket`](/api/deno/~/Deno.upgradeWebSocket) function. This +returns an object consisting of a [`Response`](/api/web/~/Response) and a web +standard [`WebSocket`](/api/web/~/WebSocket) object. The returned response +should be used to respond to the incoming request. Because the WebSocket protocol is symmetrical, the `WebSocket` object is identical to the one that can be used for client side communication. diff --git a/runtime/fundamentals/linting_and_formatting.md b/runtime/fundamentals/linting_and_formatting.md index afa262dd2..3761e72eb 100644 --- a/runtime/fundamentals/linting_and_formatting.md +++ b/runtime/fundamentals/linting_and_formatting.md @@ -288,8 +288,8 @@ specify custom settings to tailor the formatting process to your needs. To use the VSCode ESLint extension in your Deno projects, your project will need a `node_modules` directory in your project that VSCode extensions can pick up. -In your `deno.json` ensure a `node_modules` folder is created, so the editor can -resolve packages: +In your [`deno.json`](/runtime/fundamentals/configuration/) ensure a +`node_modules` folder is created, so the editor can resolve packages: ```jsonc { diff --git a/runtime/fundamentals/modules.md b/runtime/fundamentals/modules.md index 46e081875..2aa0689d5 100644 --- a/runtime/fundamentals/modules.md +++ b/runtime/fundamentals/modules.md @@ -81,7 +81,7 @@ Starting with Deno 2.4 it's possible to import `text` and `bytes` modules too. Support for importing `text` and `bytes` modules is experimental and requires `--unstable-raw-imports` CLI flag or `unstable.raw-import` option in -`deno.json`. +[`deno.json`](/runtime/fundamentals/configuration/). ::: diff --git a/runtime/fundamentals/open_telemetry.md b/runtime/fundamentals/open_telemetry.md index 03506bce1..d39d0be42 100644 --- a/runtime/fundamentals/open_telemetry.md +++ b/runtime/fundamentals/open_telemetry.md @@ -104,14 +104,14 @@ of the `deno` instrumentation scope. (e.g. `deno:2.1.4`). Deno automatically creates spans for various operations, such as: -- Incoming HTTP requests served with `Deno.serve`. -- Outgoing HTTP requests made with `fetch`. +- Incoming HTTP requests served with [`Deno.serve`](/api/deno/~/Deno.serve). +- Outgoing HTTP requests made with [`fetch`](/api/web/~/fetch). -#### `Deno.serve` +#### [`Deno.serve`](/api/deno/~/Deno.serve) -When you use `Deno.serve` to create an HTTP server, a span is created for each -incoming request. The span automatically ends when response headers are sent -(not when the response body is done sending). +When you use [`Deno.serve`](/api/deno/~/Deno.serve) to create an HTTP server, a +span is created for each incoming request. The span automatically ends when +response headers are sent (not when the response body is done sending). The name of the created span is `${method}`. The span kind is `server`. @@ -158,10 +158,11 @@ Deno.serve(async (req) => { }); ``` -#### `fetch` +#### [`fetch`](/api/web/~/fetch) -When you use `fetch` to make an HTTP request, a span is created for the request. -The span automatically ends when the response headers are received. +When you use [`fetch`](/api/web/~/fetch) to make an HTTP request, a span is +created for the request. The span automatically ends when the response headers +are received. The name of the created span is `${method}`. The span kind is `client`. @@ -181,15 +182,16 @@ After the response is received, the following attributes are added: The following metrics are automatically collected and exported: -#### `Deno.serve` / `Deno.serveHttp` +#### [`Deno.serve`](/api/deno/~/Deno.serve) / [`Deno.serveHttp`](/api/deno/~/Deno.serveHttp) ##### `http.server.request.duration` -A histogram of the duration of incoming HTTP requests served with `Deno.serve` -or `Deno.serveHttp`. The time that is measured is from when the request is -received to when the response headers are sent. This does not include the time -to send the response body. The unit of this metric is seconds. The histogram -buckets are +A histogram of the duration of incoming HTTP requests served with +[`Deno.serve`](/api/deno/~/Deno.serve) or +[`Deno.serveHttp`](/api/deno/~/Deno.serveHttp). The time that is measured is +from when the request is received to when the response headers are sent. This +does not include the time to send the response body. The unit of this metric is +seconds. The histogram buckets are `[0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0]`. This metric is recorded with the following attributes: @@ -207,10 +209,12 @@ This metric is recorded with the following attributes: ##### `http.server.active_requests` -A gauge of the number of active requests being handled by `Deno.serve` or -`Deno.serveHttp` at any given time. This is the number of requests that have -been received but not yet responded to (where the response headers have not yet -been sent). This metric is recorded with the following attributes: +A gauge of the number of active requests being handled by +[`Deno.serve`](/api/deno/~/Deno.serve) or +[`Deno.serveHttp`](/api/deno/~/Deno.serveHttp) at any given time. This is the +number of requests that have been received but not yet responded to (where the +response headers have not yet been sent). This metric is recorded with the +following attributes: - `http.request.method`: The HTTP method of the request. - `url.scheme`: The scheme of the request URL. @@ -220,8 +224,9 @@ been sent). This metric is recorded with the following attributes: ##### `http.server.request.body.size` A histogram of the size of the request body of incoming HTTP requests served -with `Deno.serve` or `Deno.serveHttp`. The unit of this metric is bytes. The -histogram buckets are +with [`Deno.serve`](/api/deno/~/Deno.serve) or +[`Deno.serveHttp`](/api/deno/~/Deno.serveHttp). The unit of this metric is +bytes. The histogram buckets are `[0, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]`. This metric is recorded with the following attributes: @@ -240,8 +245,9 @@ This metric is recorded with the following attributes: ##### `http.server.response.body.size` A histogram of the size of the response body of incoming HTTP requests served -with `Deno.serve` or `Deno.serveHttp`. The unit of this metric is bytes. The -histogram buckets are +with [`Deno.serve`](/api/deno/~/Deno.serve) or +[`Deno.serveHttp`](/api/deno/~/Deno.serveHttp). The unit of this metric is +bytes. The histogram buckets are `[0, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]`. This metric is recorded with the following attributes: @@ -721,9 +727,9 @@ By default, Deno supports the following propagators: :::note -These propagators automatically work with Deno's `fetch` API and `Deno.serve`, -enabling end-to-end tracing across HTTP requests without manual context -management. +These propagators automatically work with Deno's [`fetch`](/api/web/~/fetch) API +and [`Deno.serve`](/api/deno/~/Deno.serve), enabling end-to-end tracing across +HTTP requests without manual context management. ::: @@ -778,9 +784,10 @@ limitations to be aware of: - HTTP methods are that are not known are not normalized to `_OTHER` in the `http.request.method` span attribute as per the OpenTelemetry semantic conventions. -- The HTTP server span for `Deno.serve` does not have an OpenTelemetry status - set, and if the handler throws (ie `onError` is invoked), the span will not - have an error status set and the error will not be attached to the span via - event. +- The HTTP server span for [`Deno.serve`](/api/deno/~/Deno.serve) does not have + an OpenTelemetry status set, and if the handler throws (ie `onError` is + invoked), the span will not have an error status set and the error will not be + attached to the span via event. - There is no mechanism to add a `http.route` attribute to the HTTP client span - for `fetch`, or to update the span name to include the route. + for [`fetch`](/api/web/~/fetch), or to update the span name to include the + route. diff --git a/runtime/fundamentals/security.md b/runtime/fundamentals/security.md index ad7a5d48e..eaa644e1b 100644 --- a/runtime/fundamentals/security.md +++ b/runtime/fundamentals/security.md @@ -230,14 +230,14 @@ resolves to a sensitive system path, additional permissions are required: - **`/dev/null`, `/dev/zero`, `/dev/random`, `/dev/urandom`**: These safe device files are always accessible without additional permissions. -Creating symlinks with `Deno.symlink()` requires both `--allow-read` and -`--allow-write` with full access (not path-specific), because symlinks can point -to arbitrary locations. +Creating symlinks with [`Deno.symlink()`](/api/deno/~/Deno.symlink) requires +both `--allow-read` and `--allow-write` with full access (not path-specific), +because symlinks can point to arbitrary locations. > **Note**: Symlinks that already exist on the filesystem can be read through > using the permissions for the symlink's location. The full read/write > permission requirement only applies to _creating_ new symlinks with -> `Deno.symlink()`. +> [`Deno.symlink()`](/api/deno/~/Deno.symlink). ### Network access @@ -449,18 +449,21 @@ scripts for npm packages will be executed as a subprocess. Deno provides an [FFI mechanism for executing code written in other languages](/runtime/fundamentals/ffi/), such as Rust, C, or C++, from within a Deno runtime. This is done using the -`Deno.dlopen` API, which can load shared libraries and call functions from them. +[`Deno.dlopen`](/api/deno/~/Deno.dlopen) API, which can load shared libraries +and call functions from them. -By default, executing code can not use the `Deno.dlopen` API, as this would -constitute a violation of the principle that code can not escalate it's -privileges without user consent. +By default, executing code can not use the +[`Deno.dlopen`](/api/deno/~/Deno.dlopen) API, as this would constitute a +violation of the principle that code can not escalate it's privileges without +user consent. -In addition to `Deno.dlopen`, FFI can also be used via Node-API (NAPI) native -addons. These are also not allowed by default. +In addition to [`Deno.dlopen`](/api/deno/~/Deno.dlopen), FFI can also be used +via Node-API (NAPI) native addons. These are also not allowed by default. -Both `Deno.dlopen` and NAPI native addons require explicit permission using the -`--allow-ffi` flag. This flag can be specified with a list of files or -directories to allow access to specific dynamic libraries. +Both [`Deno.dlopen`](/api/deno/~/Deno.dlopen) and NAPI native addons require +explicit permission using the `--allow-ffi` flag. This flag can be specified +with a list of files or directories to allow access to specific dynamic +libraries. _Like subprocesses, dynamic libraries are not run in a sandbox and therefore do not have the same security restrictions as the Deno process they are being diff --git a/runtime/fundamentals/testing.md b/runtime/fundamentals/testing.md index 97e4eb9e4..0117a1716 100644 --- a/runtime/fundamentals/testing.md +++ b/runtime/fundamentals/testing.md @@ -27,8 +27,8 @@ these in this document however. ## Writing Tests -To define a test in Deno, you use the `Deno.test()` function. Here are some -examples: +To define a test in Deno, you use the [`Deno.test()`](/api/deno/~/Deno.test) +function. Here are some examples: ```ts title="my_test.ts" import { assertEquals } from "jsr:@std/assert"; @@ -308,7 +308,7 @@ Deno.test({ ``` If you want to ignore a test without passing any conditions, you can use the -`ignore()` function from the `Deno.test` object: +`ignore()` function from the [`Deno.test`](/api/deno/~/Deno.test) object: ```ts Deno.test.ignore("my test", () => { @@ -386,7 +386,7 @@ deno test --junit-path=./report.xml The [Deno Standard Library](/runtime/reference/std/) provides a set of functions to help you write tests that involve spying, mocking, and stubbing. Check out -the [@std/testing documentation on JSR](https://jsr.io/@std/testing) for more +the [`@std/testing` documentation](/runtime/reference/std/testing/) for more information on each of these utilities or our [tutorial on mocking and spying in tests with deno](/examples/mocking_tutorial/). @@ -402,8 +402,8 @@ tool. ## Behavior-Driven Development -With the [@std/testing/bdd](https://jsr.io/@std/testing/doc/bdd/~) module you -can write your tests in a familiar format for grouping tests and adding +With the [`@std/testing/bdd`](/runtime/reference/std/testing/) module you can +write your tests in a familiar format for grouping tests and adding setup/teardown hooks used by other JavaScript testing frameworks like Jasmine, Jest, and Mocha. @@ -428,8 +428,8 @@ describe("add function", () => { }); ``` -Check out the [documentation on JSR](https://jsr.io/@std/testing/doc/bdd/~) for -more information on these functions and hooks. +Check out the [`@std/testing` documentation](/runtime/reference/std/testing/) +for more information on these functions and hooks. - [BDD testing tutorial](/examples/bdd_tutorial/) @@ -573,9 +573,9 @@ reasonable and expected way. The resource sanitizer ensures that all I/O resources created during a test are closed, to prevent leaks. -I/O resources are things like `Deno.FsFile` handles, network connections, -`fetch` bodies, timers, and other resources that are not automatically garbage -collected. +I/O resources are things like [`Deno.FsFile`](/api/deno/~/Deno.FsFile) handles, +network connections, [`fetch`](/api/web/~/fetch) bodies, timers, and other +resources that are not automatically garbage collected. You should always close resources when you are done with them. For example, to close a file: @@ -594,7 +594,7 @@ const conn = await Deno.connect({ hostname: "example.com", port: 80 }); conn.close(); // <- Always close the connection when you are done with it ``` -To close a `fetch` body: +To close a [`fetch`](/api/web/~/fetch) body: ```ts const response = await fetch("https://example.com"); @@ -652,8 +652,8 @@ Deno.test({ ### Exit sanitizer -The exit sanitizer ensures that tested code doesn’t call `Deno.exit()`, which -could signal a false test success. +The exit sanitizer ensures that tested code doesn’t call +[`Deno.exit()`](/api/deno/~/Deno.exit), which could signal a false test success. This sanitizer is enabled by default, but can be disabled with `sanitizeExit: false`. @@ -679,10 +679,10 @@ Deno.test({ ## Snapshot testing The [Deno Standard Library](/runtime/reference/std/) includes a -[snapshot module](https://jsr.io/@std/testing/doc/snapshot/~) that allows -developers to write tests by comparing values against reference snapshots. These -snapshots are serialized representations of the original values and are stored -alongside the test files. +[snapshot module](/runtime/reference/std/testing/) that allows developers to +write tests by comparing values against reference snapshots. These snapshots are +serialized representations of the original values and are stored alongside the +test files. Snapshot testing enables catching a wide array of bugs with very little code. It is particularly helpful in situations where it is difficult to precisely express @@ -693,11 +693,12 @@ where the assertions a test makes are expected to change often. ## Tests and Permissions -The `permissions` property in the `Deno.test` configuration allows you to -specifically deny permissions, but does not grant them. Permissions must be -provided when running the test command. When building robust applications, you -often need to handle cases where permissions are denied, (for example you may -want to write tests to check whether fallbacks have been set up correctly). +The `permissions` property in the [`Deno.test`](/api/deno/~/Deno.test) +configuration allows you to specifically deny permissions, but does not grant +them. Permissions must be provided when running the test command. When building +robust applications, you often need to handle cases where permissions are +denied, (for example you may want to write tests to check whether fallbacks have +been set up correctly). Consider a situation where you are reading from a file, you may want to offer a fallback value in the case that the function does not have read permission: diff --git a/runtime/fundamentals/typescript.md b/runtime/fundamentals/typescript.md index fce1bc74e..3bc3c5251 100644 --- a/runtime/fundamentals/typescript.md +++ b/runtime/fundamentals/typescript.md @@ -90,7 +90,8 @@ deno test --no-check Deno runs JavaScript and TypeScript code. During type checking, Deno will only type check TypeScript files by default though. If you want to type check JavaScript files too, you can either add a `// @ts-check` pragma at the top of -the file, or add `compilerOptions.checkJs` to your `deno.json` file. +the file, or add `compilerOptions.checkJs` to your +[`deno.json`](/runtime/fundamentals/configuration/) file. ```ts title="main.js" // @ts-check @@ -222,7 +223,8 @@ file: This will enable type checking for a browser environment, providing type information for global objects like `document`. This will however disable type -information for Deno-specific APIs like `Deno.readFile`. +information for Deno-specific APIs like +[`Deno.readFile`](/api/deno/~/Deno.readFile). To enable type checking for combined **browser and Deno environments**, like using SSR with Deno, you can specify both the `dom` and `deno.ns` (Deno @@ -239,7 +241,7 @@ configuration file: This will enable type checking for both browser and Deno environments, providing type information for global objects like `document` and Deno-specific APIs like -`Deno.readFile`. +[`Deno.readFile`](/api/deno/~/Deno.readFile). To enable type checking for a **web worker environment in Deno**, (ie code that is run with `new Worker`), you can specify the `deno.worker` library file in the diff --git a/runtime/fundamentals/workspaces.md b/runtime/fundamentals/workspaces.md index c74067dfc..d14e4cc11 100644 --- a/runtime/fundamentals/workspaces.md +++ b/runtime/fundamentals/workspaces.md @@ -7,9 +7,9 @@ oldUrl: /runtime/manual/basics/workspaces Deno supports workspaces, also known as "monorepos", which allow you to manage multiple related and interdependent packages simultaneously. -A "workspace" is a collection of folders containing `deno.json` or -`package.json` configuration files. The root `deno.json` file defines the -workspace: +A "workspace" is a collection of folders containing +[`deno.json`](/runtime/fundamentals/configuration/) or `package.json` +configuration files. The root `deno.json` file defines the workspace: ```json title="deno.json" { diff --git a/runtime/reference/bundling.md b/runtime/reference/bundling.md index 16a1c82ed..49b4a22a7 100644 --- a/runtime/reference/bundling.md +++ b/runtime/reference/bundling.md @@ -75,14 +75,14 @@ single output file. ## Runtime API -In addition to the CLI, you can use `Deno.bundle()` to programmatically bundle -your JavaScript or TypeScript files. This allows you to integrate bundling into -your build processes and workflows. +In addition to the CLI, you can use [`Deno.bundle()`](/api/deno/~/Deno.bundle) +to programmatically bundle your JavaScript or TypeScript files. This allows you +to integrate bundling into your build processes and workflows. :::note -This API was added in Deno v2.5. The `Deno.bundle()` API is experimental and -must be used with the `--unstable-bundle` flag. +This API was added in Deno v2.5. The [`Deno.bundle()`](/api/deno/~/Deno.bundle) +API is experimental and must be used with the `--unstable-bundle` flag. ::: @@ -237,8 +237,7 @@ Bundled 9 modules in 99ms ``` At this point, we're ready to serve our page, let's use -[`@std/http/file-server` from JSR](https://jsr.io/@std/http/file-server) to -serve our app: +[`@std/http/file-server`](/runtime/reference/std/http/) to serve our app: ```bash $ deno run -ENR jsr:@std/http/file-server diff --git a/runtime/reference/cli/add.md b/runtime/reference/cli/add.md index f936ee1eb..e5579be6b 100644 --- a/runtime/reference/cli/add.md +++ b/runtime/reference/cli/add.md @@ -40,4 +40,4 @@ deno add --npm express If your project has a `package.json`, npm packages will be added to `dependencies` in `package.json`. Otherwise, all packages are added to the -`imports` field in `deno.json`. +`imports` field in [`deno.json`](/runtime/fundamentals/configuration/). diff --git a/runtime/reference/cli/bench.md b/runtime/reference/cli/bench.md index 053bb6a04..760d3bef0 100644 --- a/runtime/reference/cli/bench.md +++ b/runtime/reference/cli/bench.md @@ -38,10 +38,11 @@ file:///path/to/url_bench.ts ## Writing benchmarks -To define a benchmark you need to register it with a call to the `Deno.bench` -API. There are multiple overloads of this API to allow for the greatest -flexibility and easy switching between the forms (eg. when you need to quickly -focus a single bench for debugging, using the `only: true` option): +To define a benchmark you need to register it with a call to the +[`Deno.bench`](/api/deno/~/Deno.bench) API. There are multiple overloads of this +API to allow for the greatest flexibility and easy switching between the forms +(eg. when you need to quickly focus a single bench for debugging, using the +`only: true` option): ```ts // Compact form: name and function @@ -100,10 +101,12 @@ takes to read a small file, you need to open the file, read it, and then close it. If the file is small enough the time it takes to open and close the file might outweigh the time it takes to read the file itself. -To help with such situations you can `Deno.BenchContext.start` and -`Deno.BenchContext.end` to tell the benchmarking tool about the critical section -you want to measure. Everything outside of the section between these two calls -will be excluded from the measurement. +To help with such situations you can +[`Deno.BenchContext.start`](/api/deno/~/Deno.BenchContext.start) and +[`Deno.BenchContext.end`](/api/deno/~/Deno.BenchContext.end) to tell the +benchmarking tool about the critical section you want to measure. Everything +outside of the section between these two calls will be excluded from the +measurement. ```ts Deno.bench("foo", async (b) => { @@ -128,7 +131,7 @@ The above example requires the `--allow-read` flag to run the benchmark: ## Grouping and baselines When registering a bench case, it can be assigned to a group, using -`Deno.BenchDefinition.group` option: +[`Deno.BenchDefinition.group`](/api/deno/~/Deno.BenchDefinition.group) option: ```ts // url_bench.ts @@ -142,7 +145,8 @@ perform against a "baseline" case. In this example we'll check how performant is `Date.now()` compared to `performance.now()`, to do that we'll mark the first case as a "baseline" using -`Deno.BenchDefinition.baseline` option: +[`Deno.BenchDefinition.baseline`](/api/deno/~/Deno.BenchDefinition.baseline) +option: ```ts // time_bench.ts diff --git a/runtime/reference/cli/clean.md b/runtime/reference/cli/clean.md index 319b71bc9..099796a50 100644 --- a/runtime/reference/cli/clean.md +++ b/runtime/reference/cli/clean.md @@ -6,7 +6,9 @@ openGraphTitle: "deno clean" description: "Remove cached dependencies for a clean start" --- -`deno clean` removes Deno's global module cache directory. +`deno clean` removes Deno's global module cache directory. See +[Modules](/runtime/fundamentals/modules/) for more information about how Deno +caches dependencies. ## Basic usage diff --git a/runtime/reference/cli/create.md b/runtime/reference/cli/create.md index ef9d95981..763405ef0 100644 --- a/runtime/reference/cli/create.md +++ b/runtime/reference/cli/create.md @@ -27,7 +27,8 @@ Package resolution differs between npm and JSR: `deno create npm:vite` resolves to the `create-vite` package on npm and executes its main entry point. - **JSR packages** use the `./create` export. Any JSR package can act as a - template by defining a `./create` entry point in its `deno.json`: + template by defining a `./create` entry point in its + [`deno.json`](/runtime/fundamentals/configuration/): ```json title="deno.json" { diff --git a/runtime/reference/cli/env_variables.md b/runtime/reference/cli/env_variables.md index 1d7a86e1a..a753eedc1 100644 --- a/runtime/reference/cli/env_variables.md +++ b/runtime/reference/cli/env_variables.md @@ -78,7 +78,7 @@ writing to stdout and stderr. See the website [https://no-color.org](https://no-color.org/) for more information on this _de facto_ standard. The value of this flag can be accessed at runtime without permission to read the environment variables by checking the value of -`Deno.noColor`. +[`Deno.noColor`](/api/deno/~/Deno.noColor). ### NO_PROXY diff --git a/runtime/reference/cli/info.md b/runtime/reference/cli/info.md index 208491c6c..011631f4f 100644 --- a/runtime/reference/cli/info.md +++ b/runtime/reference/cli/info.md @@ -10,6 +10,10 @@ openGraphTitle: "deno info" description: "Inspect the dependencies of your project" --- +`deno info` displays information about a module's dependency tree. See +[Modules](/runtime/fundamentals/modules/) for more about how Deno resolves and +caches dependencies. + ## Example ```sh diff --git a/runtime/reference/cli/install.md b/runtime/reference/cli/install.md index a099f74fc..5f7db3b74 100644 --- a/runtime/reference/cli/install.md +++ b/runtime/reference/cli/install.md @@ -20,8 +20,8 @@ on how Deno handles modules, see ### deno install -Use this command to install all dependencies defined in `deno.json` and/or -`package.json`. +Use this command to install all dependencies defined in +[`deno.json`](/runtime/fundamentals/configuration/) and/or `package.json`. The dependencies will be installed in the global cache, but if your project has a `package.json` file, a local `node_modules` directory will be set up as well. diff --git a/runtime/reference/cli/jupyter.md b/runtime/reference/cli/jupyter.md index e9aa06523..1cc51f8ea 100644 --- a/runtime/reference/cli/jupyter.md +++ b/runtime/reference/cli/jupyter.md @@ -50,8 +50,8 @@ Jupyter Notebooks are available right out of the box. ## Rich content output -`Deno.jupyter` namespaces provides helper function for displaying rich content -in your notebooks +[`Deno.jupyter`](/api/deno/~/Deno.jupyter) namespaces provides helper function +for displaying rich content in your notebooks [using MIME types that Jupyter supports](https://docs.jupyter.org/en/latest/reference/mimetype.html). --- @@ -86,7 +86,8 @@ You can also use `Deno.jupyter.$display` instead of typing ::: This is a regular function, so you you can use any library you want to format -the output - eg. use `@std/fmt/colors` to provide a colorful output: +the output - eg. use [`@std/fmt/colors`](/runtime/reference/std/fmt/) to provide +a colorful output: ```ts import * as colors from "jsr:@std/fmt/colors"; @@ -100,8 +101,8 @@ import * as colors from "jsr:@std/fmt/colors"; } ``` -You can also use `Deno.jupyter.display` function to directly display the MIME -bundle: +You can also use [`Deno.jupyter.display`](/api/deno/~/Deno.jupyter.display) +function to directly display the MIME bundle: ```js await Deno.jupyter.display({ @@ -118,11 +119,11 @@ display based on its capabilities. --- -`Deno.jupyter` provides several helper methods for rich output of common media -types. +[`Deno.jupyter`](/api/deno/~/Deno.jupyter) provides several helper methods for +rich output of common media types. -`Deno.jupyter.html` is a tagged template that will render the provided string as -an HTML in the notebook. +[`Deno.jupyter.html`](/api/deno/~/Deno.jupyter.html) is a tagged template that +will render the provided string as an HTML in the notebook. ```js Deno.jupyter.html`

Hello, world!

@@ -132,8 +133,8 @@ Deno.jupyter.html`

Hello, world!

![`Deno.jupyter.html` API example](../images/jupyter-html.png) -`Deno.jupyter.md` is a tagged template that will render provided string as a -Markdown document in the notebook. +[`Deno.jupyter.md`](/api/deno/~/Deno.jupyter.md) is a tagged template that will +render provided string as a Markdown document in the notebook. ```js Deno.jupyter @@ -144,8 +145,8 @@ Deno.jupyter ![`Deno.jupyter.md` API example](../images/jupyter-md.png) -`Deno.jupyter.svg` is a tagged template that will render provided string as an -SVG figure in the notebook. +[`Deno.jupyter.svg`](/api/deno/~/Deno.jupyter.svg) is a tagged template that +will render provided string as an SVG figure in the notebook. ```js Deno.jupyter.svg` @@ -155,8 +156,8 @@ Deno.jupyter.svg` ![`Deno.jupyter.svg` API example](../images/jupyter-svg.png) -`Deno.jupyter.image` is function that will render a JPG or PNG image. You can -pass a filepath, or already read bytes: +[`Deno.jupyter.image`](/api/deno/~/Deno.jupyter.image) is function that will +render a JPG or PNG image. You can pass a filepath, or already read bytes: ```js Deno.jupyter.image("./cat.jpg"); @@ -180,8 +181,9 @@ notebook. ## IO pub channel broadcasting -`Deno.jupyter.broadcast` allows to publish messages to the IO pub channel -allowing to provide live updates as the cell is evaluated. +[`Deno.jupyter.broadcast`](/api/deno/~/Deno.jupyter.broadcast) allows to publish +messages to the IO pub channel allowing to provide live updates as the cell is +evaluated. Consider this example that prints a message before we start a computation and another when the computation is finished: @@ -205,7 +207,7 @@ await Deno.jupyter.broadcast("update_display_data", {
- +
Deno.jupyter.broadcast API example diff --git a/runtime/reference/cli/outdated.md b/runtime/reference/cli/outdated.md index 3dbd13e38..c16766691 100644 --- a/runtime/reference/cli/outdated.md +++ b/runtime/reference/cli/outdated.md @@ -9,9 +9,10 @@ description: "Check for outdated dependencies in your project and safely update ## Checking for outdated dependencies The `outdated` subcommand checks for new versions of NPM and JSR dependencies -listed in `deno.json` or `package.json` files, and displays dependencies that -could be updated. Workspaces are fully supported, including workspaces where -some members use `package.json` and others use `deno.json`. +listed in [`deno.json`](/runtime/fundamentals/configuration/) or `package.json` +files, and displays dependencies that could be updated. Workspaces are fully +supported, including workspaces where some members use `package.json` and others +use `deno.json`. For example, take a project with a `deno.json` file: diff --git a/runtime/reference/cli/publish.md b/runtime/reference/cli/publish.md index 8c1481d6a..dfeb1c262 100644 --- a/runtime/reference/cli/publish.md +++ b/runtime/reference/cli/publish.md @@ -12,7 +12,7 @@ description: "Publish your package or workspace to the JSR registry" ## Package Requirements Your package must have a `name` and `version` and an `exports` field in its -`deno.json` or `jsr.json` file. +[`deno.json`](/runtime/fundamentals/configuration/) or `jsr.json` file. - The `name` field must be unique and follow the `@/` convention. diff --git a/runtime/reference/cli/remove.md b/runtime/reference/cli/remove.md index f029dbde8..1e3a7c1d4 100644 --- a/runtime/reference/cli/remove.md +++ b/runtime/reference/cli/remove.md @@ -25,5 +25,6 @@ deno remove @std/path @std/assert npm:express ## Where dependencies are removed from -`deno remove` will look at both `deno.json` and `package.json` (if present) and -remove the matching dependency from whichever file it is found in. +`deno remove` will look at both +[`deno.json`](/runtime/fundamentals/configuration/) and `package.json` (if +present) and remove the matching dependency from whichever file it is found in. diff --git a/runtime/reference/cli/task.md b/runtime/reference/cli/task.md index 7f418727b..f57b498be 100644 --- a/runtime/reference/cli/task.md +++ b/runtime/reference/cli/task.md @@ -286,7 +286,8 @@ Project bundled ``` Note that the filter matches against the workspace member names as specified in -the `name` field of each member's `deno.json` file. +the `name` field of each member's +[`deno.json`](/runtime/fundamentals/configuration/) file. ## Syntax diff --git a/runtime/reference/cli/uninstall.md b/runtime/reference/cli/uninstall.md index b8c50fbde..5dca0cc23 100644 --- a/runtime/reference/cli/uninstall.md +++ b/runtime/reference/cli/uninstall.md @@ -9,7 +9,8 @@ description: "Remove a dependency from your project or from your global cache" ## `deno uninstall [PACKAGES]` -Remove dependencies specified in `deno.json` or `package.json`: +Remove dependencies specified in +[`deno.json`](/runtime/fundamentals/configuration/) or `package.json`: ```sh deno add npm:express diff --git a/runtime/reference/cli/unstable_flags.md b/runtime/reference/cli/unstable_flags.md index a43dc9425..7c9ac797b 100644 --- a/runtime/reference/cli/unstable_flags.md +++ b/runtime/reference/cli/unstable_flags.md @@ -42,9 +42,9 @@ The possible values in the `unstable` array are the flag names with the ## Configuration via environment variables Some flags can be enabled by setting a value (any value) for an environment -variable of a given name, rather than being passed as a flag or `deno.json` -configuration option. Flags that are settable via environment variables will be -noted below. +variable of a given name, rather than being passed as a flag or +[`deno.json`](/runtime/fundamentals/configuration/) configuration option. Flags +that are settable via environment variables will be noted below. Here's an example of setting the `--unstable-bare-node-builtins` flag via environment variable: diff --git a/runtime/reference/cli/update.md b/runtime/reference/cli/update.md index 37674c0ee..3198f673b 100644 --- a/runtime/reference/cli/update.md +++ b/runtime/reference/cli/update.md @@ -6,6 +6,10 @@ openGraphTitle: "deno update" description: "Update outdated dependencies with an interactive CLI" --- +`deno update` updates dependencies in your +[`deno.json`](/runtime/fundamentals/configuration/) or `package.json`. See +[Modules](/runtime/fundamentals/modules/) for more about managing dependencies. + ## Updating dependencies By default, the `update` subcommand will only update dependencies to diff --git a/runtime/reference/cli/x.md b/runtime/reference/cli/x.md index ee0af9c5d..edd6389c7 100644 --- a/runtime/reference/cli/x.md +++ b/runtime/reference/cli/x.md @@ -48,7 +48,8 @@ deno x jsr:@std/http/file-server `deno x` downloads the package to the global cache (if not already cached), resolves the package's binary entry point, and executes it. The package is not -added to your project's `deno.json` or `package.json`. +added to your project's [`deno.json`](/runtime/fundamentals/configuration/) or +`package.json`. ## Permissions diff --git a/runtime/reference/continuous_integration.md b/runtime/reference/continuous_integration.md index ff986d2d0..e65700231 100644 --- a/runtime/reference/continuous_integration.md +++ b/runtime/reference/continuous_integration.md @@ -170,7 +170,7 @@ the contents of cached dependencies are saved and any subsequent runs can restore them from cache instead of re-downloading. To demonstrate, let's say you have a project that uses the logger from -[`@std/log`](https://jsr.io/@std/log): +[`@std/log`](/runtime/reference/std/log/): ```json title="deno.json" { diff --git a/runtime/reference/env_variables.md b/runtime/reference/env_variables.md index 124713b46..0799bd178 100644 --- a/runtime/reference/env_variables.md +++ b/runtime/reference/env_variables.md @@ -13,7 +13,8 @@ There are a few ways to use environment variables in Deno: The Deno runtime offers built-in support for environment variables with [`Deno.env`](https://docs.deno.com/api/deno/~/Deno.env). -`Deno.env` has getter and setter methods. Here is example usage: +[`Deno.env`](/api/deno/~/Deno.env) has getter and setter methods. Here is +example usage: ```ts Deno.env.set("FIREBASE_API_KEY", "examplekey123"); @@ -51,7 +52,7 @@ that the first occurrence found in the last `.env` file listed will be applied. ::: -## `@std/dotenv` +## [`@std/dotenv`](/runtime/reference/std/dotenv/) The `dotenv` package in the standard library can be used to load environment variables from `.env`. @@ -150,7 +151,7 @@ The Deno runtime has these special environment variables. | DENO_NO_UPDATE_CHECK | Set to disable checking if a newer Deno version is available | | DENO_V8_FLAGS | Set V8 command line options | | DENO_JOBS | Number of parallel workers used for the `--parallel` flag with the test subcommand.
Defaults to number of available CPUs. | -| DENO_KV_ACCESS_TOKEN | Personal access token used when connecting to Deno KV databases (for example via `Deno.openKv` or `@deno/kv` with a KV Connect URL). | +| DENO_KV_ACCESS_TOKEN | Personal access token used when connecting to Deno KV databases (for example via [`Deno.openKv`](/api/deno/~/Deno.openKv) or `@deno/kv` with a KV Connect URL). | | DENO_WEBGPU_TRACE | Path to a directory to output a [WGPU trace](https://github.com/gfx-rs/wgpu/pull/619) to when using the WebGPU API | | DENO_WEBGPU_BACKEND | Select the backend WebGPU will use, or a comma separated list of backends in order of preference. Possible values are `vulkan`, `dx12`, `metal`, or `opengl` | | HTTP_PROXY | Proxy address for HTTP requests (module downloads, fetch) | diff --git a/runtime/reference/lint_plugins.md b/runtime/reference/lint_plugins.md index 0d4ad2294..4570fd4f8 100644 --- a/runtime/reference/lint_plugins.md +++ b/runtime/reference/lint_plugins.md @@ -48,7 +48,8 @@ object. Deno provides type declarations for the lint plugins API. -All the typings are available under the `Deno.lint` namespace. +All the typings are available under the [`Deno.lint`](/api/deno/~/Deno.lint) +namespace. ::: @@ -276,9 +277,9 @@ The syntax for the ignore comment is: ## Testing plugins -The `Deno.lint.runPlugin` API provides a convenient way to test your plugins. It -allows you to assert that the plugin produces expected diagnostics given the -particular input. +The [`Deno.lint.runPlugin`](/api/deno/~/Deno.lint.runPlugin) API provides a +convenient way to test your plugins. It allows you to assert that the plugin +produces expected diagnostics given the particular input. Let's use the example plugin, defined above: @@ -303,8 +304,8 @@ Deno.test("my-plugin", () => { :::info -The `Deno.lint.runPlugin` API is only available in the `deno test` and -`deno bench` subcommands. +The [`Deno.lint.runPlugin`](/api/deno/~/Deno.lint.runPlugin) API is only +available in the `deno test` and `deno bench` subcommands. Trying to use it with any other subcommand will throw an error. diff --git a/runtime/reference/vscode.md b/runtime/reference/vscode.md index ad106d9f7..d2ca3f5c1 100644 --- a/runtime/reference/vscode.md +++ b/runtime/reference/vscode.md @@ -220,8 +220,9 @@ _References_ setting mentioned above. The Deno CLI includes a [built-in testing API](/runtime/reference/lsp_integration/#testing) available -under `Deno.test`. The extension and language server have a code lens enabled by -default which provides the ability to run a test from within the editor. +under [`Deno.test`](/api/deno/~/Deno.test). The extension and language server +have a code lens enabled by default which provides the ability to run a test +from within the editor. When you have a block of code that provides a test: @@ -250,8 +251,8 @@ adjust the arguments provided when doing `deno test`, you can do so by setting the `deno.codeLens.testArgs` setting. The extension will also try to track if in the same module you destructure the -`Deno.test` function or assign it to a variable. So you can do something like -this and still have the code lens work: +[`Deno.test`](/api/deno/~/Deno.test) function or assign it to a variable. So you +can do something like this and still have the code lens work: ```ts const { test: denoTest } = Deno; diff --git a/runtime/reference/web_platform_apis.md b/runtime/reference/web_platform_apis.md index 7c913678e..ec6dc66dc 100644 --- a/runtime/reference/web_platform_apis.md +++ b/runtime/reference/web_platform_apis.md @@ -58,7 +58,7 @@ implemented as specified in the - The `referrer`, `referrerPolicy`, `mode`, `credentials`, `cache`, `integrity`, `keepalive`, and `window` properties and their relevant behaviours in `RequestInit` are not implemented. The relevant fields are not present on the - `Request` object. + [`Request`](/api/web/~/Request) object. - Request body upload streaming is supported (on HTTP/1.1 and HTTP/2). Unlike the current fetch proposal, the implementation supports duplex streaming. - The `set-cookie` header is not concatenated when iterated over in the @@ -189,8 +189,8 @@ const worker = new Worker("./workers/hello.ts", { type: "module" }); :::note For the above use cases, it is preferable to pass URLs in full rather than -relying on `--location`. You can manually base a relative URL using the `URL` -constructor if needed. +relying on `--location`. You can manually base a relative URL using the +[`URL`](/api/web/~/URL) constructor if needed. ::: @@ -254,9 +254,9 @@ the `type: "module"` option when creating a new worker. Use of relative module specifiers in the main worker are only supported with `--location ` passed on the CLI. This is not recommended for portability. -You can instead use the `URL` constructor and `import.meta.url` to easily create -a specifier for some nearby script. Dedicated workers, however, have a location -and this capability by default. +You can instead use the [`URL`](/api/web/~/URL) constructor and +`import.meta.url` to easily create a specifier for some nearby script. Dedicated +workers, however, have a location and this capability by default. ```ts // Good