GithubHelp home page GithubHelp logo

denoland / deno-docs Goto Github PK

View Code? Open in Web Editor NEW
51.0 14.0 92.0 18.71 MB

Deno documentation, examples and API Reference. Powered by Lume.

Home Page: https://docs.deno.com

License: MIT License

JavaScript 3.01% TypeScript 88.75% CSS 8.24%

deno-docs's Introduction

Deno Docs

This repository contains the website running docs.deno.com. The intent of this project is to centralize all official Deno documentation content in a single website. The Deno Docs site is built using Lume, an extremely fast static site generator.

The docs.deno.com website is hosted on Deno Deploy.

Local development

Install Deno.

You can then start the local development server with:

deno task serve

This will launch a browser window open to localhost:3000, where you will see any doc content changes you make update live. Here redirects will not work. If you want redirects to work, you need to run:

deno task build
deno task prod

Which will start a Deno server on localhost:8000 used in production, which handles redirects.

Editing content

The actual content of the docs site is found mostly in these folders:

  • runtime - docs for the Deno CLI / runtime
  • deploy - docs for the Deno Deploy cloud service
  • subhosting - docs for Deno Subhosting
  • examples - docs for the Examples section

Most files are markdown, but even markdown files are processed with MDX, which enables you to use JSX syntax within your markdown files.

Left navigation for the different doc sections are configured in the _data.ts files in their respective content directories.

  • runtime/_data.ts - sidebar config for the Runtime section
  • deploy/_data.ts - sidebar config for the Deno Deploy section

Static files (like screenshots) can be included directly in the runtime, deploy, or kv folders, and referenced by relative URLs in your markdown.

Reference docs

The reference docs served at /api are generated via the deno doc subcommand. To generate the reference docs locally, in the reference_gen directory, run:

deno task types
deno task doc

This will generate the reference docs, and you can use the serve or build tasks.

Versioning docs content

Philosophically, we want to maintain as few discrete versions of the documentation as possible. This will reduce confusion for users (reduce the number of versions they need to think about), improve search indexing, and help us maintain the docs by keeping our build times faster.

In general, we should only version the documentation when we want to concurrently maintain several versions of the docs, like for major/LTS versions. For example - the Node.js docs are only versioned for major releases, like 20.x and 19.x. We will adopt this pattern as well, and won't have versioned docs for patch or feature releases.

For additive changes, it should usually be sufficient to indicate which version a feature or API was released in. For example - in the Node 20 docs, the register function is marked as being added in version 20.6.0.

Contribution

We are very grateful for any help you can offer to improve Deno's documentation! For any small copy changes or fixes, please feel free to submit a pull request directly to the main branch of this repository.

For larger changes, please create a GitHub issue first to describe your proposed updates. It will be better to get feedback on your concept first before going to the trouble of writing a large number of docs!

Over time, we will add more in the way of linting and formatting to the pull request process. But for now, you should merely ensure that npm run build succeeds without error before submitting a pull request. This will ensure that there are no broken links or invalid MDX syntax in the content you have authored.

Examples

Deno by Example is a collection of small snippets showcasing various functions of the APIs implemented in Deno.

  • Examples are written in TypeScript
  • Each example should be a single file, no more than 50 lines
  • Each example should be a self-contained unit, and should depend on no dependencies other than Deno builtins and the standard library, unless a third-party library is strictly required.
  • Each example should be runnable without additional dependencies on all systems (exceptions can be made for platform specific functionality)
  • Examples should be introduce at most one (or in exceptional cases two or three) concepts in Deno / Web APIs. Existing concepts should be linked to.
  • Code should be kept really simple, and should be easy to read and understand by anyone. Do not use complicated code constructs, or hard to follow builtins like Array.reduce
  • Concepts introduced in an example should be explained

Adding an example

To add an example, create a file in the examples directory. The file name should be a short description of the example (in kebab case) and the contents should be the code for the example. The file should be in the .ts format. The file should start with a JSDoc style multi line comment that describes the example:

/**
 * @title HTTP server: Hello World
 * @difficulty intermediate
 * @tags cli, deploy
 * @run --allow-net <url>
 * @group Basics
 *
 * An example of a HTTP server that serves a "Hello World" message.
 */

You should add a title, a difficulty level (beginner or intermediate), and a list of tags (cli, deploy, web depending on where an example is runnable). The @run tag should be included if the example can be run locally by just doing deno run <url>. If running requires permissions, add these:

