docsify-ts-api
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,7 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
const { context } = require("../context"); | ||
const KEYWORDS = /(\bstatic\b|\bclass\b|\binterface\b|\bprivate\b|\bpublic\b|\bconst\b|\blet\b|\bprotected\b|\bimplements\b|\bconstructor\b|\breadonly\b|\babstract\b|\bimport\b|\bexport\b|\bas\b|\bfrom\b|\extends\b)/g; | ||
const { context } = require('../context'); | ||
const KEYWORDS = /(\benum\b|\bstatic\b|\bclass\b|\binterface\b|\bprivate\b|\bpublic\b|\bconst\b|\blet\b|\bprotected\b|\bimplements\b|\bconstructor\b|\breadonly\b|\babstract\b|\bimport\b|\bexport\b|\bas\b|\bfrom\b|\bextends\b)/g; | ||
const TYPES = /(\bany\b|\bstring\b|\bboolean\b|\bnumber\b|\bDate\b|\bvoid\b)/g; | ||
const SEPARATOR = /(:|;|,|\(|\)|{|}|\[|\])/g; | ||
const SEPARATOR = /(:|;|,|\(|\)|{|}|\[|\]| = )/g; | ||
/** | ||
@@ -18,5 +18,7 @@ * | ||
const symbol = context.symbols.get($1); | ||
const link = symbol.module.docPath + "/" + symbol.symbolName.toLowerCase(); | ||
const link = symbol.module.docPath + '/' + symbol.symbolName.toLowerCase(); | ||
return "<a href=\"#api/" + link + "\"><span class=\"token\">" + $1 + "</span></a>"; | ||
$1 = $1.replace(/</gi, '<').replace(/>/gi, '>'); | ||
return '<a href="#api/' + link + '"><span class="token">' + $1 + '</span></a>'; | ||
} | ||
@@ -36,3 +38,3 @@ | ||
context.symbols.forEach(o => { | ||
if (current !== o.symbolName && o.symbolType !== "function" && o.symbolName !== "") { | ||
if (current !== o.symbolName && o.symbolType !== 'function' && o.symbolName !== '') { | ||
keys.push(o.symbolName); | ||
@@ -42,3 +44,3 @@ } | ||
return new RegExp("(\\b" + keys.join("\\b|\\b") + "\\b)", "g"); | ||
return new RegExp('(\\b' + keys.join('\\b|\\b') + '\\b)', 'g'); | ||
}; | ||
@@ -55,10 +57,13 @@ | ||
if (current === "") { | ||
if (current === '') { | ||
return content; | ||
} | ||
content = content | ||
.replace(KEYWORDS, "<span class=\"token keyword\">$1<\/span>") | ||
.replace(/</gi, '<') | ||
.replace(/>/gi, '>') | ||
.replace(KEYWORDS, '<span class="token keyword">$1<\/span>') | ||
.replace(TYPES, '<span class="token keyword">$1<\/span>') | ||
.replace(/(=|:) "(\w+)"/g, `$1 <span class="token string">"$2"<\/span>`) | ||
.replace(/(\w+)\(/g, `<span class="token function">$1<\/span>(`) | ||
.replace(TYPES, "<span class=\"token keyword\">$1<\/span>") | ||
.replace(SEPARATOR, "<span class=\"token punctuation\">$1<\/span>"); | ||
.replace(SEPARATOR, '<span class="token punctuation">$1<\/span>'); | ||
@@ -65,0 +70,0 @@ content = content.replace(symbolsMatch(current), replacement); |
'use strict'; | ||
const { $log } = require('ts-log-debug'); | ||
const { context } = require('../context'); | ||
@@ -4,0 +3,0 @@ const { SymbolParser } = require('./SymbolParser'); |
@@ -1,5 +0,4 @@ | ||
const { $log } = require("ts-log-debug"); | ||
const { DocSymbol } = require("../models/DocSymbol"); | ||
const { descriptionParser } = require("./description-parser"); | ||
const { context } = require("../context"); | ||
const { DocSymbol } = require('../models/DocSymbol'); | ||
const { descriptionParser } = require('./description-parser'); | ||
const { context } = require('../context'); | ||
@@ -74,5 +73,9 @@ class SymbolParser { | ||
this.symbol.symbolName = matched[2]; | ||
try { | ||
this.symbol.symbolLabel = context.symbolTypes[this.symbol.symbolType].label; | ||
this.symbol.symbolCode = context.symbolTypes[this.symbol.symbolType].code; | ||
} catch (er) { | ||
console.error('====> Symbol', this.symbol.symbolType); //context.symbolTypes); | ||
} | ||
this.symbol.symbolLabel = context.symbolTypes[this.symbol.symbolType].label; | ||
this.symbol.symbolCode = context.symbolTypes[this.symbol.symbolType].code; | ||
} | ||
@@ -79,0 +82,0 @@ |
@@ -5,9 +5,10 @@ "use strict"; | ||
const path = require("path"); | ||
const chalk = require('chalk'); | ||
const logger = require('fancy-log'); | ||
const fsExtra = require("fs-extra"); | ||
const { render } = require("../render/render"); | ||
const { context } = require("../context"); | ||
const { trim } = require("../utils/trim"); | ||
const { $log } = require("ts-log-debug"); | ||
const { Parser } = require("../parsers/Parser"); | ||
const { DocFile } = require("../models/DocFile"); | ||
const { render } = require('../render/render'); | ||
const { context } = require('../context'); | ||
const { trim } = require('../utils/trim'); | ||
const { Parser } = require('../parsers/Parser'); | ||
const { DocFile } = require('../models/DocFile'); | ||
@@ -20,3 +21,3 @@ module.exports = { | ||
scanComponents(directory) { | ||
$log.info("Scan components", directory); | ||
logger('Scan components \'' + chalk.cyan(directory) + '\''); | ||
@@ -37,3 +38,3 @@ const files = glob.sync(path.join(directory, "**/*.ejs")); | ||
$log.info("Import component", path.basename(file)); | ||
logger('Import component \'' + chalk.cyan(path.basename(file)) + '\''); | ||
}); | ||
@@ -47,3 +48,3 @@ | ||
scanTemplate(templatePattern) { | ||
$log.info("Scan template directory", templatePattern); | ||
logger('Scan template directory \'' + chalk.cyan(templatePattern) + '\''); | ||
let files = glob.sync(templatePattern); | ||
@@ -58,3 +59,3 @@ | ||
scanFiles(pattern) { | ||
$log.info("Scan folders", pattern); | ||
logger('Scan folders \'' + chalk.cyan(pattern) + '\''); | ||
let files = glob.sync(pattern); | ||
@@ -77,3 +78,3 @@ | ||
} | ||
$log.info("Scanned symbol", symbol.symbolName); | ||
logger('Scanned symbol \'' + chalk.cyan(symbol.symbolName) + '\''); | ||
symbol.setDocFile(docFile); | ||
@@ -85,3 +86,3 @@ }); | ||
} catch (er) { | ||
$log.error(er); | ||
logger.error(chalk.red(er)); | ||
} | ||
@@ -88,0 +89,0 @@ |
'use strict'; | ||
const logger = require('fancy-log'); | ||
const { context } = require('../context'); | ||
@@ -8,6 +8,2 @@ const { writeSymbol, writeTemplate } = require('../write/write'); | ||
const { $log } = require('ts-log-debug'); | ||
$log.name = 'DOC'; | ||
const options = { | ||
@@ -41,5 +37,5 @@ components: path.join(__dirname, '..', '..', 'components') | ||
}) | ||
.then(() => $log.info('done')) | ||
.then(() => logger('done')) | ||
.catch(err => console.error(err)); | ||
} | ||
}; |
@@ -1,9 +0,9 @@ | ||
"use strict"; | ||
const path = require("path"); | ||
const glob = require("glob"); | ||
const fsExtra = require("fs-extra"); | ||
const { $log } = require("ts-log-debug"); | ||
const { context } = require("../context"); | ||
const { render } = require("../render/render"); | ||
const { scanTemplate } = require("../scan/scan"); | ||
'use strict'; | ||
const path = require('path'); | ||
const fsExtra = require('fs-extra'); | ||
const logger = require('fancy-log'); | ||
const chalk = require('chalk'); | ||
const { context } = require('../context'); | ||
const { render } = require('../render/render'); | ||
const { scanTemplate } = require('../scan/scan'); | ||
@@ -19,10 +19,9 @@ | ||
.forEach((file) => { | ||
const outfile = file.replace(/.ejs|.emd/, ".md"); | ||
$log.info("Write", outfile); | ||
const outfile = file.replace(/.ejs|.emd/, '.md'); | ||
logger(`Write '${chalk.cyan(outfile)}'`); | ||
const content = render(file); | ||
fsExtra.writeFile(outfile, content, { | ||
encoding: "utf8", | ||
flag: "w" | ||
encoding: 'utf8', | ||
flag: 'w' | ||
}); | ||
@@ -38,15 +37,15 @@ }); | ||
if (symbol.symbolName.trim() === "") { | ||
console.error("Symbol empty =>", symbol); | ||
if (symbol.symbolName.trim() === '') { | ||
console.error('Symbol empty =>', symbol); | ||
return; | ||
} | ||
const file = path.join(symbol.module.docPath, symbol.symbolName.toLowerCase() + ".md"); | ||
$log.info("Write", file); | ||
const file = path.join(symbol.module.docPath, symbol.symbolName.toLowerCase() + '.md'); | ||
logger(`Write '${chalk.cyan(file)}'`); | ||
const outFile = path.join(context.apiDir, file); | ||
fsExtra.writeFile(outFile, content, { | ||
encoding: "utf8", | ||
flag: "w" | ||
fsExtra.writeFile(outFile, content.trim(), { | ||
encoding: 'utf8', | ||
flag: 'w' | ||
}); | ||
} | ||
}; |
{ | ||
"name": "docsify-ts-api", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Generate documentation on TypeScript API for docsify tool", | ||
@@ -38,3 +38,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"chalk": "^2.4.1", | ||
"ejs": "^2.5.7", | ||
"fancy-log": "^1.3.2", | ||
"fs-extra": "^5.0.0", | ||
@@ -41,0 +43,0 @@ "glob": "^7.1.2", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
38883
1159
7
+ Addedchalk@^2.4.1
+ Addedfancy-log@^1.3.2
+ Addedansi-gray@0.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedansi-wrap@0.1.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfancy-log@1.3.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedparse-node-version@1.0.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtime-stamp@1.1.0(transitive)