Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref gen perf #1321

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"@std/html": "jsr:@std/html@^1.0.3",
"@std/media-types": "jsr:@std/media-types@^1.0.3",
"@std/path": "jsr:@std/path@^1.0.8",
"@deno/doc": "jsr:@deno/[email protected]",
"ga4": "https://raw.githubusercontent.com/denoland/ga4/04a1ce209116f158b5ef1658b957bdb109db68ed/mod.ts",
"lume/": "https://deno.land/x/[email protected]/",
"googleapis": "npm:googleapis@^144.0.0",
"prismjs": "npm:[email protected]",
"tailwindcss": "npm:tailwindcss@^3.4.9"
"tailwindcss": "npm:tailwindcss@^3.4.9",
"markdown-it": "npm:[email protected]"
},
"tasks": {
"serve": "deno run -A lume.ts -s",
Expand Down
49 changes: 48 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deploy/api/runtime-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface is part of the Fetch API and represents the request of fetch().
The Request() constructor creates a new Request instance.

```ts
let request = new Request(resource, init);
let request = new Request(input, init);
```

#### Parameters
Expand Down
9 changes: 7 additions & 2 deletions reference.page.jsx → reference.page._jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ export default function* () {
let title = "";
try {
const match = titleRegexp.exec(content);
const titleFirst = match[1].slice(0, -"documentation".length);

title = unescape(titleFirst, { entityList }) + "- Deno Docs";
if (!match) {
//console.log("No title found in", file.path);
title = file.path + " - Deno Docs";
} else {
const titleFirst = match[1].slice(0, -"documentation".length);
title = unescape(titleFirst, { entityList }) + "- Deno Docs";
}
} catch (e) {
if (!file.path.endsWith("prototype.html")) {
console.error(file.path);
Expand Down
17 changes: 17 additions & 0 deletions reference/_categories/deno-categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Cloud": "Tools for managing state, scheduling tasks, and interacting with key-value stores. \n\nEg {@linkcode Deno.openKv }, {@linkcode Deno.cron}",
"Errors": "Error types and utilities for handling exceptions and custom error scenarios. Helps improve error handling and debugging. \n\nEg {@linkcode Deno.errors.NotFound}",
"FFI": "Foreign Function Interface. Call functions from shared libraries (e.g., C/C++) directly from Deno.\n\nUseful for integrating with existing native code or accessing low-level system functionality. \n\nEg {@linkcode Deno.dlopen}",
"Fetch": "HTTP client for fetching data across a network. Retrieve resources from servers, handle responses, and manage network requests. \n\nEg {@linkcode fetch}, {@linkcode Response}, {@linkcode Request}, {@linkcode Headers}",
"File System": "File System APIs for working with files, directories, and file metadata. Includes functions for reading, writing, and manipulating file paths. \n\nEg {@linkcode Deno.readDir}, {@linkcode Deno.readTextFile}",
"GPU": "GPU programming and rendering. Efficiently use a device’s graphics processing unit (GPU) for high-performance computations and complex image rendering. \n\nEg {@linkcode GPUDevice}",
"HTTP Server": "Handling HTTP requests, serving responses, and managing server behavior. \n\nEg {@linkcode Deno.serveHttp}, {@linkcode Deno.serve}",
"I/O": "Interfaces for reading, writing, seeking, and managing resources. For handling of data streams, file I/O, and console interactions. \n\nEg {@linkcode Deno.stdin}, {@linkcode Deno.inspect}",
"Jupyter": "Create interactive notebooks and execute code cells. Useful for data analysis, visualization, and educational purposes. \n\nEg {@linkcode Deno.jupyter}",
"Network": "A wide range of networking tasks, from low-level connections to high-level server creation. Handle HTTP requests, WebSocket communication, and DNS resolution. Useful for building web servers, clients, and networking tools. \n\nEg {@linkcode Deno.connect}, {@linkcode Deno.listen}, {@linkcode Deno.resolveDns}",
"Permissions": "Permission system controls access to resources (e.g., file system, network, environment variables).\n\nRequest permissions explicitly, enhancing security and user trust. \n\nEg {@linkcode Deno.permissions}",
"Runtime": "System-related functionality, process management, and observability. \n\nEg {@linkcode Deno.mainModule}, {@linkcode Deno.exit}, {@linkcode Deno.cwd}",
"Subprocess": "Spawn and manage child processes, execute commands, and collect output. Useful for executing external programs from Deno.\n\nEg {@linkcode Deno.Command}",
"Testing": "Robust testing and benchmarking capabilities to ensure code quality and performance.\n\nEg {@linkcode Deno.test}, {@linkcode Deno.bench}",
"WebSockets": "Enable real-time communication between clients and servers using WebSockets. Tools to create interactive and dynamic applications.\n\nEg {@linkcode WebSocket}"
}
22 changes: 22 additions & 0 deletions reference/_categories/web-categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Cache": "Tools for caching and managing data. Store and retrieve data from the cache, manage cache storage limits, and handle cache-related events.\n\nEg {@linkcode caches}",
"Canvas": "Create, transform, and display images and graphics within the HTML element.\n\nEg {@linkcode createImageBitmap}",
"Crypto": "Cryptographic functionality for secure communication, data protection, and key management. Generate secure random numbers, encrypt and decrypt data, and manage cryptographic keys.\n\nEg {@linkcode crypto}",
"Encoding": "Handle character encoding, decoding, and binary data conversion.\n\nEg {@linkcode TextDecoder}, {@linkcode TextEncoder}",
"Events": "Handle events and interactions. Listen for and respond to various events, including custom events, errors, progress, and promise rejections.\n\nEg {@linkcode addEventListener}",
"Fetch": "HTTP client for fetching data across a network. Retrieve resources from servers, handle responses, and manage network requests.\n\nEg {@linkcode fetch}, {@linkcode Response}, {@linkcode Request}, {@linkcode Headers}",
"File": "File and data manipulation tools. Handle files, read data and work with binary content.\n\nEg {@linkcode File}, {@linkcode Blob}",
"GPU": "GPU programming and rendering. Efficiently use a device’s graphics processing unit (GPU) for high-performance computations and complex image rendering.\n\nEg {@linkcode GPUDevice}",
"I/O": "Interfaces for reading, writing, seeking, and managing resources. For handling of data streams, file I/O, and console interactions. \n\nEg {@linkcode stdin}, {@linkcode inspect}",
"Intl": "Tools for internationalization and localization. Create language-aware applications, handle date and time formatting, and adapt content for different locales. \n\nEg {@linkcode Intl}",
"Messaging": "Facilitate communication between different parts of an application, allowing data exchange and coordination.\n\nEg {@linkcode BroadcastChannel}, {@linkcode MessageChannel}",
"Performance": "Measure, analyze, and optimize application performance. \n\nEg {@linkcode performance}",
"Platform": "A set of essential interfaces and functions to interact with the browser environment. Eg handling user interactions, getting browser and device information, scheduling and canceling periodic or one-time tasks.\n\n{@linkcode prompt}, {@linkcode console}",
"Storage": "Store data locally within the browser. Manage session storage and local storage.\n\n{@linkcode sessionStorage}, {@linkcode localStorage}",
"Streams": "Manage data streams, queuing strategies, and transformations. Handle data in chunks, process large datasets, and optimize memory usage.\n\nEg {@linkcode ReadableStream}, {@linkcode WritableStream}, {@linkcode TransformStream}",
"Temporal": "Date and time handling. Includes long-lived Workflows, calendar systems, time zones, and precise duration calculations.\n\nEg {@linkcode Temporal.Now}, {@linkcode Temporal.PlainDate}",
"URL": "Manipulate URLs, extract data from URLs and manage query parameters.\n\nEg {@linkcode URL}",
"Wasm": "Efficiently execute computationally intensive tasks. Wasm module compilation, instantiation, memory management, and interaction with imports and exports.\n\nEg {@linkcode WebAssembly.instantiate}, {@linkcode WebAssembly.Module}, {@linkcode WebAssembly.Instance}",
"WebSockets": "Enable real-time communication between clients and servers using WebSockets. Tools to create interactive and dynamic applications.\n\nEg {@linkcode WebSocket}",
"Workers": "Run script operations in background threads. Manage worker threads, communicate with workers, and handle data transfer between workers and the main thread.\n\nEg {@linkcode Worker}"
}
50 changes: 50 additions & 0 deletions reference/_dataSources/dtsSymbolSource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { expandGlob } from "@std/fs";
import { doc, DocNode } from "@deno/doc";

export type Package = {
name: string;
symbols: DocNode[];
};

const packages = [
{ packageName: "Web", files: ["./types/web.d.ts"] },
{ packageName: "Deno", files: ["./types/deno.d.ts"] },
{ packageName: "Node", files: await getNodeTypeFiles() },
];

export async function* getSymbols() {
for (const { packageName, files } of packages) {
const paths = files.map((file) => {
if (!file.startsWith("./")) {
return `file://${file}`;
} else {
const newPath = file.replace("./", "../../reference_gen/");
return import.meta.resolve(newPath);
}
});

const docs = await loadDocumentation(paths);

for (const sourceFile of Object.keys(docs)) {
const symbols = docs[sourceFile];
yield { packageName, symbols };
}
}
}

async function loadDocumentation(paths: string[]) {
const docGenerationPromises = paths.map(async (path) => {
return await doc([path]);
});

const nodes = await Promise.all(docGenerationPromises);
return nodes.reduce((acc, val) => ({ ...acc, ...val }), {});
}

async function getNodeTypeFiles() {
const urls: string[] = [];
for await (const file of expandGlob("./types/node/[!_]*")) {
urls.push(file.path);
}
return urls;
}
87 changes: 87 additions & 0 deletions reference/_layouts/ReferencePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from "npm:@preact/compat";
import { Navigation, ReferenceContext } from "../types.ts";

export default function Layout(
{ context, navigation, children }: {
context: ReferenceContext;
navigation?: Navigation;
children: React.ReactNode;
},
) {
return (
<>
{/* sorry mum, put these somewhere good */}
<link rel="stylesheet" href="/reference-styles/styles.css" />
<link rel="stylesheet" href="/reference-styles/page.css" />

<div className={"ddoc"}>
<CategoryPanel context={context} />
<div>
{navigation && <TopNav {...navigation} />}
<div id={"content"}>
{children}
</div>
</div>
</div>
</>
);
}

function CategoryPanel({ context }: { context: ReferenceContext }) {
const categories = context.currentCategoryList;

const categoryListItems = Object.entries(categories).map(([key, value]) => {
const categoryLinkUrl =
`${context.root}/${context.packageName.toLocaleLowerCase()}/${key.toLocaleLowerCase()}`;

return (
<li>
<a href={categoryLinkUrl}>{key}</a>
</li>
);
});

return (
<div id={"categoryPanel"}>
<ul>
{categoryListItems}
</ul>
</div>
);
}

function TopNav(
{ category, currentItemName }: Navigation,
) {
return (
<nav id={"topnav"} className={"top-0 sticky bg-white z-50 py-3 h-14"}>
<div className={"h-full"}>
<div>
<ul className={"breadcrumbs"}>
<li>
<a href="./" className={"contextLink"}>{category}</a>
</li>
<span class="text-[#0F172A]">
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M5.76748 11.8159C5.5378 11.577 5.54525 11.1972 5.78411 10.9675L8.93431 8L5.78411 5.0325C5.54525 4.80282 5.5378 4.423 5.76748 4.18413C5.99715 3.94527 6.37698 3.93782 6.61584 4.1675L10.2158 7.5675C10.3335 7.68062 10.4 7.83679 10.4 8C10.4 8.16321 10.3335 8.31938 10.2158 8.4325L6.61584 11.8325C6.37698 12.0622 5.99715 12.0547 5.76748 11.8159Z"
fill="currentColor"
>
</path>
</svg>
</span>
<li>{currentItemName}</li>
</ul>
</div>
</div>
</nav>
);
}
Loading
Loading