/**
 * ...
 * @run --allow-net --allow-read <url>
 */

After the pragmas, you can add a description of the example. This is optional, but recommended for most examples. It should not be longer than one or two lines. The description shows up at the top of the example in the example page, and in search results.

After the JS Doc comment, you can write the code. Code can be prefixed with a comment that describes the code. The comment will be rendered next to the code in the example page.

Special thanks for historical contributions

This repository was created using content from the Deno Manual, a project contributed to by hundreds of developers since 2018. You can view a list of historical contributors to the Deno documentation in this repository and the manual with this command:

git shortlog -s -n

Deployment

The docs.deno.com site is updated with every push to the main branch, which should be done via pull request to this repository.

License

MIT

deno-docs's People

Contributors

ayame113 avatar bartlomieju avatar caspervonb avatar cknight avatar crowlkats avatar denobot avatar donjo avatar dsherret avatar getspooky avatar gjzwiers avatar hashrock avatar iuioiua avatar josh-collinsworth avatar kitsonk avatar kt3k avatar kwhinnery avatar littledivy avatar losfair avatar lucacasonato avatar magurotuna avatar marvinhagemeister avatar nayeemrmn avatar not-my-profile avatar rbetts avatar ry avatar sant123 avatar thisisjofrank avatar tokiedokie avatar trivikr avatar vwkd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deno-docs's Issues

List not supported features of standalone Deno apps

I think it would be helpful to list here what features are not supported in standalone (aka deno compile) apps. As far I know, there isn't any official doc mentioning the differences.

I only know of Web Workers, but there might be others too.

Thoughts ? ๐Ÿ˜„

[Deploy docs] - Finish/Fix DynamoDB example

What problem are you trying to solve?

The Connect to DynamoDB docs page has snippets of useful information but is ultimately a let down as there are large gaps that need filled in on your own. It would be far more useful to have a complete working example. Specific issues:

  • Gather credentials from DynamoDB

My experience in getting credentials was different to this. This may be my inexperience of using AWS, but should be checked for currency.

  • Write code that connects to DynamoDB

By referencing new ApiFactory().makeNew(DynamoDB) I am assuming that you are referencing https://deno.land/x/aws_api but there is no mention of this anywhere on the page nor any imports anywhere to guide you. Also, there is a strong caveat to using this library, namely:

Do not use this module in mission critical stuff. It's supposed to be for automation scripts, quick & dirty pieces of infrastructure, and prototype microservices and so on. If you just want the real, full-fat AWS SDK, a port of it has been uploaded at /x/aws_sdk.

Either use this library and highlight the caveat or show the example using the official AWS SDK.

Also, this line const data = await client.send(command); is thrown in without any suggestion where command comes from, how to construct it, what it looks like, etc.

Describe the solution you'd like

The docs for this are too light, much is left to the reader to work out and do a disservice to anyone attempting to follow them. Either this example should be properly and more thoroughly completed or this page removed.

Describe alternatives you've considered

As per above, complete this example or remove this page.

Documentation, Adoption, Migration Strategy

No response

jsdom manual example - Not Implemented: isContext

Using the manual example for:
https://github.com/denoland/manual/blob/v1.26.1/jsx_dom/jsdom.md
I get:

