Skip to content

Commit

Permalink
Merge pull request #723 from OpenFn/fix-describe
Browse files Browse the repository at this point in the history
describe-package: document anything with an @function tag
  • Loading branch information
josephjclark authored Jun 25, 2024
2 parents 5e54e44 + 6bfb359 commit d156311
Show file tree
Hide file tree
Showing 23 changed files with 179 additions and 27 deletions.
7 changes: 7 additions & 0 deletions examples/dts-inspector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# dts-inspector

## 1.0.17

### Patch Changes

- Updated dependencies [fa65a0f]
- @openfn/describe-package@0.0.20

## 1.0.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/dts-inspector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dts-inspector",
"version": "1.0.16",
"version": "1.0.17",
"description": "",
"main": "index.js",
"type": "module",
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/integration-tests-worker

## 1.0.48

### Patch Changes

- @openfn/engine-multi@1.1.11
- @openfn/lightning-mock@2.0.11
- @openfn/ws-worker@1.2.1

## 1.0.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-worker",
"private": true,
"version": "1.0.47",
"version": "1.0.48",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/cli

## 1.4.1

### Patch Changes

- Updated dependencies [fa65a0f]
- @openfn/describe-package@0.0.20
- @openfn/compiler@0.1.3

## 1.4.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/cli",
"version": "1.4.0",
"version": "1.4.1",
"description": "CLI devtools for the openfn toolchain.",
"engines": {
"node": ">=18",
Expand Down
7 changes: 7 additions & 0 deletions packages/compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/compiler

## 0.1.3

### Patch Changes

- Updated dependencies [fa65a0f]
- @openfn/describe-package@0.0.20

## 0.1.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/compiler",
"version": "0.1.2",
"version": "0.1.3",
"description": "Compiler and language tooling for openfn jobs.",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
6 changes: 6 additions & 0 deletions packages/describe-package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/describe-package

## 0.0.20

### Patch Changes

- fa65a0f: Describe anything with an @function tag, consistent with docsite

## 0.0.19

### Patch Changes
Expand Down
7 changes: 4 additions & 3 deletions packages/describe-package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/describe-package",
"version": "0.0.19",
"version": "0.0.20",
"description": "Utilities to inspect an npm package.",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down Expand Up @@ -32,7 +32,8 @@
"build:worker": "tsm esbuild-worker.ts",
"build:node": "tsup --config tsup.config.js src/index.ts",
"build": "pnpm clean && pnpm build:node && pnpm build:worker",
"pack": "pnpm pack --pack-destination ../../dist"
"pack": "pnpm pack --pack-destination ../../dist",
"cli": "npx tsx src/cli.ts"
},
"keywords": [],
"devDependencies": {
Expand All @@ -44,7 +45,7 @@
"esbuild": "^0.18.14",
"rimraf": "^3.0.2",
"threads": "1.7.0",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"tslib": "^2.4.0",
"tsm": "^2.2.1",
"tsup": "^7.2.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/describe-package/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type ParameterDescription = {
*/
export const describePackage = async (
specifier: string,
_options: Options
_options: Options = {}
): Promise<PackageDescription> => {
const { name, version } = getNameAndVersion(specifier);
const project = new Project();
Expand Down
12 changes: 12 additions & 0 deletions packages/describe-package/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { describePackage } from './api';

const a = process.argv[2];

async function run(specifier: string) {
const result = await describePackage(specifier, {});

console.log(result);
}

console.log('GENERATING FOR', a);
run(a);
2 changes: 1 addition & 1 deletion packages/describe-package/src/describe-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const describeProject = (
return true;
}
// Return all export aliases and public symbols
return symbol.isExportAlias || symbol.isPublic;
return symbol.isExportAlias || symbol.hasFunctionTag;
})
.reduce((symbols, symbol) => {
if (symbol.isFunctionDeclaration) {
Expand Down
9 changes: 5 additions & 4 deletions packages/describe-package/src/typescript/wrapped-symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ export class WrappedSymbol {
return this.symbol.valueDeclaration?.type;
}

// A function is private unless it has a public tag
public get isPublic(): boolean {
return this.jsDocTags.some(
(tag: ts.JSDocTag) => tag.tagName.escapedText === 'public'
public get hasFunctionTag(): boolean {
return Boolean(
this.jsDocTags.find(
(tag: ts.JSDocTag) => tag.tagName.escapedText === 'function'
)
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/describe-package/test/describe-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test('Parse an empty file', async (t) => {

test('Recognise a namespace', async (t) => {
const ns = get('flavours');
t.is(ns.type, 'namespace')
t.is(ns.type, 'namespace');

// Note that we don't do a lot with the namespace right now - we just acknowledge that its there
});
});
6 changes: 3 additions & 3 deletions packages/describe-package/test/fixtures/stroopwafel.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Returns a traditional stroopwafel
* @public
* @function
* @example
* traditional()
*/
export declare function traditional(): string;

/**
* Returns a flavoured stroopwafel
* @public
* @function
* @param {string} flavour
* @magic flavour - $.children[*]
* @example
Expand All @@ -18,7 +18,7 @@ export declare function oneFlavour(flavour: string): string;

/**
* Returns a many flavoured stroopwafel
* @public
* @function
* @example
* manyFlavours(['strawberry', 'cream'])
* @example
Expand Down
6 changes: 6 additions & 0 deletions packages/engine-multi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# engine-multi

## 1.1.11

### Patch Changes

- @openfn/compiler@0.1.3

## 1.1.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-multi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/engine-multi",
"version": "1.1.10",
"version": "1.1.11",
"description": "Multi-process runtime engine",
"main": "dist/index.js",
"type": "module",
Expand Down
6 changes: 6 additions & 0 deletions packages/lightning-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/lightning-mock

## 2.0.11

### Patch Changes

- @openfn/engine-multi@1.1.11

## 2.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/lightning-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/lightning-mock",
"version": "2.0.10",
"version": "2.0.11",
"private": true,
"description": "A mock Lightning server",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/ws-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ws-worker

## 1.2.1

### Patch Changes

- @openfn/engine-multi@1.1.11

## 1.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ws-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/ws-worker",
"version": "1.2.0",
"version": "1.2.1",
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
"main": "dist/index.js",
"type": "module",
Expand Down
Loading

0 comments on commit d156311

Please sign in to comment.