-
-
Notifications
You must be signed in to change notification settings - Fork 67
Add documentation about InlineJavascriptRequirement expressionLib #242
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
Conversation
Started using So today re-wrote it without |
* An example function that uses a function from the included | ||
* functions.js file to create a Hello World message. | ||
* @param {Object} message - CWL document input message | ||
*/ | ||
var createHelloWorldMessage = function (message) { | ||
return capitalizeWords(message); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting to show a mixture of includes and inline; might be better to show each case separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't take credit for the example, I modeled it after this example common-workflow-language/common-workflow-language#788 (comment) 🙂
I was trying to make this example simpler. If we break it down in two examples, would it be for the same code?
I liked this example as it shows that whatever is loaded in an entry of expressionLib
gets added to the global context and will be available for other entries of expressionLib
, but also to other parts of the code where Expressions are supported.
If we break it down into two examples, I think it would be nice to show
- just
$include
- just inline JavaScript
- both combined
I think that section would get a bit longer, and the user would get the same idea in both cases… I think… WDYT?
Yes, it is likely that newer versions of |
2dc9f34
to
c6c7217
Compare
Ah, I didn't try that.
I think it's worth repeating to users that whatever JavaScript they have needs to be compatible with the version of the JS Engine used by the CWL Runner, |
I was going to end that note with "You can use a transpiler to convert newer JavaScript code down to ECMAScript 5.1.", but thought it better to leave to #245 👍 |
.split(' ') | ||
.map(function (token) { | ||
return token.charAt(0).toUpperCase() + token.slice(1); | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the simplest JS code I could think of, that's actually common to see in code bases (different than fibonacci sequence or factorial) as it's not provided by JavaScript out of the box as in Python with 'string'.capitalize()
. Also avoided anything random, so that the output of the examples is more deterministic (which I intend to make even more deterministic by removing user name, directories, etc. with a container + Sphinx directive… for another issue).
6080fa0
to
1294b1f
Compare
(rebased) |
Alright, had a go at it again, let me know if it's looking better, please, @mr-c: https://common-workflow-languageuser-guide--242.org.readthedocs.build/en/242/topics/expressions.html#using-external-libraries-and-inline-javascript-code-with-expressionlib |
Co-authored-by: Michael R. Crusoe <[email protected]>
Co-authored-by: Michael R. Crusoe <[email protected]>
…ntroduce the ways to use expressionLib to readers
Closes #126