error: Uncaught Error: Not implemented: isContext
throw new Error(message);
^
at notImplemented (https://deno.land/[email protected]/node/_utils.ts:23:9)
at Object.isContext (https://deno.land/[email protected]/node/vm.ts:62:3)
at new Sme (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:8449)
at iY.createWindow (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:6192)
at new py (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:23482)
at file:///Users/tracey/av/jsdom.js:4:34

I tried a few versions back in jsdom -- just in case it was that. But get same style failure up to versions 1y old, too, eg:

deno eval 'import { JSDOM } from  "https://esm.sh/[email protected]"; new JSDOM("<!DOCTYPE html><html><body></body></html>")'

I'm using latest v1.26.1 of deno. Any help appreciated! I'd love to convert my work codebase jest-based (a fair amount using jsdom) from node to deno. (I tried
import { DOMParser } from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts'; too. And that is working decently for some of the testing -- but we could use a more complete DOM fake for some tests (eg: form submitting, etc.)

Full example here:

> cat deno.jsonc;
{
  "compilerOptions": {
    "lib": [
      "deno.ns",
      "dom",
      "dom.iterable",
      "dom.asynciterable"
    ]
  }
}


> cat jsdom.js   
import { JSDOM } from  "https://esm.sh/jsdom";
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";

const { window: { document } } = new JSDOM(
  `<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hello from Deno</title>
  </head>
  <body>
    <h1>Hello from Deno</h1>
    <form>
      <input name="user">
      <button>
        Submit
      </button>
    </form>
  </body>
</html>`,
  {
    url: "https://example.com/",
    referrer: "https://example.org/",
    contentType: "text/html",
    storageQuota: 10000000,
  },
);

const h1 = document.querySelector("h1");
assert(h1);

console.log(h1.textContent);


> deno run -A jsdom.js
error: Uncaught Error: Not implemented: isContext
  throw new Error(message);
        ^
    at notImplemented (https://deno.land/[email protected]/node/_utils.ts:23:9)
    at Object.isContext (https://deno.land/[email protected]/node/vm.ts:62:3)
    at new Sme (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:8449)
    at iY.createWindow (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:6192)
    at new py (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:23482)
    at file:///Users/tracey/av/jsdom.js:4:34

esm.sh vs npm specifiers

call out benefits to use npm specifiers over esh.sm:

the major advantage of npm specifiers is that you don't have to rely on 3rd party service to transpile them and Deno's static analysis is more precise than esm.sh due to being run locally. that allows you to load Node-API files and data files from packages. which isn't really possible with esm.sh.

Document special env variables

Special env variables are documented in deno --help output, but some of these are not mentioned in the manual at all. I think we need a page for listing these env vars in the manual to make these variables searchable in the homepage.

ENVIRONMENT VARIABLES:
    DENO_AUTH_TOKENS     A semi-colon separated list of bearer tokens and
                         hostnames to use when fetching remote modules from
                         private repositories
                         (e.g. "[email protected];[email protected]")
    DENO_TLS_CA_STORE    Comma-separated list of order dependent certificate
                         stores. Possible values: "system", "mozilla".
                         Defaults to "mozilla".
    DENO_CERT            Load certificate authority from PEM encoded file
    DENO_DIR             Set the cache directory
    DENO_INSTALL_ROOT    Set deno install's output directory
                         (defaults to $HOME/.deno/bin)
    DENO_NO_PROMPT       Set to disable permission prompts on access
                         (alternative to passing --no-prompt on invocation)
    DENO_NO_UPDATE_CHECK Set to disable checking if a newer Deno version is
                         available
    DENO_WEBGPU_TRACE    Directory to use for wgpu traces
    DENO_JOBS            Number of parallel workers used for the --parallel
                         flag with the test subcommand. Defaults to number
                         of available CPUs.
    HTTP_PROXY           Proxy address for HTTP requests
                         (module downloads, fetch)
    HTTPS_PROXY          Proxy address for HTTPS requests
                         (module downloads, fetch)
    NPM_CONFIG_REGISTRY  URL to use for the npm registry.
    NO_COLOR             Set to disable color
    NO_PROXY             Comma-separated list of hosts which do not use a proxy
                         (module downloads, fetch)

Missing documentation for `deno check` tool

I think it would be helpful to document deno check usage. I knew the command existed but it's usage is not that clear (including --help output).

I expected deno check to typecheck the whole project but it needs the file. Calling it like this deno check **/**.ts is also not what I was looking for. After some trial and error I figured out that it type-checks all of the imported files recursively so I basically needed to call deno check src/mod.ts.

Would be nice to clarify this in docs.

Depricate all refrences to skypack.dev

The skypack-cdn seems to be abandoned. No issue updates have been made recently and the search API on the website is broken. We should:

  1. Preemptively replace links from skypack.dev to esm.sh to ensure if skypack.dev goes completely down new users won't be confused
  2. Note on the node-faq page that the project seems to be abandoned and should not be used.

Error in the debugging section?

https://deno.land/[email protected]/getting_started/debugging_your_code#chrome-devtools

You might notice that DevTools pauses execution on the first line of
_constants.ts instead of file_server.ts. This is expected behavior caused by
the way ES modules are evaluated in JavaScript (_constants.ts is left-most,
bottom-most dependency of file_server.ts so it is evaluated first).

In my system, the DevTools pauses execution on os.ts instead of _constants.ts:

Screen Shot 2022-10-01 at 15 51 20

I'm using Deno 1.26.0 and Chrome 106.

Set up CI and Deno Deploy project

Create the necessary CI integrations and Deno Deploy setup to run the doc site. Site should be hosted on the main Deno Deploy account.

Add "What has changed?" page

It would be great if manual had "What has changed?" page. It's not easy right now for users to see what new additions where made to manual since the last release.

It's unreasonable to expect users to go to Github repository and see commit log to figure this out. This could be somehow generated using git log and then mapped to actual manual pages with additions.

CC @lucacasonato

Doubts on "Integrity Checking and Lock Files" Article

Greetings!

The article "Integrity Checking and Lock Files" doesn't explain what happen if the checking fails. How the another developer fix the problem? The dependency on cloud has not the code that the project needs. Must the first developer share the dependency manually? How do that?

Thanks. Deno is great!

Create catch-all handler for 404s in static site

Redirects from deno.land may not be sent to the correct location - in the Oak server sitting on top of the Docusaurus site, introduce a middleware handler that will be the fallback if a static file isn't found. 301 redirect if possible, otherwise 404.

Add manual installation guide

There're many edge cases where install.sh doesn't work well with users environment (e.g. missing unzip, broken curl, the shell is not bash or zsh ), but also we don't want to make install.sh more complex to support those edge cases.

To address those edge cases, I suggest we should have manual installation guide, which instructs the users to install Deno completely manually (like with the sections 1. Download, 2. Move, 3. Configure $PATH and each section describes some alternatives.)

Invalid signal: SIGINT process.kill("SIGINT")

https://deno.land/[email protected]/examples/subprocess

I follow the code at the bottom of the document page to execute an invalid type error

import { mergeReadableStreams } from "https://deno.land/[email protected]/streams/merge_readable_streams.ts";

// create the file to attach the process to
const file = await Deno.open("./hello.txt", {
  read: true,
  write: true,
  create: true,
});

// start the process
const process = Deno.run({
  cmd: ["yes"],
  stdout: "piped",
  stderr: "piped",
});

// example of combining stdout and stderr while sending to a file
const joined = mergeReadableStreams(
  process.stdout.readable,
  process.stderr.readable,
);

// returns a promise that resolves when the process is killed/closed
joined.pipeTo(file.writable).then(() => console.log("pipe join done"));

// manually stop process "yes" will never end on its own
setTimeout(() => {
  process.kill("SIGINT"); //Change to SIGTERM, no error
}, 100);

error: Uncaught TypeError: Invalid signal: SIGINT
process.kill("SIGINT"); //SIGTERM
^
at opKill (deno:runtime/js/40_process.js:21:9)
at Process.kill (deno:runtime/js/40_process.js:99:7)
at file:///E:/test/deno/deno01/index.ts:648:11
at Object.action (deno:ext/web/02_timers.js:147:13)
at handleTimerMacrotask (deno:ext/web/02_timers.js:64:12)

Create SubChapter of Embedding Deno

Related to denoland/manual#15

It is important to have an easy-to-use explanation of all of deno's crates and what features they provide.

It makes it easier to build custom operators and pick and choose features to create the perfect Embedded Runtime.

Generate API Reference for Deno runtime as a build task

The API reference today is dynamically generated per request on the server. The current implementation of the doc site links back to deno.land where this work is being done today.

However, this content is not truly dynamic, and could benefit from static generation. This would also allow us to use the sitemap generation features of Docusaurus.

Using the same API endpoints that exist for the Deno runtime today, we should generate MDX files for the Runtime and include them in the runtime docs folder.

Improve contributing guidelines

I suggest the maintainers add a CONTRIBUTING.md file:
https://mozillascience.github.io/working-open-workshop/contributing/

As someone who just had the need to clone Deno & poke around, I can say that beyond just regular rust setup, there are a lot of not fully clear things, e.g:

  • What does a comfortable DX looks like for debugging *.js files from ext/?
  • Known issues with compilation? (for example, it seemed like cargo was over-zealously rebuilding some packages for me

And just in general, it's a very friendly way to let someone who can contribute code or debug something know how to get the rubber to hit the road with minimal headaches.

If those instructions do exist somewhere, you could link them from CONTRIBUTING.md or vice versa, because if they DO exist, they weren't very easily discoverable (I sure did try)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.