docsify-ts-api
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -35,3 +35,3 @@ const readPkgUp = require('read-pkg-up'); | ||
status: SYMBOL_STATUS, | ||
symbols: new Map(), | ||
symbols: require('./symbols'), | ||
components: {}, | ||
@@ -38,0 +38,0 @@ readPkg() { |
@@ -1,2 +0,2 @@ | ||
const context = require("./context"); | ||
const context = require('./context'); | ||
const find = (list, value) => { | ||
@@ -6,6 +6,6 @@ return [].concat(list).indexOf(value) > -1; | ||
const rules = { | ||
"module": (q, symbol) => find(q, symbol.module.docPath), | ||
"symbolType": (q, symbol) => find(q, symbol.symbolType), | ||
"symbolName": (q, symbol) => find(q, symbol.symbolName), | ||
"label": (q, symbol) => symbol.labels.find((label) => find(q, label.key)) | ||
'module': (q, symbol) => find(q, symbol.module.docPath), | ||
'symbolType': (q, symbol) => find(q, symbol.symbolType), | ||
'symbolName': (q, symbol) => find(q, symbol.symbolName), | ||
'label': (q, symbol) => symbol.labels.find((label) => find(q, label.key)) | ||
}; | ||
@@ -26,3 +26,3 @@ | ||
if (result === keys.length) { | ||
symbols.push(symbol.symbolName); | ||
symbols.push(symbol); | ||
} | ||
@@ -50,5 +50,8 @@ }); | ||
return symbols | ||
.sort() | ||
.map(symbolName => context.symbols.get(symbolName)); | ||
.sort((a, b) => { | ||
if (a.symbolName < b.symbolName) return -1; | ||
if (a.symbolName > b.symbolName) return 1; | ||
return 0; | ||
}); | ||
} | ||
}; |
@@ -122,3 +122,3 @@ const { context } = require('../context/index'); | ||
try { | ||
const exported = getExportedModule(this.module.moduleLibPath + '/index.js'); | ||
const exported = getExportedModule(this.module.moduleSrcPath + '/index.js'); | ||
const symbolPrivate = exported[this.symbolName.trim()]; | ||
@@ -133,3 +133,3 @@ | ||
this.labels.push({ key: 'private', value: 'private' }); | ||
console.error('Error on exported module', this.module.moduleLibPath + '/index.js'); | ||
console.error('Error on exported module', this.module.moduleSrcPath + '/index.js', this.symbolName.trim(), er); | ||
} | ||
@@ -136,0 +136,0 @@ } |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
const { $log } = require("ts-log-debug"); | ||
const { context } = require("../context"); | ||
const { SymbolParser } = require("./SymbolParser"); | ||
'use strict'; | ||
const { $log } = require('ts-log-debug'); | ||
const { context } = require('../context'); | ||
const { SymbolParser } = require('./SymbolParser'); | ||
@@ -9,3 +9,3 @@ const { | ||
stripsTags | ||
} = require("../utils/strips"); | ||
} = require('../utils/strips'); | ||
@@ -15,2 +15,3 @@ class Parser { | ||
constructor(docFile) { | ||
this.docFile = docFile; | ||
this.contents = docFile.contents; | ||
@@ -25,7 +26,7 @@ this.symbols = new Map(); | ||
*/ | ||
overview(str = "") { | ||
overview(str = '') { | ||
return stripsTags(stripsComments(str)) | ||
.split("\n") | ||
.split('\n') | ||
.filter(o => !!o.trim()) | ||
.join("\n") | ||
.join('\n') | ||
.trim(); | ||
@@ -42,9 +43,9 @@ } | ||
this.inComment = 0; | ||
let content = this.contents.split("/** */"); | ||
let content = this.contents.split('/** */'); | ||
content = stripsTags(content[content.length - 1]); | ||
content | ||
.split("\n") | ||
.split('\n') | ||
.map((line, index, map) => this.parseLine(line, index, map)) | ||
.join("\n"); | ||
.join('\n'); | ||
@@ -64,3 +65,3 @@ // $log.debug(this.symbols); | ||
if (line.trim() === "") { | ||
if (line.trim() === '') { | ||
return; | ||
@@ -73,3 +74,3 @@ } | ||
if (line.trim() === "/**") { | ||
if (line.trim() === '/**') { | ||
if (this.inComment === 0) { | ||
@@ -82,3 +83,3 @@ this.currentComment = []; | ||
if (line.trim() === "*/") { | ||
if (line.trim() === '*/') { | ||
this.inComment--; | ||
@@ -89,7 +90,7 @@ return; | ||
if (this.inComment > 0) { | ||
this.currentComment.push(line.trim().replace(/^\* |^\*/, "")); | ||
this.currentComment.push(line.trim().replace(/^\* |^\*/, '')); | ||
return; | ||
} | ||
if (line.indexOf("}") > -1) { | ||
if (line.indexOf('}') > -1) { | ||
this.tabLevel--; | ||
@@ -102,3 +103,3 @@ } | ||
this.currentSymbol.overview.push(line); | ||
this.currentSymbol.overview = this.currentSymbol.overview.join("\n"); | ||
this.currentSymbol.overview = this.currentSymbol.overview.join('\n'); | ||
this.setSymbol(this.currentSymbol); | ||
@@ -111,5 +112,5 @@ this.currentSymbol = undefined; | ||
if (this.tabLevel >= 1 && this.currentSymbol) { | ||
this.currentSymbol.appendMember(this.tabLevel, line, this.currentComment.join("\n")); | ||
this.currentSymbol.appendMember(this.tabLevel, line, this.currentComment.join('\n')); | ||
this.currentComment = []; | ||
this.currentSymbol.overview.push(line.replace(/^export /, "")); | ||
this.currentSymbol.overview.push(line.replace(/^export /, '')); | ||
} | ||
@@ -119,8 +120,8 @@ | ||
if (line.match(/{$/)) { | ||
if (line.indexOf("function") === -1) { | ||
const symbolParser = new SymbolParser(line, this.currentComment.join("\n"), this.contents); | ||
if (line.indexOf('function') === -1) { | ||
const symbolParser = new SymbolParser(line, this.currentComment.join('\n'), this.contents); | ||
symbolParser.parse(); | ||
this.currentComment = []; | ||
this.currentSymbol = symbolParser.symbol; | ||
this.currentSymbol.overview = [line.replace(/^export /, "")]; | ||
this.currentSymbol.overview = [line.replace(/^export /, '')]; | ||
} | ||
@@ -131,3 +132,3 @@ } | ||
if (line.indexOf("{") > -1) { | ||
if (line.indexOf('{') > -1) { | ||
this.tabLevel++; | ||
@@ -139,5 +140,5 @@ } | ||
if (line.match(/;$/)) { | ||
const symbolParser = new SymbolParser(line, this.currentComment.join("\n"), this.contents); | ||
const symbolParser = new SymbolParser(line, this.currentComment.join('\n'), this.contents); | ||
symbolParser.parse(); | ||
symbolParser.symbol.overview = line.replace(/^export /, ""); | ||
symbolParser.symbol.overview = line.replace(/^export /, ''); | ||
this.setSymbol(symbolParser.symbol); | ||
@@ -155,5 +156,5 @@ return; | ||
}); | ||
const symbolParser = new SymbolParser(line, this.currentComment.join("\n"), this.contents); | ||
const symbolParser = new SymbolParser(line, this.currentComment.join('\n'), this.contents); | ||
symbolParser.parse(); | ||
symbolParser.symbol.overview = overview.join("\n").replace(/^export /, ""); | ||
symbolParser.symbol.overview = overview.join('\n').replace(/^export /, ''); | ||
this.setSymbol(symbolParser.symbol); | ||
@@ -167,11 +168,8 @@ return; | ||
setSymbol(symbol) { | ||
if (symbol.symbolName === "") { | ||
if (symbol.symbolName === '') { | ||
return; | ||
} | ||
if (context.symbols.has(symbol.symbolName)) { | ||
context.symbols.get(symbol.symbolName).merge(symbol); | ||
} else { | ||
this.symbols.set(symbol.symbolName, symbol); | ||
context.symbols.set(symbol.symbolName, symbol); | ||
} | ||
symbol.file = this.docFile.file; | ||
this.symbols.set(symbol.symbolName, context.symbols.push(symbol)); | ||
} | ||
@@ -178,0 +176,0 @@ } |
{ | ||
"name": "docsify-ts-api", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Generate documentation on TypeScript API for docsify tool", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
38443
46
1153