Skip to content

fix(examples): make the per-example "run locally" command actually runnable#3308

Merged
bartlomieju merged 1 commit into
mainfrom
docs/fix-example-run-urls
Jun 18, 2026
Merged

fix(examples): make the per-example "run locally" command actually runnable#3308
bartlomieju merged 1 commit into
mainfrom
docs/fix-example-run-urls

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

The "Run this example locally" command on every example page substituted
<url> with a github.com /blob/ URL, which serves an HTML page rather
than the script. As a result the rendered command never worked:

$ deno run https://github.com/denoland/deno-docs/blob/main/examples/scripts/hello_world.ts
error: SyntaxError: Expected ';', '}' or <eof>
7 | <!DOCTYPE html>

This switches the run command to the raw docs.deno.com URL the component
already computes, which serves the script and runs:

$ deno run https://docs.deno.com/examples/scripts/hello_world.ts
Hello, World!

It also corrects the repo name in the GitHub source links (deno-docs
was relying on a redirect to docs).

Separately, deno test cannot run a remote URL at all, even the working
raw one:

$ deno test -R -W https://docs.deno.com/examples/scripts/writing_tests.ts
error: No test modules found

So for deno test examples the page now renders a download-then-run
command that works (verified end to end against the three test examples):

# deno test runs local files, so download the example first:
curl -O https://docs.deno.com/examples/scripts/writing_tests.ts
deno test -R -W writing_tests.ts

Closes #1827.

The 'Run this example locally' command substituted <url> with a
github.com /blob/ URL, which serves an HTML page rather than the script,
so every rendered command failed (deno run/test on the blob URL throws a
SyntaxError on '<!DOCTYPE html>'). Use the raw docs.deno.com URL, which
serves the script, and fix the repo name in the GitHub links
(deno-docs -> docs).

deno test additionally cannot run a remote URL at all ('No test modules
found'), so for deno test examples render a download-then-run-locally
command instead.

Closes #1827
@bartlomieju
bartlomieju merged commit 956df2d into main Jun 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feedback: /examples/writing_tests/ - Needs Improvement

1 participant