Skip to content

Commit 895671e

Browse files
authored
Merge pull request #32 from bldl/ecmarkup-section
imported updated version of optimization-section
2 parents eb87ab8 + a6f0c55 commit 895671e

File tree

1 file changed

+72
-50
lines changed

1 file changed

+72
-50
lines changed

upsert-tutorial/index.html

Lines changed: 72 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ <h3 id="testing-the-implementation">Testing the Implementation</h3>
10641064
</section>
10651065

10661066
<section class="collapsible" id="issues">
1067+
10671068
<h2>Issues With the Original Proposal</h2>
10681069
<p>The proposal we have implemented provides a flexible solution by allowing both an <code>update</code> and an <code>insert</code> function. While flexibility is generally a good thing, here it adds unnecessary complexity to the usage of <code>upsert</code>. In other words, flexibility comes here at the expense of simplicity and ease of use which are very important for widespread adoption in programming languages.</p>
10691070
<p>The most likely primary, in-demand use case of the <code>upsert</code> method is when a developer wants to check whether a <code>key</code> exists and, if it doesn&#39;t, to insert it into the map.
@@ -1268,14 +1269,13 @@ <h3 id="step-5--6---insert-the-new-key-value-pair">Step 5 &amp; 6 - Insert the n
12681269
</section>
12691270

12701271
<section class="collapsible" id="ecmarkup">
1271-
<h2>Writing the Specification in Ecmarkup</h2>
1272+
<h2>Rendering the New Specification Text Using _Ecmarkup_</h2>
12721273
<div class="content-body">
1273-
<p>In this section, we will cover how to install and use Ecmarkup to write specifications for proposals.
1274-
Ecmarkup is a markup language that is designed for technical specifications.
1275-
This allows the authors to visualize and format complex algorithms, clauses and terms in a way that is both readable and structured.
1276-
Regarding JavaScript-proposals, Ecmarkup provides a solid framework to document new algorithms or implementations so they align with the ECMAScript®-standards. </p>
1277-
<p> We will start with setting up the necessary tools to be able to use Ecmarkup, such as Node.js and Ecmarkup itself.
1278-
Furthermore, we will check out how to format specification using Ecmarkup before guiding you through how to build your specification into an HTML document. </p>
1274+
<p>In this section, we will explain how to use <a href="https://github.com/tc39/ecmarkup"><em>Ecmarkup</em></a>, which is a specialized markup language, to write and format <strong>specification documents</strong> for ECMAScript® and other web standards, so that they align with the formatting of these standards documents.
1275+
<em>Ecmarkup</em> is specifically designed for technical specifications, and allows authors to visualize and format complex algorithms, clauses and terms in a way that is both readable and structured. If you visit the <a href="https://tc39.es/ecma262/" target="_blank">ECMA-262 official webpage</a>, you can read the ECMAScript® specification with hyperlinks to used terms, algorithms, and syntax definitions. This enables easy navigation between different sections and components of the specification. These specifications are made with <em>Ecmarkup</em>.</p>
1276+
<p>We will explain how to install and use <em>Ecmarkup</em> to render proposal specifications, and will write our updated <code>upsert</code> proposal specification using <em>Ecmarkup</em>.
1277+
We will start with setting up the necessary tools to be able to use <em>Ecmarkup</em>: Node.js and <em>Ecmarkup</em> itself. </p>
1278+
12791279
<ul>
12801280
<li><p><strong>Installing Node.js and Node Package Manager</strong></p>
12811281
<div class="tab-container">
@@ -1286,27 +1286,27 @@ <h2>Writing the Specification in Ecmarkup</h2>
12861286
</div>
12871287
<div class="tab-content active" id="ecmarkup-windows-tab">
12881288
<ol>
1289-
<li><p>First go to Node.js official website (<a href="https://nodejs.org/en">https://nodejs.org/en</a>), and download the Windows Installer (recommended version).</p>
1289+
<li><p>Download the Windows installer from the <a href="https://nodejs.org/en">Node.js webpage</a>.</p>
12901290
</li>
1291-
<li><p>Run the installer and follow the instructions (make sure to check the box that says &quot;Automatically install necessary tools&quot;).</p>
1291+
<li><p>Run the installer and follow the instructions. Make sure to check the box that says <i>Automatically install necessary tools</i>.</p>
12921292
</li>
1293-
<li><p>Verify installation by opening Command Prompt and typing:</p>
1293+
<li><p>Verify the installation by executing the following in the command prompt:</p>
12941294
</li>
12951295
</ol>
12961296
<pre><code class="language-sh">node -v
12971297
npm -v
12981298
</code></pre>
1299-
<p>This should return the versions of Node.js and npm.</p>
1299+
<p>This should output the versions of Node.js and npm.</p>
13001300
</div>
13011301
<div class="tab-content" id="ecmarkup-mac-tab">
13021302
<ol>
13031303
<li>Open Terminal</li>
1304-
<li>Install Node.js via Homebrew by running the following command:</li>
1304+
<li>Install Node.js via <a href="https://brew.sh/">Homebrew</a> by running the following command:</li>
13051305
</ol>
13061306
<pre><code class="language-sh">brew install node
13071307
</code></pre>
13081308
<ol start="3">
1309-
<li>Verify installation by typing:</li>
1309+
<li>Verify installation by executing:</li>
13101310
</ol>
13111311
<pre><code class="language-sh">node -v
13121312
npm -v
@@ -1315,12 +1315,12 @@ <h2>Writing the Specification in Ecmarkup</h2>
13151315
<div class="tab-content" id="ecmarkup-linux-tab">
13161316
<ol>
13171317
<li>Open Terminal</li>
1318-
<li>Update your package list:</li>
1318+
<li>Update the package list:</li>
13191319
</ol>
13201320
<pre><code class="language-sh">sudo apt update
13211321
</code></pre>
13221322
<ol start="3">
1323-
<li>Install Node.js by running:</li>
1323+
<li>Install Node.js by executing:</li>
13241324
</ol>
13251325
<pre><code class="language-sh">sudo apt install node.js spm
13261326
</code></pre>
@@ -1336,23 +1336,24 @@ <h2>Writing the Specification in Ecmarkup</h2>
13361336
</li>
13371337
<li><p><strong>Installing <a href="https://tc39.es/ecmarkup/" target="_blank">Ecmarkup</a></strong></p>
13381338
<ul>
1339-
<li>Windows/Mac/Linux<ol>
1340-
<li>Open Command Prompt (Windows) or Terminal (Mac/Linux)</li>
1341-
<li>Run the following command to install Ecmarkup globally:</li>
1339+
<li><strong>Windows</strong> / <strong>Mac</strong> / <strong>Linux</strong><ol>
1340+
<li>Open Command Prompt (Windows) or Terminal (Mac/Linux).</li>
1341+
<li>Run the following command to install <em>Ecmarkup</em> globally:</li>
13421342
</ol>
13431343
<pre><code class="language-sh">npm install -g ecmarkup
13441344
</code></pre>
13451345
<ol start="3">
1346-
<li>Verify that Ecmarkup has been installed by typing:</li>
1346+
<li>Verify that <em>Ecmarkup</em> has been installed by executing:</li>
13471347
</ol>
13481348
<pre><code class="language-sh">ecmarkup --version
13491349
</code></pre>
1350-
<p>You have now installed Ecmarkup.</p>
1350+
<p>You have now successfully installed <em>Ecmarkup</em>.</p>
13511351
</li>
13521352
</ul>
13531353
</li>
1354-
<li><p><strong>How to write ecmarkup</strong></p>
1355-
<p>Ecmarkup is a markup language used for writing technical specifications. It has a syntax similar to <code>HTML</code>, making it intuitive for those familiar with web development. Here&#39;s a simple example of what an algorithm in a <code>.emu</code> file looks like (<code>.emu</code> is the file ending of an ecmarkup file):</p>
1354+
<li><p><strong>How to write specifications using Ecmarkup</strong></p>
1355+
<p><em>Ecmarkup</em>&#39;s syntax is similar to HTML - this makes it intuitive for most web developers.
1356+
Files written using <em>Ecmakup</em> have extension <code>.emu</code>; here is a simple example of such a file.</p>
13561357
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
13571358
&lt;meta charset=&quot;utf8&quot;&gt;
13581359
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css&quot;&gt;
@@ -1364,7 +1365,7 @@ <h2>Writing the Specification in Ecmarkup</h2>
13641365
&lt;/pre&gt;
13651366

13661367
&lt;emu-clause id=&quot;sec-greater-than-five&quot;&gt;
1367-
&lt;h1&gt;greaterThanFive(_value_)&lt;/h1&gt;
1368+
&lt;h1&gt;greaterThanFive (_value_)&lt;/h1&gt;
13681369
&lt;p&gt;When the greaterThanFive method is called, the following steps are taken:&lt;/p&gt;
13691370
&lt;emu-alg&gt;
13701371
1. Let _x_ be _value_.
@@ -1377,28 +1378,48 @@ <h2>Writing the Specification in Ecmarkup</h2>
13771378
&lt;/emu-alg&gt;
13781379
&lt;/emu-clause&gt;
13791380
</code></pre>
1380-
<p><strong>Note:</strong> This is just an example of how an Ecmarkup file should be structured. The algorithm itself is illustrative and not a real-world example.</p>
1381+
<p><a href="https://bldl.github.io/upsert-tutorial/greaterThanFiveExample-spec/out.html">Here</a> is how this document will look like when &quot;compiled&quot; to an HTML presentation.</p>
1382+
<p>Please note that this is just an example of how an <em>Ecmarkup</em> file should be structured. The algorithm itself is illustrative and is not a real-world example.</p>
13811383
</li>
1382-
<li><p><strong>How to format spec text using Ecmarkup</strong></p>
1383-
<p>Formatting spec text using Ecmarkup involves understanding the differences between what each reperesents. ECMAScript® is a scripting language specification, while Ecmarkup is a specialized markup language used to write and format <strong>specification documents</strong> for ECMAScript® and other web standards.</p>
1384-
<ol>
1385-
<li><p><strong>Understanding why we need Ecmarkup</strong></p>
1386-
<p>Ecmarkup combines HTML-like tags with specific syntactic constructs to write formal specifications. If you visit the <a href="https://tc39.es/ecma262/" target="_blank">TC39 official website</a> for ECMA-262, you can read ECMAScript® with hyperlinks to used terms, algorithms, and syntax definitions, allowing for easy navigation between different sections and components of the specification. These specifications are made with Ecmarkup.</p>
1387-
</li>
1388-
<li><p><strong>Basic translation steps</strong></p>
1389-
<ul>
1390-
<li><code>&lt;emu-alg&gt;</code>: Defines an algorithm.</li>
1391-
<li><code>&lt;emu-clause&gt;</code>: Defines a clause/section in the specification.</li>
1392-
<li>Underscores are used to refer to variables (<code>_varname_</code>).</li>
1393-
<li><code>&lt;emu-xref&gt;</code>: Link to other sections, clauses or algorithms within the specification.</li>
1394-
<li><code>*someBoldText*</code>: Make bold text with <code>*</code>.</li>
1395-
<li>Use double square brackets (<code>[[...]]</code>) when documenting or referring to the internal, hidden mechanisms of objects that are not directly accessible in the JavaScript™ language but are crucial for the implementation and behavior of the object.</li>
1396-
</ul>
1397-
</li>
1398-
</ol>
1384+
<li><p><strong>How to Format Specification Text Using <em>Ecmarkup</em></strong></p>
13991385
</li>
1400-
<li><p>The function <code>upsert(key, callbackfn)</code> in ecmarkup (can also be found under the spec-folder in this proposal)</p>
1401-
<pre><code class="language-html"> &lt;!DOCTYPE html&gt;
1386+
</ul>
1387+
<p><em>Ecmarkup</em> combines HTML-like tags with specific syntactic constructs to write formal specifications.</p>
1388+
<table class="styled-table">
1389+
<thead>
1390+
<tr>
1391+
<th><em>Ecmarkup tag/syntax</em></th>
1392+
<th>explanation</th>
1393+
</tr>
1394+
</thead>
1395+
<tbody><tr>
1396+
<td><code>&lt;emu-alg&gt;</code></td>
1397+
<td>defines an algorithm</td>
1398+
</tr>
1399+
<tr>
1400+
<td><code>&lt;emu-clause&gt;</code></td>
1401+
<td>defines a clause/section in the specification</td>
1402+
</tr>
1403+
<tr>
1404+
<td><code>&lt;emu-xref&gt;</code></td>
1405+
<td>adding a link to a section, clause or an algorithm within the specification</td>
1406+
</tr>
1407+
<tr>
1408+
<td><code>[[ ... ]]</code> (<em>double square brackets</em>)</td>
1409+
<td>when documenting or referring to the internal hidden mechanisms of objects that are not directly accessible in the JavaScript™ language but are crucial for the implementation and behavior of the object</td>
1410+
</tr>
1411+
<tr>
1412+
<td><code>_varname_</code> (<em>underscores</em>)</td>
1413+
<td>referring to variables within the specification</td>
1414+
</tr>
1415+
<tr>
1416+
<td><code>*someBoldText*</code> (<em>asterisks</em>)</td>
1417+
<td>renders text in bold font</td>
1418+
</tr>
1419+
</tbody></table>
1420+
<p>The following is a demonstration of how we can write the new specification of the method <code>upsert(key, callbackfn)</code> using <em>Ecmarkup</em>. </p>
1421+
<pre><code>```html
1422+
&lt;!DOCTYPE html&gt;
14021423
&lt;meta charset=&quot;utf8&quot;&gt;
14031424
&lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css&quot;&gt;
14041425
&lt;script src=&quot;./spec.js&quot;&gt;&lt;/script&gt;
@@ -1422,20 +1443,21 @@ <h2>Writing the Specification in Ecmarkup</h2>
14221443
1. Return _e_.[[Value]].
14231444
&lt;/emu-alg&gt;
14241445
&lt;/emu-clause&gt;
1446+
```
14251447
</code></pre>
1426-
</li>
1427-
<li><p><strong>Building the spec</strong></p>
1428-
<p>To build the spec, use the following command:</p>
1429-
<pre><code class="language-sh"> ecmarkup spec.emu out.html
1448+
<ul>
1449+
<li><p><strong>Building the specification</strong></p>
1450+
<p>After we have written a specification, we can build it to render as an HTML file:</p>
1451+
<pre><code class="language-sh">node -e &#39;fs.mkdirSync(&quot;build&quot;, { recursive: true })&#39; &amp;&amp; ecmarkup --load-biblio @tc39/ecma262-biblio --verbose spec.emu build/out.html --lint-spec
14301452
</code></pre>
14311453
<p>In this command:</p>
14321454
<ul>
1433-
<li><code>spec.emu</code> is the source file where you have written your specification using Ecmarkup.</li>
1434-
<li><code>out.html</code> is the output file, which is a runnable HTML document.
1435-
To verify that your specification has been built correctly, simply drag-and-drop the <code>out.html</code> file into a web browser.</li>
1455+
<li><code>spec.emu</code> is the source file where we have written our specification using <em>Ecmarkup</em>,</li>
1456+
<li><code>out.html</code> is the output file, which is an HTML document. To verify that our specification has been built correctly, we can open the <a href="https://bldl.github.io/upsert-tutorial/callbackfn-spec/specCallbackfn.html"><code>out.html</code></a> file in a web browser and visually inspect it.</li>
14361457
</ul>
14371458
</li>
14381459
</ul>
1460+
<p>Note that you can find the official <em>Ecmarkup</em> user guide <a href="https://tc39.es/ecmarkup/">here</a>.</p>
14391461

14401462
</div>
14411463
</section>

0 commit comments

Comments
 (0)