Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 85 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@basketry/typescript-docs",
"version": "0.1.1",
"version": "0.2.0-rc.0",
"description": "Basketry generator for documenting services that have a Typescript language target.",
"main": "./lib/index.js",
"scripts": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"bugs": {
"url": "https://github.com/basketry/typescript-docs/issues"
},
"homepage": "https://github.com/basketry/typescript-docs#readme",
"homepage": "https://basketry.io/docs/components/@basketry/typescript-docs",
"funding": "https://github.com/sponsors/basketry",
"devDependencies": {
"@types/jest": "^29.5.12",
Expand All @@ -49,8 +49,8 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@basketry/typescript": "^0.1.4",
"basketry": "^0.1.5",
"@basketry/typescript": "^0.2.0",
"basketry": "^0.2.0",
"case": "^1.6.3",
"prettier": "^2.5.1"
}
Expand Down
10 changes: 5 additions & 5 deletions src/interface-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ export class InterfaceInfo {
private init(): void {
for (const method of this.int.methods) {
for (const param of method.parameters) {
for (const t of this.traverse(param.typeName.value, 'input')) {
for (const t of this.traverse(param.value.typeName.value, 'input')) {
// noop
}
}

if (method.returnType && !method.returnType.isPrimitive) {
if (method.returns?.value.kind === 'ComplexValue') {
for (const t of this.traverse(
method.returnType.typeName.value,
method.returns.value.typeName.value,
'output',
)) {
// noop
Expand Down Expand Up @@ -132,8 +132,8 @@ export class InterfaceInfo {
yield type;

for (const prop of type.properties) {
if (!prop.isPrimitive) {
yield* this.traverse(prop.typeName.value, mode);
if (prop.value.kind === 'ComplexValue') {
yield* this.traverse(prop.value.typeName.value, mode);
}
}
} else if (union) {
Expand Down
23 changes: 4 additions & 19 deletions src/readme-factory.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import { readFileSync } from 'fs';
import { join } from 'path';
import { generateDocs } from './readme-factory';
import { generateFiles } from './snapshot/test-utils';

const pkg = require('../package.json');
const withVersion = `${pkg.name}@${pkg.version}`;
const withoutVersion = `${pkg.name}@{{version}}`;

describe('InterfaceFactory', () => {
it('recreates a valid snapshot', () => {
// ARRANGE
const service = require('basketry/lib/example-ir.json');

// ACT
const files = generateDocs(service, {
sorbet: {
typesModule: 'types',
enumsModule: 'enums',
},
});

// ASSERT
for (const file of [...files]) {
const path = join('src', 'snapshot', ...file.path);
const snapshot = readFileSync(path)
.toString()
.replace(withoutVersion, withVersion);
it('recreates a valid snapshot using the Engine', async () => {
for await (const file of await generateFiles()) {
const snapshot = readFileSync(join(...file.path)).toString();
expect(file.contents).toStrictEqual(snapshot);
}
});
Expand Down
Loading
Loading