From d17ae61f41de0f681a341296293056cb05215b4b Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 23 Dec 2024 12:53:14 +0100 Subject: [PATCH] more docs fixes --- docs/sphinx_pyodide/sphinx_pyodide/jsdoc.py | 2 +- .../sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py | 17 +++++++++++++---- src/js/api.ts | 5 +++++ src/js/dynload.ts | 2 +- src/js/installer.ts | 2 +- src/js/load-package.ts | 12 ++++++++++-- src/js/snapshot.ts | 2 +- src/js/types.ts | 18 ++++++++++++++++-- 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/docs/sphinx_pyodide/sphinx_pyodide/jsdoc.py b/docs/sphinx_pyodide/sphinx_pyodide/jsdoc.py index 6470ee8b2c5..1e4b54aa3dc 100644 --- a/docs/sphinx_pyodide/sphinx_pyodide/jsdoc.py +++ b/docs/sphinx_pyodide/sphinx_pyodide/jsdoc.py @@ -101,7 +101,7 @@ def doclet_is_private(doclet: ir.TopLevel) -> bool: # this via a @private decorator in the documentation comment. return True - if filename in ["module.", "compat.", "types."]: + if filename in ["module.", "compat."]: return True if filename == "pyproxy." and toplevelname.endswith("Methods"): diff --git a/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py b/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py index b310dafae01..9a35130df78 100644 --- a/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py +++ b/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py @@ -32,6 +32,14 @@ "TextDecoder": "$global/", "DataView": "$global/", "Uint8Array": "$global/", + "Int8Array": "$global/", + "Uint16Array": "$global/", + "Int16Array": "$global/", + "Uint32Array": "$global/", + "Int32Array": "$global/", + "Uint8ClampedArray": "$global/", + "Float32Array": "$global/", + "Float64Array": "$global/", "Map": "$global/", "Set": "$global/", # the JavaScript domain has no exception type for some reason... @@ -156,11 +164,12 @@ USE_NAME_AS_LINK_TEXT, ) -for key, url in [ - ("void", "https://www.typescriptlang.org/docs/handbook/2/functions.html#void"), - ("any", "https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any"), +for ty, key, url in [ + ("js:data", "void", "https://www.typescriptlang.org/docs/handbook/2/functions.html#void"), + ("js:data", "any", "https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any"), + ("js:class", "Record", "https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type") ]: - INVDATA["js:data"][key] = ( + INVDATA[ty][key] = ( "typescript docs", "", url, diff --git a/src/js/api.ts b/src/js/api.ts index a3cdcf2ad9e..426176ab0a0 100644 --- a/src/js/api.ts +++ b/src/js/api.ts @@ -666,6 +666,11 @@ export class PyodideAPI { return orig; } + /** + * + * @param param0 + * @returns + */ static makeMemorySnapshot({ serializer, }: { diff --git a/src/js/dynload.ts b/src/js/dynload.ts index 3851d1dd791..420446c4b55 100644 --- a/src/js/dynload.ts +++ b/src/js/dynload.ts @@ -5,7 +5,7 @@ import { PackageManagerAPI, PackageManagerModule } from "./types"; import { createLock } from "./common/lock"; import { LoadDynlibFS, ReadFileType, InternalPackageData } from "./types"; -/** @private */ +/** @hidden */ export class DynlibLoader { #api: PackageManagerAPI; #module: PackageManagerModule; diff --git a/src/js/installer.ts b/src/js/installer.ts index d440260386c..f3a13adf069 100644 --- a/src/js/installer.ts +++ b/src/js/installer.ts @@ -9,7 +9,7 @@ import { PackageManagerAPI, PackageManagerModule } from "./types"; * - storing metadata about the Package * - loading shared libraries * - installing data files - * @private + * @hidden */ export class Installer { #api: PackageManagerAPI; diff --git a/src/js/load-package.ts b/src/js/load-package.ts index f94abf23ec1..7dccf08dd86 100644 --- a/src/js/load-package.ts +++ b/src/js/load-package.ts @@ -6,6 +6,7 @@ import { PackageLoadMetadata, PackageManagerAPI, PackageManagerModule, + LoadedPackages, } from "./types"; import { IN_NODE } from "./environments"; import type { PyProxy } from "generated/pyproxy"; @@ -118,7 +119,7 @@ export class PackageManager { * * TODO: Make this private and expose a setter */ - public loadedPackages: Record = {}; + public loadedPackages: LoadedPackages = {}; private _lock = createLock(); @@ -566,7 +567,14 @@ export function toStringArray(str: string | PyProxy | string[]): string[] { } export let loadPackage: typeof PackageManager.prototype.loadPackage; -export let loadedPackages: typeof PackageManager.prototype.loadedPackages; +/** + * An object whose keys are the names of the loaded packages and whose values + * are the install sources of the packages. Use + * `Object.keys(pyodide.loadedPackages)` to get the list of names of loaded + * packages, and `pyodide.loadedPackages[package_name]` to access the install + * source for a particular `package_name`. + */ +export let loadedPackages: LoadedPackages; if (typeof API !== "undefined" && typeof Module !== "undefined") { const singletonPackageManager = new PackageManager(API, Module); diff --git a/src/js/snapshot.ts b/src/js/snapshot.ts index 1ae218d4299..4a4abcf0bf3 100644 --- a/src/js/snapshot.ts +++ b/src/js/snapshot.ts @@ -60,7 +60,7 @@ export function makeGlobalsProxy( type SerializedHiwireValue = { path: string[] } | { serialized: any } | null; /** - * @private + * @hidden */ export type SnapshotConfig = { hiwireKeys: SerializedHiwireValue[]; diff --git a/src/js/types.ts b/src/js/types.ts index 177f0c387ee..8c2b1927427 100644 --- a/src/js/types.ts +++ b/src/js/types.ts @@ -171,6 +171,7 @@ declare global { export const __iscoroutinefunction: (a: number) => number; } +/** @hidden */ export type FSNode = { timestamp: number; rdev: number; @@ -178,6 +179,7 @@ export type FSNode = { mode: number; }; +/** @hidden */ export type FSStream = { tty?: boolean; seekable?: boolean; @@ -185,8 +187,10 @@ export type FSStream = { node: FSNode; }; +/** @hidden */ export type FSStreamOps = FSStreamOpsGen; +/** @hidden */ export type FSStreamOpsGen = { open: (a: T) => void; close: (a: T) => void; @@ -207,6 +211,7 @@ export type FSStreamOpsGen = { ) => number; }; +/** @hidden */ export interface FS { unlink: (path: string) => void; mkdirTree: (path: string, mode?: number) => void; @@ -256,13 +261,15 @@ export interface FS { readFile(a: string): Uint8Array; } -/** @private */ +/** @hidden */ export type PreRunFunc = (Module: Module) => void; +/** @hidden */ export type ReadFileType = (path: string) => Uint8Array; // File System-like type which can be passed to // Module.loadDynamicLibrary or Module.loadWebAssemblyModule +/** @hidden */ export type LoadDynlibFS = { readFile: ReadFileType; findObject: (path: string, dontResolveLastLink: boolean) => any; @@ -270,12 +277,14 @@ export type LoadDynlibFS = { type DSO = any; +/** @hidden */ export interface LDSO { loadedLibsByName: { [key: string]: DSO; }; } +/** @hidden */ export interface Module { API: API; locateFile: (file: string) => string; @@ -340,12 +349,13 @@ type LockfileInfo = { python: string; }; +/** @hidden */ export type Lockfile = { info: LockfileInfo; packages: Record; }; -/** @private */ +/** @hidden */ export type PackageType = | "package" | "cpython_module" @@ -362,6 +372,9 @@ export interface PackageData { packageType: PackageType; } +/** @hidden */ +export type LoadedPackages = Record; + /** * @hidden */ @@ -389,6 +402,7 @@ export type PackageLoadMetadata = { packageData: InternalPackageData; }; +/** @hidden */ export interface API { fatal_error: (e: any) => never; isPyProxy: (e: any) => e is PyProxy;