Skip to content

Commit b00f15a

Browse files
authored
Add load by URL example, package keywords and link to docs in RADME (#14)
* Add example for loading documents by URL to README * Add keywords to package * Add link to documentation to README * Increase version number
1 parent 6bfc23e commit b00f15a

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ To install the latest version of cwl-ts-auto execute:
1212
### Loading Documents
1313
Documents can be loaded by specyfying a file path or by string
1414
```TypeScript
15-
import * as cwltsauto from 'cwl-ts-auto'
15+
import * as cwlTsAuto from 'cwl-ts-auto'
1616
import fs from 'fs'
1717
import url from 'url'
1818

1919
// Load document by file
20-
cwltsauto.loadDocument('./test.cwl')
20+
cwlTsAuto.loadDocument('./test.cwl')
2121
.then((file) => {
22-
if (file instanceof cwltsauto.CommandLineTool) {
22+
if (file instanceof cwlTsAuto.CommandLineTool) {
2323
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
2424
}
2525
})
2626
.catch((e) => {
27-
if(e instanceof cwltsauto.ValidationException) {
27+
if(e instanceof cwlTsAuto.ValidationException) {
2828
console.log(e.toString())
2929
} else {
3030
console.log(e)
@@ -33,14 +33,29 @@ cwltsauto.loadDocument('./test.cwl')
3333

3434
// Load document by string
3535
let docAsString = fs.readFileSync('./test.cwl').toString()
36-
cwltsauto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/').toString())
36+
cwlTsAuto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/').toString())
3737
.then((file) => {
38-
if (file instanceof cwltsauto.CommandLineTool) {
38+
if (file instanceof cwlTsAuto.CommandLineTool) {
3939
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
4040
}
4141
})
4242
.catch((e) => {
43-
if(e instanceof cwltsauto.ValidationException) {
43+
if(e instanceof cwlTsAuto.ValidationException) {
44+
console.log(e.toString())
45+
} else {
46+
console.log(e)
47+
}
48+
})
49+
50+
// Load document by URL
51+
cwlTsAuto.loadDocument('https://raw.githubusercontent.com/common-workflow-lab/cwl-ts-auto/main/src/test/data/examples/valid-cat-tool.cwl')
52+
.then((file) => {
53+
if (file instanceof cwlTsAuto.CommandLineTool) {
54+
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
55+
}
56+
})
57+
.catch((e) => {
58+
if(e instanceof cwlTsAuto.ValidationException) {
4459
console.log(e.toString())
4560
} else {
4661
console.log(e)
@@ -51,24 +66,29 @@ cwltsauto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/')
5166
### Creating, editing and saving Documents
5267
This example shows how to create a simple CommandLineTool with one input
5368
```TypeScript
54-
import * as cwltsauto from 'cwl-ts-auto'
69+
import * as cwlTsAuto from 'cwl-ts-auto'
5570

5671
let exampleCommandLineTool =
57-
new cwltsauto.CommandLineTool({
58-
class_: cwltsauto.CommandLineTool_class.COMMANDLINETOOL,
72+
new cwlTsAuto.CommandLineTool({
73+
class_: cwlTsAuto.CommandLineTool_class.COMMANDLINETOOL,
5974
inputs: [],
6075
outputs: []
6176
})
6277
exampleCommandLineTool.baseCommand = 'echo'
6378

6479
let exampleInput =
65-
new cwltsauto.CommandInputParameter({
66-
type: cwltsauto.PrimitiveType.STRING
80+
new cwlTsAuto.CommandInputParameter({
81+
type: cwlTsAuto.PrimitiveType.STRING
6782
})
6883
exampleInput.default_ = 'Hello World!'
6984
exampleCommandLineTool.inputs.push(exampleInput)
7085

7186
console.log(JSON.stringify(exampleCommandLineTool.save()))
7287
```
88+
89+
## Documentation
90+
The complete documentation, autogenerated by [TypeDoc](https://typedoc.org/) can be found under the following link:
91+
https://common-workflow-lab.github.io/cwl-ts-auto/
92+
7393
## Limitations
74-
cwl-ts-auto only supports the CWL v1.2 syntax. Other documents have to be upgraded using the [cwl-upgrader](https://pypi.org/project/cwl-upgrader/)
94+
cwl-ts-auto only supports the CWL v1.2 syntax. Other documents have to be upgraded using the [cwl-upgrader](https://pypi.org/project/cwl-upgrader/)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "cwl-ts-auto",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "This project contains TypeScript objects and utilities auto-generated by https://github.com/common-workflow-language/schema_salad for parsing documents corresponding to the https://w3id.org/cwl/cwl# schema.",
55
"author": "Adrian Zimmer",
66
"homepage": "https://www.commonwl.org/",
7+
"keywords": ["cwl", "cwl-ts-auto", "commonwl", "common workflow language", "typescript", "models", "parsing", "serialization", "deserialization"],
78
"license": "Apache License, Version 2.0",
89
"repository": {
910
"type": "git",

0 commit comments

Comments
 (0)