Is there a way to parse the argument values passed to a JavaScript function in python?
I want to be able to automatically document JavaScript function calls in order to make sure they have the right arguments passed to them.
For example, in:
function mymethod(fruit, vegetable, drink) {
// dummy function
}
function drink(drink) {
this.drink = drink
}
var myveg = 'tomato'
mymethod('grape', myveg, new drink('apple juice'))
The function call would be rewritten as:
mymethod(
/*fruit*/ 'grape', /*vegetable*/ myveg,
/*drink*/ new drink('apple juice')
)
So I really want to be able to split the arguments into ["'grape'", "myveg", "new drink('apple juice')"]
removing any previous auto-inserted comments in the process, preferably allowing subfunction calls as arguments.
If all else fails, I'll make it so that the arguments are as a comment before the method call (which would be much easier to parse) but I thought I'd ask first as it would make mistakes look more obvious.
Thank you very much in advance.