Socket
Socket
Sign inDemoInstall

dgeni-packages

Package Overview
Dependencies
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dgeni-packages - npm Package Compare versions

Comparing version 0.21.0 to 0.21.1

typescript/src/utils/encodeAnchor.ts

5

base/services/resolveUrl.spec.js

@@ -81,2 +81,7 @@ var mockPackage = require('../mocks/mockPackage');

// });
it('should encode any \' in the path', function() {
expect(resolveUrl('currentFile.html', '/abc\'def.html', ''))
.toEqual('/abc%27def.html');
});
});

13

CHANGELOG.md
# Changelog
# 0.21.1 4 September 2017
## Features
* **typescript**: support overloaded constructors ca69213d
## Bug Fixes
* **typescript**: fix possibly null references 463ef5cf
# 0.21.0 4 September 2017
* feat(typescript): reference `extands` and `implements` ancestor info d7c29603
## Features
* **typescript**: reference `extands` and `implements` ancestor info d7c29603

@@ -7,0 +18,0 @@ ## BREAKING CHANGES:

2

package.json
{
"name": "dgeni-packages",
"version": "0.21.0",
"version": "0.21.1",
"description": "A collection of dgeni packages for generating documentation from source code",

@@ -5,0 +5,0 @@ "scripts": {

import { Symbol, TypeChecker } from 'typescript';
import { ClassLikeExportDoc } from '../api-doc-types/ClassLikeExportDoc';
import { MemberDoc } from '../api-doc-types/MemberDoc';
import { MethodMemberDoc } from '../api-doc-types/MethodMemberDoc';
import { ModuleDoc } from '../api-doc-types/ModuleDoc';

@@ -11,5 +12,6 @@ /**

docType: string;
constructorDoc: MemberDoc;
constructorDoc: MethodMemberDoc | undefined;
statics: MemberDoc[];
constructor(moduleDoc: ModuleDoc, symbol: Symbol, basePath: string, typeChecker: TypeChecker, hidePrivateMembers: boolean, namespacesToInclude: string[]);
private getConstructorDoc(constructorSymbol);
}

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

if (constructorSymbol && constructorSymbol.getFlags() & typescript_1.SymbolFlags.Constructor) {
_this.constructorDoc = new MethodMemberDoc_1.MethodMemberDoc(_this, constructorSymbol, constructorSymbol.getDeclarations()[0], _this.basePath, _this.namespacesToInclude, false);
_this.constructorDoc = _this.getConstructorDoc(constructorSymbol);
}

@@ -42,2 +42,18 @@ // Get the instance members

}
ClassExportDoc.prototype.getConstructorDoc = function (constructorSymbol) {
var _this = this;
var constructorDoc = null;
var overloads = [];
constructorSymbol.getDeclarations().forEach(function (declaration) {
if (declaration.body) {
// This is the "real" declaration of the method
constructorDoc = new MethodMemberDoc_1.MethodMemberDoc(_this, constructorSymbol, declaration, _this.basePath, _this.namespacesToInclude, false, overloads);
}
else {
// This is an overload signature of the method
overloads.push(new MethodMemberDoc_1.MethodMemberDoc(_this, constructorSymbol, declaration, _this.basePath, _this.namespacesToInclude, false, overloads));
}
});
return constructorDoc || overloads.shift();
};
return ClassExportDoc;

@@ -44,0 +60,0 @@ }(ClassLikeExportDoc_1.ClassLikeExportDoc));

@@ -15,2 +15,3 @@ "use strict";

var getTypeParametersText_1 = require("../services/TsParser/getTypeParametersText");
var encodeAnchor_1 = require("../utils/encodeAnchor");
var MemberDoc_1 = require("./MemberDoc");

@@ -41,3 +42,3 @@ var MethodMemberDoc = (function (_super) {

// if there is more than one declaration then we need to include the param list to distinguish them
return encodeURI(this.symbol.getDeclarations().length === 1 ? anchorName : anchorName + "(" + this.parameters.join(', ') + ")");
return encodeAnchor_1.encodeAnchor(this.symbol.getDeclarations().length === 1 ? anchorName : anchorName + "(" + this.parameters.join(', ') + ")");
};

@@ -44,0 +45,0 @@ MethodMemberDoc.prototype.computeAliases = function () {

@@ -13,2 +13,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var encodeAnchor_1 = require("../utils/encodeAnchor");
var MemberDoc_1 = require("./MemberDoc");

@@ -20,3 +21,3 @@ var PropertyMemberDoc = (function (_super) {

_this.name = _this.symbol.name;
_this.anchor = encodeURI(_this.name);
_this.anchor = encodeAnchor_1.encodeAnchor(_this.name);
_this.id = _this.containerDoc.id + "." + _this.name;

@@ -23,0 +24,0 @@ _this.aliases = _this.containerDoc.aliases.map(function (alias) { return alias + "." + _this.name; });

export abstract class TestClass {
constructor(x: string, y: number);
constructor(x: string, y: string, z: number);
constructor(x: string, y: number|string, z?: number) {
// do nothing
}
/**

@@ -3,0 +8,0 @@ * String foo

@@ -201,2 +201,16 @@ "use strict";

});
describe('overloaded constructors', function () {
it('should create a member doc for the "real" constructor, which includes an overloads property', function () {
processor.sourceFiles = ['overloadedMembers.ts'];
var docs = [];
processor.$process(docs);
var foo = docs.find(function (doc) { return doc.name === 'constructor'; });
expect(foo.parameters).toEqual(['x: string', 'y: number|string', 'z?: number']);
var overloads = foo.overloads;
expect(overloads.map(function (overload) { return overload.parameters; })).toEqual([
['x: string', 'y: number'],
['x: string', 'y: string', 'z: number'],
]);
});
});
describe('ordering of members', function () {

@@ -203,0 +217,0 @@ it('should order class members in order of appearance (by default)', function () {

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

import { Declaration } from 'typescript';
export declare function getParameters(declaration: Declaration, namespacesToInclude: string[]): string[];
import { SignatureDeclaration } from 'typescript';
export declare function getParameters(declaration: SignatureDeclaration, namespacesToInclude: string[]): string[];
/* tslint:disable:no-bitwise */
import { Declaration, Symbol, SymbolFlags, TypeChecker } from 'typescript';
import { Declaration, FunctionLikeDeclaration, Symbol, SymbolFlags, TypeChecker } from 'typescript';
import { ClassLikeExportDoc } from '../api-doc-types/ClassLikeExportDoc';

@@ -14,3 +14,3 @@ import { MemberDoc } from '../api-doc-types/MemberDoc' ;

docType = 'class';
constructorDoc: MemberDoc;
constructorDoc: MethodMemberDoc|undefined;
statics: MemberDoc[] = [];

@@ -32,3 +32,3 @@ constructor(

if (constructorSymbol && constructorSymbol.getFlags() & SymbolFlags.Constructor) {
this.constructorDoc = new MethodMemberDoc(this, constructorSymbol, constructorSymbol.getDeclarations()[0], this.basePath, this.namespacesToInclude, false);
this.constructorDoc = this.getConstructorDoc(constructorSymbol);
}

@@ -39,2 +39,17 @@ // Get the instance members

}
private getConstructorDoc(constructorSymbol: Symbol) {
let constructorDoc: MethodMemberDoc|null = null;
const overloads: MethodMemberDoc[] = [];
constructorSymbol.getDeclarations()!.forEach(declaration => {
if ((declaration as FunctionLikeDeclaration).body) {
// This is the "real" declaration of the method
constructorDoc = new MethodMemberDoc(this, constructorSymbol, declaration, this.basePath, this.namespacesToInclude, false, overloads);
} else {
// This is an overload signature of the method
overloads.push(new MethodMemberDoc(this, constructorSymbol, declaration, this.basePath, this.namespacesToInclude, false, overloads));
}
});
return constructorDoc || overloads.shift();
}
}

@@ -69,3 +69,3 @@ /* tslint:disable:no-bitwise */

// (interfaces can have multiple declarations, which are merged, each with their own heritage)
this.symbol.getDeclarations().forEach(declaration => {
this.symbol.getDeclarations()!.forEach(declaration => {
getHeritage(declaration).forEach(clause => {

@@ -72,0 +72,0 @@ // Now process these clauses to find each "extends" and "implements" clause

@@ -42,3 +42,3 @@ /* tslint:disable:no-bitwise */

for (const declaration of member.getDeclarations()) {
for (const declaration of member.getDeclarations()!) {
if (flags & MethodMemberFlags) {

@@ -45,0 +45,0 @@ if ((declaration as FunctionLikeDeclaration).body) {

@@ -20,3 +20,3 @@ import { Declaration, Symbol, TypeChecker } from 'typescript';

super(moduleDoc, symbol, symbol.valueDeclaration!, basePath, typeChecker, namespacesToInclude);
this.additionalDeclarations = symbol.getDeclarations().filter(declaration => declaration !== this.declaration);
this.additionalDeclarations = symbol.getDeclarations()!.filter(declaration => declaration !== this.declaration);
if (symbol.exports) {

@@ -23,0 +23,0 @@ this.members = this.getMemberDocs(symbol.exports, true, false);

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

import { Declaration, Symbol, TypeChecker } from 'typescript';
import { Declaration, SignatureDeclaration, Symbol, TypeChecker } from 'typescript';
import { getDeclarationTypeText } from '../services/TsParser/getDeclarationTypeText';

@@ -11,7 +11,7 @@ import { getParameters } from '../services/TsParser/getParameters';

docType = 'function';
overloads = this.symbol.getDeclarations()
overloads = this.symbol.getDeclarations()!
.filter(declaration => declaration !== this.declaration)
.map(declaration => new OverloadInfo(this, declaration, this.typeChecker));
typeParameters = getTypeParametersText(this.declaration, this.namespacesToInclude);
parameters = getParameters(this.declaration, this.namespacesToInclude);
parameters = getParameters(this.declaration as SignatureDeclaration, this.namespacesToInclude);
type = getDeclarationTypeText(this.declaration, this.namespacesToInclude);

@@ -25,3 +25,3 @@

namespacesToInclude: string[]) {
super(moduleDoc, symbol, findRealDeclaration(symbol.getDeclarations()), basePath, typeChecker, namespacesToInclude);
super(moduleDoc, symbol, findRealDeclaration(symbol.getDeclarations()!), basePath, typeChecker, namespacesToInclude);
}

@@ -28,0 +28,0 @@

@@ -18,6 +18,6 @@ import { Declaration, Map, Symbol, TypeChecker } from 'typescript';

namespacesToInclude: string[]) {
super(moduleDoc, symbol, symbol.valueDeclaration || symbol.getDeclarations()[0]!, basePath, typeChecker, namespacesToInclude);
super(moduleDoc, symbol, symbol.valueDeclaration || symbol.getDeclarations()![0]!, basePath, typeChecker, namespacesToInclude);
if (symbol.members) this.members = this.getMemberDocs(symbol.members, true, false);
this.additionalDeclarations = symbol.getDeclarations().filter(declaration => declaration !== this.declaration);
this.additionalDeclarations = symbol.getDeclarations()!.filter(declaration => declaration !== this.declaration);
}
}
/* tslint:disable:no-bitwise */
import { Declaration, Symbol, SymbolFlags } from 'typescript';
import { Declaration, SignatureDeclaration, Symbol, SymbolFlags } from 'typescript';
import { getParameters } from '../services/TsParser/getParameters';
import { getTypeParametersText } from '../services/TsParser/getTypeParametersText';
import { encodeAnchor } from '../utils/encodeAnchor';
import { ContainerExportDoc } from './ContainerExportDoc';

@@ -9,3 +10,3 @@ import { MemberDoc } from './MemberDoc';

export class MethodMemberDoc extends MemberDoc {
readonly parameters = getParameters(this.declaration, this.namespacesToInclude);
readonly parameters = getParameters(this.declaration as SignatureDeclaration, this.namespacesToInclude);
readonly name = this.computeName();

@@ -39,3 +40,3 @@ readonly anchor = this.computeAnchor();

// if there is more than one declaration then we need to include the param list to distinguish them
return encodeURI(this.symbol.getDeclarations().length === 1 ? anchorName : `${anchorName}(${this.parameters.join(', ')})`);
return encodeAnchor(this.symbol.getDeclarations()!.length === 1 ? anchorName : `${anchorName}(${this.parameters.join(', ')})`);
}

@@ -42,0 +43,0 @@

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

import { Declaration, TypeChecker } from 'typescript';
import { Declaration, SignatureDeclaration, TypeChecker } from 'typescript';
import { getDeclarationTypeText } from '../services/TsParser/getDeclarationTypeText';

@@ -13,3 +13,3 @@ import { getParameters } from '../services/TsParser/getParameters';

docType = 'function-overload';
parameters = getParameters(this.declaration, this.namespacesToInclude);
parameters = getParameters(this.declaration as SignatureDeclaration, this.namespacesToInclude);
type = getDeclarationTypeText(this.declaration, this.namespacesToInclude);

@@ -16,0 +16,0 @@

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

import { encodeAnchor } from '../utils/encodeAnchor';
import { MemberDoc } from './MemberDoc';

@@ -5,5 +6,5 @@

name = this.symbol.name;
anchor = encodeURI(this.name);
anchor = encodeAnchor(this.name);
id = `${this.containerDoc.id}.${this.name}`;
aliases = this.containerDoc.aliases.map(alias => `${alias}.${this.name}` );
}

@@ -16,3 +16,3 @@ import { Declaration, Symbol, SyntaxKind, TypeChecker } from 'typescript';

namespacesToInclude: string[]) {
super(moduleDoc, exportSymbol, getTypeAliasDeclaration(exportSymbol.getDeclarations()), basePath, typeChecker, namespacesToInclude);
super(moduleDoc, exportSymbol, getTypeAliasDeclaration(exportSymbol.getDeclarations()!), basePath, typeChecker, namespacesToInclude);
}

@@ -19,0 +19,0 @@ }

@@ -251,2 +251,18 @@ import {Dgeni, DocCollection} from 'dgeni';

describe('overloaded constructors', () => {
it('should create a member doc for the "real" constructor, which includes an overloads property', () => {
processor.sourceFiles = [ 'overloadedMembers.ts'];
const docs: DocCollection = [];
processor.$process(docs);
const foo: MethodMemberDoc = docs.find(doc => doc.name === 'constructor');
expect(foo.parameters).toEqual(['x: string', 'y: number|string', 'z?: number']);
const overloads = foo.overloads;
expect(overloads.map(overload => overload.parameters)).toEqual([
['x: string', 'y: number'],
['x: string', 'y: string', 'z: number'],
]);
});
});
describe('ordering of members', () => {

@@ -253,0 +269,0 @@ it('should order class members in order of appearance (by default)', () => {

@@ -18,4 +18,4 @@ import { MethodDeclaration } from 'typescript';

expect(getContent(module.exportArray[0].getDeclarations()[0])).toEqual('Description of TestClass\n@deprecated warning');
expect(getContent(module.exportArray[1].getDeclarations()[0])).toEqual('Description of function');
expect(getContent(module.exportArray[0].getDeclarations()![0])).toEqual('Description of TestClass\n@deprecated warning');
expect(getContent(module.exportArray[1].getDeclarations()![0])).toEqual('Description of function');
});

@@ -22,0 +22,0 @@

@@ -18,5 +18,5 @@ import { SignatureDeclaration } from 'typescript';

expect(getDeclarationTypeText(moduleExports[0].getDeclarations()[0], [])).toEqual('42');
expect(getDeclarationTypeText(moduleExports[0].getDeclarations()![0], [])).toEqual('42');
const testFunction = moduleExports[1].getDeclarations()[0] as SignatureDeclaration;
const testFunction = moduleExports[1].getDeclarations()![0] as SignatureDeclaration;
expect(getDeclarationTypeText(testFunction, [])).toEqual('number');

@@ -27,5 +27,5 @@ expect(getDeclarationTypeText(testFunction.parameters[0], [])).toEqual('T[]');

const testClass = moduleExports[2];
expect(getDeclarationTypeText(testClass.members!.get('property')!.getDeclarations()[0], [])).toEqual('T[]');
expect(getDeclarationTypeText(testClass.members!.get('method')!.getDeclarations()[0], [])).toEqual('T');
expect(getDeclarationTypeText(testClass.members!.get('property')!.getDeclarations()![0], [])).toEqual('T[]');
expect(getDeclarationTypeText(testClass.members!.get('method')!.getDeclarations()![0], [])).toEqual('T');
});
});

@@ -19,7 +19,7 @@ import { SignatureDeclaration } from 'typescript';

const testMethodDeclaration = testClass.members!.get('method')!.getDeclarations()[0];
const testMethodDeclaration = testClass.members!.get('method')!.getDeclarations()![0];
const testParameters = (testMethodDeclaration as any).parameters;
const classDecorators = getDecorators(testClass.getDeclarations()[0])!;
const propertyDecorators = getDecorators(testClass.members!.get('property')!.getDeclarations()[0])!;
const classDecorators = getDecorators(testClass.getDeclarations()![0])!;
const propertyDecorators = getDecorators(testClass.members!.get('property')!.getDeclarations()![0])!;
const methodDecorators = getDecorators(testMethodDeclaration)!;

@@ -26,0 +26,0 @@

@@ -43,7 +43,7 @@ import { Node, NodeFlags, Symbol, SymbolFlags } from 'typescript';

symbolType: ${symbol.flags}
file: ${symbol.getDeclarations()[0].getSourceFile().fileName}`);
file: ${symbol.getDeclarations()![0].getSourceFile().fileName}`);
}
function getBlockScopedVariableDocType(symbol: Symbol) {
let node: Node | undefined = symbol.valueDeclaration || symbol.getDeclarations()[0];
let node: Node | undefined = symbol.valueDeclaration || symbol.getDeclarations()![0];
while (node) {

@@ -50,0 +50,0 @@ if ( node.flags & NodeFlags.Const) {

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

import { SignatureDeclaration } from 'typescript';
import { TsParser } from '.';

@@ -16,3 +17,3 @@ import { getParameters } from './getParameters';

const moduleExports = parseInfo.moduleSymbols[0].exportArray;
const params = getParameters(moduleExports[0].getDeclarations()[0], []);
const params = getParameters(moduleExports[0].getDeclarations()![0] as SignatureDeclaration, []);
expect(params).toEqual([

@@ -19,0 +20,0 @@ 'a: string',

@@ -1,5 +0,5 @@

import { Declaration, ParameterDeclaration } from 'typescript';
import { Declaration, ParameterDeclaration, SignatureDeclaration } from 'typescript';
import { getDeclarationTypeText } from './getDeclarationTypeText';
export function getParameters(declaration: Declaration, namespacesToInclude: string[]) {
export function getParameters(declaration: SignatureDeclaration, namespacesToInclude: string[]) {
const parameters = getParameterDeclarations(declaration);

@@ -6,0 +6,0 @@ if (!parameters) {

@@ -18,9 +18,9 @@ import { } from 'typescript';

const testFunction = moduleExports[0].getDeclarations()[0];
const testFunction = moduleExports[0].getDeclarations()![0];
expect(getTypeParametersText(testFunction, [])).toEqual('<T, U, V>');
const testClass = moduleExports[1];
expect(getTypeParametersText(testClass.getDeclarations()[0], [])).toEqual('<T>');
expect(getTypeParametersText(testClass.members!.get('method')!.getDeclarations()[0], [])).toEqual('<U>');
expect(getTypeParametersText(testClass.getDeclarations()![0], [])).toEqual('<T>');
expect(getTypeParametersText(testClass.members!.get('method')!.getDeclarations()![0], [])).toEqual('<U>');
});
});

@@ -44,3 +44,3 @@ import { Declaration, Symbol, TypeNode } from 'typescript';

function getType(symbol: Symbol) {
return (symbol.getDeclarations()[0] as any).type as TypeNode;
return (symbol.getDeclarations()![0] as any).type as TypeNode;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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