Skip to content

Commit

Permalink
Split out empty parts
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl committed Jul 21, 2023
1 parent 0fe77e8 commit 9f311a9
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 333 deletions.
4 changes: 2 additions & 2 deletions docs/odata-json-format/odata-json-format.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ <h3 id="123-document-conventions"><a name="Documentconventions" href="#Documentc
<p>This uses pandoc 3.1.2 from <a href="https://github.com/jgm/pandoc/releases/tag/3.1.2">https://github.com/jgm/pandoc/releases/tag/3.1.2</a>.</p>
</div>
<hr />
<!--TODO from here -->

<h1 id="2-json-format-design"><a name="JSONFormatDesign" href="#JSONFormatDesign">2 JSON Format Design</a></h1>
<p>JSON, as described in <a href="#rfc8259">RFC8259</a> defines a text format for serializing structured data. Objects are serialized as an unordered collection of name/value pairs.</p>
<p>JSON does not define any semantics around the name/value pairs that make up an object, nor does it define an extensibility mechanism for adding control information to a payload.</p>
Expand All @@ -282,6 +280,8 @@ <h1 id="2-json-format-design"><a name="JSONFormatDesign" href="#JSONFormatDesign
<p>Control information is used in JSON to capture instance metadata that cannot be predicted (e.g. the next link of a collection) as well as a mechanism to provide values where a computed value would be wrong (e.g. if the media read link of one particular entity does not follow the standard URL conventions). Computing values from metadata expressions is compute intensive and some clients might opt for a larger payload size to avoid computational complexity; to accommodate for this the <code>Accept</code> header allows the client to control the amount of control information added to the response.</p>
<p>To optimize streaming scenarios, there are a few restrictions that MAY be imposed on the sequence in which name/value pairs appear within JSON objects. For details on the ordering requirements see <a href="#PayloadOrderingConstraints">Payload Ordering Constraints</a>.</p>
<hr />
<!--TODO from here -->

<h1 id="3-requesting-the-json-format"><a name="RequestingtheJSONFormat" href="#RequestingtheJSONFormat">3 Requesting the JSON Format</a></h1>
<h2 id="31-controlling-the-amount-of-control-information-in-responses"><a name="ControllingtheAmountofControlInformationinResponses" href="#ControllingtheAmountofControlInformationinResponses">3.1 Controlling the Amount of Control Information in Responses</a></h2>
<h3 id="311-metadataminimal-odatametadataminimal"><a name="metadataminimalodatametadataminimal" href="#metadataminimalodatametadataminimal">3.1.1 <code>metadata=minimal</code> (<code>odata.metadata=minimal</code>)</a></h3>
Expand Down
4 changes: 2 additions & 2 deletions docs/odata-json-format/odata-json-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ This uses pandoc 3.1.2 from https://github.com/jgm/pandoc/releases/tag/3.1.2.

-------

<!--TODO from here -->

# <a name="JSONFormatDesign" href="#JSONFormatDesign">2 JSON Format Design</a>

JSON, as described in [RFC8259](#rfc8259) defines
Expand Down Expand Up @@ -304,6 +302,8 @@ Constraints](#PayloadOrderingConstraints).

-------

<!--TODO from here -->

# <a name="RequestingtheJSONFormat" href="#RequestingtheJSONFormat">3 Requesting the JSON Format</a>

## <a name="ControllingtheAmountofControlInformationinResponses" href="#ControllingtheAmountofControlInformationinResponses">3.1 Controlling the Amount of Control Information in Responses</a>
Expand Down
26 changes: 25 additions & 1 deletion lib/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,37 @@ const { createInterface } = require("readline");
const fs = require("fs");
const yaml = require("js-yaml");

function compareSectionNumbers(a, b) {
// Split section numbers into parts
const partsA = a.split(" ")[0].split(".");
const partsB = b.split(" ")[0].split(".");

// Compare each part of the section numbers
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
const partA = parseInt(partsA[i]);
const partB = parseInt(partsB[i]);

//TODO: if both partA and partB are NaN, compare lexicographically

if (partA < partB) {
return -1;
} else if (partA > partB) {
return 1;
}
}

// If all parts are equal, compare the lengths of the section numbers
return partsA.length - partsB.length;
}

class Number {
constructor(dir) {
this.dir = dir;
this.chapters = fs
.readdirSync(dir)
.filter((fn) => fn.endsWith(".md"))
.sort();
.sort(compareSectionNumbers);
// console.log(this.chapters);
this.meta = yaml.load(fs.readFileSync(dir + "/meta.yaml"));
}

Expand Down
Loading

0 comments on commit 9f311a9

Please sign in to comment.