Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add npm package for the docgen-tool #1008

Merged
merged 5 commits into from
Jun 15, 2021
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ check-tidy: generate
release:
@(VERSIONED_FILES="version.go \
npm-packages/cadence-parser/package.json \
npm-packages/cadence-language-server/package.json" \
npm-packages/cadence-language-server/package.json \
npm-packages/cadence-docgen/package.json" \
./bump-version.sh $(bump))
1 change: 1 addition & 0 deletions npm-packages/cadence-docgen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
30 changes: 30 additions & 0 deletions npm-packages/cadence-docgen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cadence Documentation Generator

The [Cadence](https://github.com/onflow/cadence) docgen tool compiled to WebAssembly and bundled as an NPM package,
so it can be used in tools written in JavaScript.

## Usage

```js
import {CadenceDocgen} from "@onflow/cadence-docgen"

const docgen = await CadenceDocgen.create("cadence-docgen.wasm")

const docs = docgen.generate(`
/// This is a simple function with a doc-comment.
pub fun hello() {
}
`)
```

## Development

- Building the docgen WASM binary:

```sh
cd ../../tools/docgen/wasm/

GOARCH=wasm GOOS=js go build -o ../../../npm-packages/cadence-docgen/dist/cadence-docgen.wasm
```

<!-- Cannot build from current location due to: https://github.com/golang/go/issues/43733 -->
8 changes: 8 additions & 0 deletions npm-packages/cadence-docgen/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'node',
"transform": {
"^.+\\.[tj]s$": "ts-jest"
},
setupFilesAfterEnv: [ './tests/setup.js' ],
testPathIgnorePatterns: ["/node_modules/", "/dist/"]
};
Loading