We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Proxied JS method.apply(context, list) fail while method(*list) doesn't
## 🐛 Bug

While working on [this PyScript issue](https://github.com/pyscript/pyscript/pull/1459) I've noticed that `context.method.apply(context, list)` doesn't work while `context.method(*list)` does.

I don't mind using the latter as that's also more Pythonic but that might surprise JS developers using Pyodide proxies that mimic JS APIs.

### To Reproduce

```python
import js
classList = js.document.body.classList
classList.add.apply(classList, ["a", "b"])
```

### Expected behavior

The method should be invoked with *n* arguments as by JS specs.

### Environment

- Pyodide Version<!-- (e.g. 1.8.1) -->: latest
- Browser version<!-- (e.g. Chrome 95.0.4638.54) -->: any
- Any other relevant information: nope

<!-- If you are building Pyodide by yourself, please also include these information: -->

<!--
- Commit hash of Pyodide git repository:
- Build environment<!--(e.g. Ubuntu 18.04, pyodide/pyodide-env:19 docker)- ->:
-->

### Additional context

Happy to have it as won't fix but at least there's a related issue that explain the *gotcha*.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py`
Content:
```
1 from sphinx.application import Sphinx
2 from sphinx.ext.intersphinx import InventoryAdapter
3 
4 DATA = {
5     "js:function": {
6         "setTimeout": "API/",
7         "clearTimeout": "API/",
8         "setInterval": "API/",
9         "clearInterval": "API/",
10         "fetch": "API/",
11         "eval": "$global/",
12         "Object.fromEntries": "$global/",
13         "Reflect.ownKeys": "$global/",
14         "Array.from": "$global/",
15         "Atomics.wait": "$global/",
16     },
17     "js:class": {
18         "Array": "$global/",
19         "NodeList": "API/",
20         "HTMLCollection": "API/",
21         "Generator": "$global/",
22         "AsyncGenerator": "$global/",
23         "Date": "$global/",
24         "ArrayBuffer": "$global/",
25         "SharedArrayBuffer": "$global/",
26         "TypedArray": "$global/",
27         "TextEncoder": "$global/",
28         "TextDecoder": "$global/",
29         "DataView": "$global/",
30         "Uint8Array": "$global/",
31         "Map": "$global/",
32         "Set": "$global/",
33         # the JavaScript domain has no exception type for some reason...
34         "Error": "$global/",
35         "Function": "$global/",
36         "Promise": "$global/",
37         "FileSystemDirectoryHandle": "API/",
38     },
39     "js:method": {
40         "Iterator.next": "$reference/Iteration_protocols#next",
41         "AsyncIterator.next": "$reference/Iteration_protocols#next_2",
42         "Generator.next": "$global/",
43         "Generator.throw": "$global/",
44         "Generator.return": "$global/",
45         "AsyncGenerator.next": "$global/",
46         "AsyncGenerator.throw": "$global/",
47         "AsyncGenerator.return": "$global/",
48         "Response.clone": "API/",
49         "Response.arrayBuffer": "API/",
50         "EventTarget.addEventListener": "API/",
51         "EventTarget.removeEventListener": "API/",
52         "Promise.then": "$global/",
53         "Promise.catch": "$global/",
54         "Promise.finally": "$global/",
55         "Function.apply": "$global/",
56         "Function.bind": "$global/",
57         "Function.call": "$global/",
58     },
59     "js:data": {
60         "Iterable": "$reference/Iteration_protocols#the_iterable_protocol",
61         "IteratorResult": "$reference/Iteration_protocols#next",
62         "Iterator": "$reference/Iteration_protocols#the_iterator_protocol",
63         "AsyncIterator": "$reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols",
64         "Symbol.asyncIterator": "$global/",
65         "Symbol.iterator": "$global/",
66         "Symbol.toStringTag": "$global/",
67         "FinalizationRegistry": "$global/",
68         "globalThis": "$global/",
69         "NaN": "$global/",
70         "undefined": "$global/",
71         "BigInt": "$global/",
72         "Number": "$global/",
73         "String": "$global/",
74         "Boolean": "$global/",
75         "Object": "$global/",
76         "Number.MAX_SAFE_INTEGER": "$global/",
77         "null": "$reference/Operators/",
78         "Response": "API/",
79         "TypedArray.BYTES_PER_ELEMENT": "$global/",
80     },
81     "js:attribute": {
82         "TypedArray.byteLength": "$global/",
83         "Response.type": "API/",
84         "Response.url": "API/",
85         "Response.statusText": "API/",
86         "Response.bodyUsed": "API/",
87         "Response.ok": "API/",
88         "Response.redirected": "API/",
89         "Response.status": "API/",
90     },
91     "std:label": {"async function": "$reference/Statements/async_function"},
92 }
93 
94 JSDATA = set(DATA["js:data"].keys())
95 JSDATA.update([x.lower() for x in JSDATA])
96 JSDATA.add("void")
97 JSDATA.add("any")
98 JSCLASS = set(DATA["js:class"].keys())
99 
100 # Each entry is a four tuple:
101 # (project_name, project_version, url, link_text)
102 #
103 # If link_text is "-" the original name of the xref will be used as the link
104 # text which is good enough for us.
105 PROJECT_NAME = "MDN docs"
106 PROJECT_VERSION = ""  # MDN docs are not really versioned
107 USE_NAME_AS_LINK_TEXT = "-"
108 
109 INVDATA: dict[str, dict[str, tuple[str, str, str, str]]] = {}
110 for type, entries in DATA.items():
111     type_values = INVDATA.setdefault(type, {})
112     for key, value in entries.items():
113         value = value.replace("$reference", "JavaScript/Reference")
114         value = value.replace("$global", "JavaScript/Reference/Global_Objects")
115         if value.endswith("/"):
116             value += key.replace(".", "/")
117         url = f"https://developer.mozilla.org/en-US/docs/Web/{value}"
118         type_values[key] = (PROJECT_NAME, PROJECT_VERSION, url, USE_NAME_AS_LINK_TEXT)
119         type_values[key.lower()] = (
120             PROJECT_NAME,
121             PROJECT_VERSION,
122             url,
123             USE_NAME_AS_LINK_TEXT,
124         )
125 
126 for key, url in [
127     ("void", "https://www.typescriptlang.org/docs/handbook/2/functions.html#void"),
128     ("any", "https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any"),
129 ]:
130     INVDATA["js:data"][key] = (
131         "typescript docs",
132         "",
133         url,
134         "-",
135     )
136 
137 for key in ["stdin", "stdout", "stderr"]:
138     INVDATA["js:data"][f"process.{key}"] = (
139         "node docs",
140         "",
141         f"https://nodejs.org/api/process.html#process{key}",
142         "-",
143     )
144 
145 
146 def add_mdn_xrefs(app: Sphinx) -> None:
147     """Add cross referencing to Mozilla Developer Network documentation"""
148     inventories = InventoryAdapter(app.builder.env)
149     inventories.named_inventory["mdn"] = INVDATA
150     for type, objects in INVDATA.items():
151         inventories.main_inventory.setdefault(type, {}).update(objects)
152 
153 
154 __all__ = ["add_mdn_xrefs"]
155
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py b/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py
--- a/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py
+++ b/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py
@@ -55,6 +55,25 @@
         "Function.apply": "$global/",
         "Function.bind": "$global/",
         "Function.call": "$global/",
+        "Array.join": "$global/",
+        "Array.slice": "$global/",
+        "Array.lastIndexOf": "$global/",
+        "Array.indexOf": "$global/",
+        "Array.forEach": "$global/",
+        "Array.map": "$global/",
+        "Array.filter": "$global/",
+        "Array.reduce": "$global/",
+        "Array.reduceRight": "$global/",
+        "Array.some": "$global/",
+        "Array.every": "$global/",
+        "Array.at": "$global/",
+        "Array.concat": "$global/",
+        "Array.includes": "$global/",
+        "Array.entries": "$global/",
+        "Array.keys": "$global/",
+        "Array.values": "$global/",
+        "Array.find": "$global/",
+        "Array.findIndex": "$global/",
     },
     "js:data": {
         "Iterable": "$reference/Iteration_protocols#the_iterable_protocol",

{"golden_diff": "diff --git a/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py b/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py\n--- a/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py\n+++ b/docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py\n@@ -55,6 +55,25 @@\n         \"Function.apply\": \"$global/\",\n         \"Function.bind\": \"$global/\",\n         \"Function.call\": \"$global/\",\n+        \"Array.join\": \"$global/\",\n+        \"Array.slice\": \"$global/\",\n+        \"Array.lastIndexOf\": \"$global/\",\n+        \"Array.indexOf\": \"$global/\",\n+        \"Array.forEach\": \"$global/\",\n+        \"Array.map\": \"$global/\",\n+        \"Array.filter\": \"$global/\",\n+        \"Array.reduce\": \"$global/\",\n+        \"Array.reduceRight\": \"$global/\",\n+        \"Array.some\": \"$global/\",\n+        \"Array.every\": \"$global/\",\n+        \"Array.at\": \"$global/\",\n+        \"Array.concat\": \"$global/\",\n+        \"Array.includes\": \"$global/\",\n+        \"Array.entries\": \"$global/\",\n+        \"Array.keys\": \"$global/\",\n+        \"Array.values\": \"$global/\",\n+        \"Array.find\": \"$global/\",\n+        \"Array.findIndex\": \"$global/\",\n     },\n     \"js:data\": {\n         \"Iterable\": \"$reference/Iteration_protocols#the_iterable_protocol\",\n", "issue": "Proxied JS method.apply(context, list) fail while method(*list) doesn't\n## \ud83d\udc1b Bug\r\n\r\nWhile working on [this PyScript issue](https://github.com/pyscript/pyscript/pull/1459) I've noticed that `context.method.apply(context, list)` doesn't work while `context.method(*list)` does.\r\n\r\nI don't mind using the latter as that's also more Pythonic but that might surprise JS developers using Pyodide proxies that mimic JS APIs.\r\n\r\n### To Reproduce\r\n\r\n```python\r\nimport js\r\nclassList = js.document.body.classList\r\nclassList.add.apply(classList, [\"a\", \"b\"])\r\n```\r\n\r\n### Expected behavior\r\n\r\nThe method should be invoked with *n* arguments as by JS specs.\r\n\r\n### Environment\r\n\r\n- Pyodide Version<!-- (e.g. 1.8.1) -->: latest\r\n- Browser version<!-- (e.g. Chrome 95.0.4638.54) -->: any\r\n- Any other relevant information: nope\r\n\r\n<!-- If you are building Pyodide by yourself, please also include these information: -->\r\n\r\n<!--\r\n- Commit hash of Pyodide git repository:\r\n- Build environment<!--(e.g. Ubuntu 18.04, pyodide/pyodide-env:19 docker)- ->:\r\n-->\r\n\r\n### Additional context\r\n\r\nHappy to have it as won't fix but at least there's a related issue that explain the *gotcha*.\r\n\n", "before_files": [{"content": "from sphinx.application import Sphinx\nfrom sphinx.ext.intersphinx import InventoryAdapter\n\nDATA = {\n    \"js:function\": {\n        \"setTimeout\": \"API/\",\n        \"clearTimeout\": \"API/\",\n        \"setInterval\": \"API/\",\n        \"clearInterval\": \"API/\",\n        \"fetch\": \"API/\",\n        \"eval\": \"$global/\",\n        \"Object.fromEntries\": \"$global/\",\n        \"Reflect.ownKeys\": \"$global/\",\n        \"Array.from\": \"$global/\",\n        \"Atomics.wait\": \"$global/\",\n    },\n    \"js:class\": {\n        \"Array\": \"$global/\",\n        \"NodeList\": \"API/\",\n        \"HTMLCollection\": \"API/\",\n        \"Generator\": \"$global/\",\n        \"AsyncGenerator\": \"$global/\",\n        \"Date\": \"$global/\",\n        \"ArrayBuffer\": \"$global/\",\n        \"SharedArrayBuffer\": \"$global/\",\n        \"TypedArray\": \"$global/\",\n        \"TextEncoder\": \"$global/\",\n        \"TextDecoder\": \"$global/\",\n        \"DataView\": \"$global/\",\n        \"Uint8Array\": \"$global/\",\n        \"Map\": \"$global/\",\n        \"Set\": \"$global/\",\n        # the JavaScript domain has no exception type for some reason...\n        \"Error\": \"$global/\",\n        \"Function\": \"$global/\",\n        \"Promise\": \"$global/\",\n        \"FileSystemDirectoryHandle\": \"API/\",\n    },\n    \"js:method\": {\n        \"Iterator.next\": \"$reference/Iteration_protocols#next\",\n        \"AsyncIterator.next\": \"$reference/Iteration_protocols#next_2\",\n        \"Generator.next\": \"$global/\",\n        \"Generator.throw\": \"$global/\",\n        \"Generator.return\": \"$global/\",\n        \"AsyncGenerator.next\": \"$global/\",\n        \"AsyncGenerator.throw\": \"$global/\",\n        \"AsyncGenerator.return\": \"$global/\",\n        \"Response.clone\": \"API/\",\n        \"Response.arrayBuffer\": \"API/\",\n        \"EventTarget.addEventListener\": \"API/\",\n        \"EventTarget.removeEventListener\": \"API/\",\n        \"Promise.then\": \"$global/\",\n        \"Promise.catch\": \"$global/\",\n        \"Promise.finally\": \"$global/\",\n        \"Function.apply\": \"$global/\",\n        \"Function.bind\": \"$global/\",\n        \"Function.call\": \"$global/\",\n    },\n    \"js:data\": {\n        \"Iterable\": \"$reference/Iteration_protocols#the_iterable_protocol\",\n        \"IteratorResult\": \"$reference/Iteration_protocols#next\",\n        \"Iterator\": \"$reference/Iteration_protocols#the_iterator_protocol\",\n        \"AsyncIterator\": \"$reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols\",\n        \"Symbol.asyncIterator\": \"$global/\",\n        \"Symbol.iterator\": \"$global/\",\n        \"Symbol.toStringTag\": \"$global/\",\n        \"FinalizationRegistry\": \"$global/\",\n        \"globalThis\": \"$global/\",\n        \"NaN\": \"$global/\",\n        \"undefined\": \"$global/\",\n        \"BigInt\": \"$global/\",\n        \"Number\": \"$global/\",\n        \"String\": \"$global/\",\n        \"Boolean\": \"$global/\",\n        \"Object\": \"$global/\",\n        \"Number.MAX_SAFE_INTEGER\": \"$global/\",\n        \"null\": \"$reference/Operators/\",\n        \"Response\": \"API/\",\n        \"TypedArray.BYTES_PER_ELEMENT\": \"$global/\",\n    },\n    \"js:attribute\": {\n        \"TypedArray.byteLength\": \"$global/\",\n        \"Response.type\": \"API/\",\n        \"Response.url\": \"API/\",\n        \"Response.statusText\": \"API/\",\n        \"Response.bodyUsed\": \"API/\",\n        \"Response.ok\": \"API/\",\n        \"Response.redirected\": \"API/\",\n        \"Response.status\": \"API/\",\n    },\n    \"std:label\": {\"async function\": \"$reference/Statements/async_function\"},\n}\n\nJSDATA = set(DATA[\"js:data\"].keys())\nJSDATA.update([x.lower() for x in JSDATA])\nJSDATA.add(\"void\")\nJSDATA.add(\"any\")\nJSCLASS = set(DATA[\"js:class\"].keys())\n\n# Each entry is a four tuple:\n# (project_name, project_version, url, link_text)\n#\n# If link_text is \"-\" the original name of the xref will be used as the link\n# text which is good enough for us.\nPROJECT_NAME = \"MDN docs\"\nPROJECT_VERSION = \"\"  # MDN docs are not really versioned\nUSE_NAME_AS_LINK_TEXT = \"-\"\n\nINVDATA: dict[str, dict[str, tuple[str, str, str, str]]] = {}\nfor type, entries in DATA.items():\n    type_values = INVDATA.setdefault(type, {})\n    for key, value in entries.items():\n        value = value.replace(\"$reference\", \"JavaScript/Reference\")\n        value = value.replace(\"$global\", \"JavaScript/Reference/Global_Objects\")\n        if value.endswith(\"/\"):\n            value += key.replace(\".\", \"/\")\n        url = f\"https://developer.mozilla.org/en-US/docs/Web/{value}\"\n        type_values[key] = (PROJECT_NAME, PROJECT_VERSION, url, USE_NAME_AS_LINK_TEXT)\n        type_values[key.lower()] = (\n            PROJECT_NAME,\n            PROJECT_VERSION,\n            url,\n            USE_NAME_AS_LINK_TEXT,\n        )\n\nfor key, url in [\n    (\"void\", \"https://www.typescriptlang.org/docs/handbook/2/functions.html#void\"),\n    (\"any\", \"https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any\"),\n]:\n    INVDATA[\"js:data\"][key] = (\n        \"typescript docs\",\n        \"\",\n        url,\n        \"-\",\n    )\n\nfor key in [\"stdin\", \"stdout\", \"stderr\"]:\n    INVDATA[\"js:data\"][f\"process.{key}\"] = (\n        \"node docs\",\n        \"\",\n        f\"https://nodejs.org/api/process.html#process{key}\",\n        \"-\",\n    )\n\n\ndef add_mdn_xrefs(app: Sphinx) -> None:\n    \"\"\"Add cross referencing to Mozilla Developer Network documentation\"\"\"\n    inventories = InventoryAdapter(app.builder.env)\n    inventories.named_inventory[\"mdn\"] = INVDATA\n    for type, objects in INVDATA.items():\n        inventories.main_inventory.setdefault(type, {}).update(objects)\n\n\n__all__ = [\"add_mdn_xrefs\"]\n", "path": "docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py"}], "after_files": [{"content": "from sphinx.application import Sphinx\nfrom sphinx.ext.intersphinx import InventoryAdapter\n\nDATA = {\n    \"js:function\": {\n        \"setTimeout\": \"API/\",\n        \"clearTimeout\": \"API/\",\n        \"setInterval\": \"API/\",\n        \"clearInterval\": \"API/\",\n        \"fetch\": \"API/\",\n        \"eval\": \"$global/\",\n        \"Object.fromEntries\": \"$global/\",\n        \"Reflect.ownKeys\": \"$global/\",\n        \"Array.from\": \"$global/\",\n        \"Atomics.wait\": \"$global/\",\n    },\n    \"js:class\": {\n        \"Array\": \"$global/\",\n        \"NodeList\": \"API/\",\n        \"HTMLCollection\": \"API/\",\n        \"Generator\": \"$global/\",\n        \"AsyncGenerator\": \"$global/\",\n        \"Date\": \"$global/\",\n        \"ArrayBuffer\": \"$global/\",\n        \"SharedArrayBuffer\": \"$global/\",\n        \"TypedArray\": \"$global/\",\n        \"TextEncoder\": \"$global/\",\n        \"TextDecoder\": \"$global/\",\n        \"DataView\": \"$global/\",\n        \"Uint8Array\": \"$global/\",\n        \"Map\": \"$global/\",\n        \"Set\": \"$global/\",\n        # the JavaScript domain has no exception type for some reason...\n        \"Error\": \"$global/\",\n        \"Function\": \"$global/\",\n        \"Promise\": \"$global/\",\n        \"FileSystemDirectoryHandle\": \"API/\",\n    },\n    \"js:method\": {\n        \"Iterator.next\": \"$reference/Iteration_protocols#next\",\n        \"AsyncIterator.next\": \"$reference/Iteration_protocols#next_2\",\n        \"Generator.next\": \"$global/\",\n        \"Generator.throw\": \"$global/\",\n        \"Generator.return\": \"$global/\",\n        \"AsyncGenerator.next\": \"$global/\",\n        \"AsyncGenerator.throw\": \"$global/\",\n        \"AsyncGenerator.return\": \"$global/\",\n        \"Response.clone\": \"API/\",\n        \"Response.arrayBuffer\": \"API/\",\n        \"EventTarget.addEventListener\": \"API/\",\n        \"EventTarget.removeEventListener\": \"API/\",\n        \"Promise.then\": \"$global/\",\n        \"Promise.catch\": \"$global/\",\n        \"Promise.finally\": \"$global/\",\n        \"Function.apply\": \"$global/\",\n        \"Function.bind\": \"$global/\",\n        \"Function.call\": \"$global/\",\n        \"Array.join\": \"$global/\",\n        \"Array.slice\": \"$global/\",\n        \"Array.lastIndexOf\": \"$global/\",\n        \"Array.indexOf\": \"$global/\",\n        \"Array.forEach\": \"$global/\",\n        \"Array.map\": \"$global/\",\n        \"Array.filter\": \"$global/\",\n        \"Array.reduce\": \"$global/\",\n        \"Array.reduceRight\": \"$global/\",\n        \"Array.some\": \"$global/\",\n        \"Array.every\": \"$global/\",\n        \"Array.at\": \"$global/\",\n        \"Array.concat\": \"$global/\",\n        \"Array.includes\": \"$global/\",\n        \"Array.entries\": \"$global/\",\n        \"Array.keys\": \"$global/\",\n        \"Array.values\": \"$global/\",\n        \"Array.find\": \"$global/\",\n        \"Array.findIndex\": \"$global/\",\n    },\n    \"js:data\": {\n        \"Iterable\": \"$reference/Iteration_protocols#the_iterable_protocol\",\n        \"IteratorResult\": \"$reference/Iteration_protocols#next\",\n        \"Iterator\": \"$reference/Iteration_protocols#the_iterator_protocol\",\n        \"AsyncIterator\": \"$reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols\",\n        \"Symbol.asyncIterator\": \"$global/\",\n        \"Symbol.iterator\": \"$global/\",\n        \"Symbol.toStringTag\": \"$global/\",\n        \"FinalizationRegistry\": \"$global/\",\n        \"globalThis\": \"$global/\",\n        \"NaN\": \"$global/\",\n        \"undefined\": \"$global/\",\n        \"BigInt\": \"$global/\",\n        \"Number\": \"$global/\",\n        \"String\": \"$global/\",\n        \"Boolean\": \"$global/\",\n        \"Object\": \"$global/\",\n        \"Number.MAX_SAFE_INTEGER\": \"$global/\",\n        \"null\": \"$reference/Operators/\",\n        \"Response\": \"API/\",\n        \"TypedArray.BYTES_PER_ELEMENT\": \"$global/\",\n    },\n    \"js:attribute\": {\n        \"TypedArray.byteLength\": \"$global/\",\n        \"Response.type\": \"API/\",\n        \"Response.url\": \"API/\",\n        \"Response.statusText\": \"API/\",\n        \"Response.bodyUsed\": \"API/\",\n        \"Response.ok\": \"API/\",\n        \"Response.redirected\": \"API/\",\n        \"Response.status\": \"API/\",\n    },\n    \"std:label\": {\"async function\": \"$reference/Statements/async_function\"},\n}\n\nJSDATA = set(DATA[\"js:data\"].keys())\nJSDATA.update([x.lower() for x in JSDATA])\nJSDATA.add(\"void\")\nJSDATA.add(\"any\")\nJSCLASS = set(DATA[\"js:class\"].keys())\n\n# Each entry is a four tuple:\n# (project_name, project_version, url, link_text)\n#\n# If link_text is \"-\" the original name of the xref will be used as the link\n# text which is good enough for us.\nPROJECT_NAME = \"MDN docs\"\nPROJECT_VERSION = \"\"  # MDN docs are not really versioned\nUSE_NAME_AS_LINK_TEXT = \"-\"\n\nINVDATA: dict[str, dict[str, tuple[str, str, str, str]]] = {}\nfor type, entries in DATA.items():\n    type_values = INVDATA.setdefault(type, {})\n    for key, value in entries.items():\n        value = value.replace(\"$reference\", \"JavaScript/Reference\")\n        value = value.replace(\"$global\", \"JavaScript/Reference/Global_Objects\")\n        if value.endswith(\"/\"):\n            value += key.replace(\".\", \"/\")\n        url = f\"https://developer.mozilla.org/en-US/docs/Web/{value}\"\n        type_values[key] = (PROJECT_NAME, PROJECT_VERSION, url, USE_NAME_AS_LINK_TEXT)\n        type_values[key.lower()] = (\n            PROJECT_NAME,\n            PROJECT_VERSION,\n            url,\n            USE_NAME_AS_LINK_TEXT,\n        )\n\nfor key, url in [\n    (\"void\", \"https://www.typescriptlang.org/docs/handbook/2/functions.html#void\"),\n    (\"any\", \"https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any\"),\n]:\n    INVDATA[\"js:data\"][key] = (\n        \"typescript docs\",\n        \"\",\n        url,\n        \"-\",\n    )\n\nfor key in [\"stdin\", \"stdout\", \"stderr\"]:\n    INVDATA[\"js:data\"][f\"process.{key}\"] = (\n        \"node docs\",\n        \"\",\n        f\"https://nodejs.org/api/process.html#process{key}\",\n        \"-\",\n    )\n\n\ndef add_mdn_xrefs(app: Sphinx) -> None:\n    \"\"\"Add cross referencing to Mozilla Developer Network documentation\"\"\"\n    inventories = InventoryAdapter(app.builder.env)\n    inventories.named_inventory[\"mdn\"] = INVDATA\n    for type, objects in INVDATA.items():\n        inventories.main_inventory.setdefault(type, {}).update(objects)\n\n\n__all__ = [\"add_mdn_xrefs\"]\n", "path": "docs/sphinx_pyodide/sphinx_pyodide/mdn_xrefs.py"}]}