diff --git a/.opencode/plans/graphs-links.md b/.opencode/plans/graphs-links.md new file mode 100644 index 0000000..179ce99 --- /dev/null +++ b/.opencode/plans/graphs-links.md @@ -0,0 +1,53 @@ +## Internal methods + +Examples of Internal methods not being connected - + +1. `[[DefineOwnProperty]]` - + +* /abstract-operations.html#sec-createdataproperty - `7.3.5 CreateDataProperty` - uses generic `O.[[DefineOwnProperty]]` +* /ordinary-and-exotic-objects-behaviours.html#sec-array-exotic-objects-defineownproperty-p-desc - `10.4.2.1 [[DefineOwnProperty]]` -Array has custom `[[DefineOwnProperty]]`. +* /ordinary-and-exotic-objects-behaviours.html#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc - `10.1.6 [[DefineOwnProperty]]` - Ordinary definition + +2. `[[GetOwnProperty]]` - Similar, defined for proxies + + +Written in html as (both consumer + definition) - + +[[DefineOwnProperty]] + +How it works internally for references - + +ecmarkup.js - `showReferencesFor(entry)` - uses `entry.referencingIds` from biblio. + + +Abstract methods list - + +File: /ecmascript-data-types-and-values.html#table-essential-internal-methods + +[[GetPrototypeOf]] +[[SetPrototypeOf]] +[[IsExtensible]] +[[PreventExtensions]] +[[GetOwnProperty]] +[[DefineOwnProperty]] +[[HasProperty]] +[[Get]] +[[Set]] +[[Delete]] +[[OwnPropertyKeys]] + +File: /ecmascript-data-types-and-values.html#table-additional-essential-internal-methods-of-function-objects +[[Call]] +[[Construct]] + +*Connect these to the implementations* + +Regex to search all - +``` +\[\[GetPrototypeOf\]\]|\[\[SetPrototypeOf\]\]|\[\[IsExtensible\]\]|\[\[PreventExtensions\]\]|\[\[GetOwnProperty\]\]|\[\[DefineOwnProperty\]\]|\[\[HasProperty\]\]|\[\[Get\]\]|\[\[Set\]\]|\[\[Delete\]\]|\[\[OwnPropertyKeys\]\]|\[\[Call\]\]|\[\[Construct\]\] +``` + +Problems - +1. `[[Get]]`, `[[Set]]` - are also used as Property Attributes (/ecmascript-data-types-and-values.html#sec-property-attributes). Distinguish them. +2. Mark all Property Attributes. + diff --git a/setup/html-add-internal-method-link.ts b/setup/html-add-internal-method-link.ts new file mode 100644 index 0000000..74c1e29 --- /dev/null +++ b/setup/html-add-internal-method-link.ts @@ -0,0 +1,56 @@ +#!/usr/bin/env bun +import type { CheerioAPI } from "cheerio"; +import * as cheerio from "cheerio"; +import { readFileSync, writeFileSync } from "fs"; +import { fileURLToPath } from "url"; + +// Resolve the path to the HTML file (relative to repo root) +const htmlUrl = new URL( + "../spec-built/multipage/ecmascript-data-types-and-values.html", + import.meta.url, +); +const htmlPath = fileURLToPath(htmlUrl); + +// Load and parse the HTML +const htmlString = readFileSync(htmlPath, "utf-8"); +const htmlCheerioApi = cheerio.load(htmlString); + +/** + * Script to add unique `id` attributes to internal method links. + * + * It scans the ECMA spec HTML tables `#table-essential-internal-methods` + * and `#table-additional-essential-internal-methods-of-function-objects` + * and adds an `id` to the first `` element found in + * the first `` of each row. The generated id follows the pattern: + * `ask262-internal-method-` where `` is the text + * content of the `` element with surrounding brackets stripped. + * + * @param $ - The Cheerio parsing instance. + */ +function addInternalMethodIds($: CheerioAPI): void { + // Find the first inside the first of each row + // in the two internal‑method tables and add a unique `id` attribute. + $( + "#table-essential-internal-methods tr > td:first-child, " + + "#table-additional-essential-internal-methods-of-function-objects tr > td:first-child", + ).each((_, td: any) => { + const $td = $(td); + const $var = $td.find("var.field").first(); + if ($var.length) { + const rawText = $var.text().trim(); + // Remove any square brackets from the extracted text + const text = rawText.replace(/[[\]]/g, ""); + const id = `ask262-internal-method-${text}`; + $var.attr("id", id); + } + }); +} + +// Execute core logic +addInternalMethodIds(htmlCheerioApi); + +// Write the updated HTML back +writeFileSync(htmlPath, htmlCheerioApi.html(), "utf-8"); +console.log( + `Updated ${htmlPath} – added id attributes to elements.`, +); diff --git a/spec-built/multipage/ecmascript-data-types-and-values.html b/spec-built/multipage/ecmascript-data-types-and-values.html index e6caac4..0e4fc03 100644 --- a/spec-built/multipage/ecmascript-data-types-and-values.html +++ b/spec-built/multipage/ecmascript-data-types-and-values.html @@ -1212,7 +1212,7 @@ - [[GetPrototypeOf]] + [[GetPrototypeOf]] ( ) Object | Null @@ -1223,7 +1223,7 @@ - [[SetPrototypeOf]] + [[SetPrototypeOf]] (Object | Null) Boolean @@ -1234,7 +1234,7 @@ - [[IsExtensible]] + [[IsExtensible]] ( ) Boolean @@ -1245,7 +1245,7 @@ - [[PreventExtensions]] + [[PreventExtensions]] ( ) Boolean @@ -1256,7 +1256,7 @@ - [[GetOwnProperty]] + [[GetOwnProperty]] (propertyKey) Undefined | Property Descriptor @@ -1267,7 +1267,7 @@ - [[DefineOwnProperty]] + [[DefineOwnProperty]] (propertyKey, PropertyDescriptor) Boolean @@ -1278,7 +1278,7 @@ - [[HasProperty]] + [[HasProperty]] (propertyKey) Boolean @@ -1289,7 +1289,7 @@ - [[Get]] + [[Get]] (propertyKey, Receiver) any @@ -1300,7 +1300,7 @@ - [[Set]] + [[Set]] (propertyKey, value, Receiver) Boolean @@ -1311,7 +1311,7 @@ - [[Delete]] + [[Delete]] (propertyKey) Boolean @@ -1322,7 +1322,7 @@ - [[OwnPropertyKeys]] + [[OwnPropertyKeys]] ( ) List of property keys @@ -1351,7 +1351,7 @@ - [[Call]] + [[Call]] (any, a List of any) any @@ -1362,7 +1362,7 @@ - [[Construct]] + [[Construct]] (a List of any, Object) Object