typescene-api-docgen
Advanced tools
Comparing version 0.1.1 to 0.1.2
33
index.js
@@ -18,3 +18,6 @@ // COMMAND LINE APPLICATION: | ||
const ts = require("typescript"); | ||
const md = require("markdown-it")(); | ||
const md = require("markdown-it")({ | ||
html: true, | ||
typographer: true | ||
}); | ||
@@ -34,4 +37,8 @@ /** List of of all declaration items by ID */ | ||
[]); | ||
const byIdSorter = (a, b) => | ||
a.id === b.id ? (a.sourceIdx - b.sourceIdx) : a.id > b.id ? 1 : -1; | ||
const byIdSorter = (a, b) => { | ||
var a_id = a.textSort || a.id; | ||
var b_id = b.textSort || b.id; | ||
if (a_id === b_id) return a.sourceIdx - b.sourceIdx; | ||
return a_id > b_id ? 1 : -1; | ||
} | ||
@@ -146,5 +153,5 @@ // check arguments | ||
// add reference index if none defined yet | ||
if (!allItems["!~ref"]) { | ||
if (!allItems["~reference"]) { | ||
var refItem = { | ||
id: "!~ref", | ||
id: "~reference", | ||
name: "Reference", | ||
@@ -154,3 +161,3 @@ textSlug: "reference", | ||
}; | ||
allItems["!~ref"] = refItem; | ||
allItems["~reference"] = refItem; | ||
items.push(refItem); | ||
@@ -161,5 +168,12 @@ } | ||
items.forEach(item => { | ||
// find TOC parent, or use !~ref for code items | ||
// find TOC parent, or use ~reference for code items | ||
var parentID = item.textParent; | ||
if (!parentID && item.code) parentID = "!~ref"; | ||
if (!parentID) { | ||
if (item.code) parentID = "~reference"; | ||
else { | ||
var match = item.id.match(/(.*)\/[^\/]+$/); | ||
if (match && allItems[match[1]]) | ||
item.textParent = parentID = match[1]; | ||
} | ||
} | ||
var parent = allItems[parentID]; | ||
@@ -267,3 +281,4 @@ | ||
// determine name and ID from heading (or comments below) | ||
item.id = item.name = lines.shift().trim(); | ||
item.id = (item.name = lines.shift().trim()) | ||
.replace(/\s+/g, "-"); | ||
@@ -270,0 +285,0 @@ // split into running named sections |
{ | ||
"name": "typescene-api-docgen", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "API documentation generator used by Typescene modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
373565
1743