Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docsify-ts-api

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docsify-ts-api - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

1

lib/context/context.js

@@ -51,4 +51,5 @@ const readPkgUp = require('read-pkg-up');

this.modules = docsifyApi.modules;
this.scope = docsifyApi.scope;
}
};

@@ -1,2 +0,2 @@

const context = require("./context");
const context = require('./context');
module.exports = {

@@ -8,4 +8,14 @@ /**

modules() {
return Object.keys(context.modules).map(key => context.modules[key]);
return Object.keys(context.modules).reduce((acc, key) => {
const mods = context.modules[key];
if (typeof mods === 'string') {
acc.push(mods);
} else {
Object.keys(mods).forEach((subKey) => {
acc.push(mods[subKey]);
});
}
return acc;
}, []);
}
};

50

lib/models/DocFile.js

@@ -1,4 +0,4 @@

const { context } = require("../context/index");
const path = require("path");
const fs = require("fs");
const { context } = require('../context/index');
const path = require('path');
const fs = require('fs');

@@ -14,6 +14,6 @@ // const {$log} = require("ts-log-debug");

this.file = file;
this.path = (file || "").replace(path.join(context.libDir), "").replace(".d.ts", ".ts");
this.srcPath = path.resolve(path.join(context.root, "src", this.path));
this.path = (file || '').replace(path.join(context.libDir), '').replace('.d.ts', '.ts');
this.srcPath = path.resolve(path.join(context.root, 'src', this.path));
this.symbol = path.basename(file).replace(".d.ts", "");
this.symbol = path.basename(file).replace('.d.ts', '');
this.module = this.getModule();

@@ -29,17 +29,37 @@ this.symbols = new Map();

getModule() {
const index = this.path.replace(/^\//, "").split("/")[0];
const docPath = context.modules[index] || "common";
const isCommon = docPath.indexOf("common/") > -1;
const name = isCommon ? context.projectName : (context.projectName + "/" + index);
const [pkgName, subPkgName] = this.path.replace(/^\//, '').split('/');
const pkgSettings = context.modules[pkgName];
let packagePath = pkgName;
if (typeof pkgSettings === 'object' && context.modules[pkgName][subPkgName]) {
packagePath = pkgName + '/' + subPkgName;
}
if (context.scope) {
return {
name: context.scope + '/' + packagePath,
importFrom: context.scope + '/' + pkgName,
pkgName,
subPkgName,
docPath: packagePath,
srcPath: path.join(context.root, 'src', packagePath),
moduleSrcPath: context.srcDir + '/' + packagePath,
moduleLibPath: context.libDir + '/' + pkgName
};
}
const isCommon = packagePath.indexOf('common/') > -1;
const name = isCommon ? context.projectName : (context.projectName + '/' + pkgName);
const srcPath = path.resolve(
isCommon ? path.join(context.root, "src") : path.join(context.root, "src", index)
isCommon ? path.join(context.root, 'src') : path.join(context.root, 'src', pkgName)
);
return {
name,
pkgName,
importFrom: name,
docPath,
docPath: packagePath,
srcPath,
moduleSrcPath: context.srcDir + "/" + index,
moduleLibPath: context.libDir + "/" + index,
isCommon
moduleSrcPath: context.srcDir + '/' + pkgName,
moduleLibPath: context.libDir + '/' + pkgName
};

@@ -46,0 +66,0 @@ }

@@ -1,8 +0,18 @@

const path = require("path");
const { context } = require("../context/index");
const { descriptionParser } = require("../parsers/description-parser.js");
const { context } = require('../context/index');
const { descriptionParser } = require('../parsers/description-parser.js');
const mapExported = new Map();
const getExportedModule = (path) => {
if (!mapExported.has(path)) {
mapExported.set(path, require(path));
}
return mapExported.get(path);
};
const _filterParams = (labels) => {
return labels.filter(o => o.key === "param")
return labels.filter(o => o.key === 'param')
.map(o => {

@@ -12,7 +22,7 @@ let type = o.value.match(/{(.*)}/);

if (type) {
o.value = o.value.replace(/{(.*)}/, "").trim();
o.value = o.value.replace(/{(.*)}/, '').trim();
type = type[1];
}
const spaceIndex = o.value.trim().indexOf(" ");
const spaceIndex = o.value.trim().indexOf(' ');
if (spaceIndex === -1) {

@@ -36,14 +46,14 @@ return;

constructor() {
this.symbolName = "";
this.module = "";
this.github = "";
this.url = "";
this.symbolName = '';
this.module = '';
this.github = '';
this.url = '';
this.abstract = false;
this.symbolType = "";
this.symbolLabel = "";
this.symbolCode = "";
this.extends = "";
this.symbolType = '';
this.symbolLabel = '';
this.symbolCode = '';
this.extends = '';
this.implements = [];
this.members = [];
this.description = "";
this.description = '';
this.exported = false;

@@ -62,8 +72,8 @@ this.labels = [];

if (tabLevel > 1) {
this.members[this.members.length - 1].overview.push(line.replace(" ", ""));
this.members[this.members.length - 1].overview.push(line.replace(' ', ''));
return;
}
if (line.indexOf("}") > -1) {
this.members[this.members.length - 1].overview.push(line.replace(" ", ""));
if (line.indexOf('}') > -1) {
this.members[this.members.length - 1].overview.push(line.replace(' ', ''));
return;

@@ -77,3 +87,3 @@ }

labels: description.labels,
overview: [line.trim().replace(";", "")]
overview: [line.trim().replace(';', '')]
});

@@ -86,3 +96,3 @@

member.params = _filterParams(member.labels);
member.overview = member.overview.join("\n");
member.overview = member.overview.join('\n');
return member;

@@ -99,12 +109,12 @@ });

if (this.path.match("decorators")) {
this.symbolType = "decorator";
this.symbolLabel = context.symbolTypes["decorator"].label;
this.symbolCode = context.symbolTypes["decorator"].code;
if (this.path.match('decorators')) {
this.symbolType = 'decorator';
this.symbolLabel = context.symbolTypes['decorator'].label;
this.symbolCode = context.symbolTypes['decorator'].code;
}
if (this.path.match("services")) {
this.symbolType = "service";
this.symbolLabel = context.symbolTypes["service"].label;
this.symbolCode = context.symbolTypes["service"].code;
if (this.path.match('services')) {
this.symbolType = 'service';
this.symbolLabel = context.symbolTypes['service'].label;
this.symbolCode = context.symbolTypes['service'].code;
}

@@ -116,11 +126,15 @@ this.isPrivate();

if (this.private === undefined) {
if (this.symbolType !== "interface") {
if (this.symbolType !== 'interface') {
try {
const exported = getExportedModule(this.module.moduleLibPath + '/index.js');
const symbolPrivate = exported[this.symbolName.trim()];
const exported = require(this.module.moduleLibPath + "/index.js");
const symbolPrivate = exported[this.symbolName.trim()];
this.private = !symbolPrivate;
if (this.private) {
this.labels.push({ key: "private", value: "private" });
this.private = !symbolPrivate;
if (this.private) {
this.labels.push({ key: 'private', value: 'private' });
}
} catch (er) {
this.private = true;
this.labels.push({ key: 'private', value: 'private' });
console.error('Error on exported module', this.module.moduleLibPath + '/index.js');
}

@@ -139,3 +153,3 @@ }

merge(symbol) {
if (symbol.symbolType !== "const") {
if (symbol.symbolType !== 'const') {
this.symbolType = symbol.symbolType;

@@ -146,3 +160,3 @@ this.symbolCode = symbol.symbolCode;

if (this.description === "") {
if (this.description === '') {
this.description = symbol.description;

@@ -153,3 +167,3 @@ this.labels = symbol.labels;

if (this.overview !== symbol.overview) {
this.overview = this.overview + "\n" + symbol.overview;
this.overview = this.overview + '\n' + symbol.overview;
}

@@ -162,6 +176,16 @@ }

if (!isPrivate) {
return this.module.name;
return this.module.importFrom;
}
const path = context.projectName + context.libDir.replace(context.root, "");
return this.srcPath.replace(context.root + "/src", path).replace(/\.ts$/, "");
if (context.scope) {
const path = this.srcPath
.replace(context.root + '/src/' + this.module.pkgName, '')
.replace(/\.ts$/, '');
return context.scope + '/' + this.module.pkgName + '/lib' + path;
}
const path = context.libDir.replace(context.root, '');
const entityPath = this.srcPath.replace(context.root + '/src', path).replace(/\.ts$/, '');
return context.projectName + entityPath;
}

@@ -179,7 +203,7 @@

this.symbolCode,
this.hasLabel("deprecated"),
this.hasLabel("stable"),
this.hasLabel("experimental"),
this.hasLabel("private")
].join(";");
this.hasLabel('deprecated'),
this.hasLabel('stable'),
this.hasLabel('experimental'),
this.hasLabel('private')
].join(';');
}

@@ -186,0 +210,0 @@ }

@@ -1,4 +0,4 @@

const fs = require("fs");
const ejs = require("ejs");
const { context, modules } = require("../context");
const fs = require('fs');
const ejs = require('ejs');
const { context, modules } = require('../context');

@@ -17,2 +17,3 @@ module.exports = {

version,
scope: context.scope,
projectName,

@@ -24,3 +25,3 @@ components,

const template = fs.readFileSync(filename, { encoding: "utf8" });
const template = fs.readFileSync(filename, { encoding: 'utf8' });

@@ -27,0 +28,0 @@ return ejs.render(template, scope, {

@@ -58,3 +58,3 @@ "use strict";

return files
.filter((file) => !file.match(/Express.d.ts/))
.filter((file) => !file.match(/Express.d.ts|lib\/index.ts/))
.map(file => new DocFile(file))

@@ -61,0 +61,0 @@ .map(docFile => {

{
"name": "docsify-ts-api",
"version": "1.1.1",
"version": "2.0.0",
"description": "Generate documentation on TypeScript API for docsify tool",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc