Hi,
Sorry if this has been asked already earlier here on the list. I looked into the reference documentation, but couldn't find anything. Is it possible to generate JavaScript comments, or even more generalized, inline any JavaScript inside parenscript code?
Thanks!
Cheers, Bastian
On 08/20/2010 10:32 PM, Bastian Müller wrote:
Hi,
Sorry if this has been asked already earlier here on the list. I looked into the reference documentation, but couldn't find anything. Is it possible to generate JavaScript comments, or even more generalized, inline any JavaScript inside parenscript code?
I'm new to parenscript's internals, so maybe that's not the correct way, but here's a small patch that allows something like:
(ps (comment #?"Foo\nbar")) ;; => ;; "/* Foo ;; bar */;"
Cheers
Hi Bastian,
That patch is indeed the right way to make a comment special form. This wasn't around before because no one had asked for it - I think most users of Parenscript generate JS code for their web applications, and use the code mainly from Lisp.
Are you making a library? If so, are you looking to document particular functions, or insert inline comments in arbitrary places? If it's the functions, then it might make sense for me to add optional output of function and variable docstrings to JS comments; that would spare the need for a new special form and syntax for comments.
As for arbitrary JS code, if there is a case where there is some JS code that you need that cannot be generated by Parenscript, it should be considered a bug in Parenscript.
Vladimir
2010/8/21 Bastian Müller bastian@turbolent.com:
On 08/20/2010 10:32 PM, Bastian Müller wrote:
Hi,
Sorry if this has been asked already earlier here on the list. I looked into the reference documentation, but couldn't find anything. Is it possible to generate JavaScript comments, or even more generalized, inline any JavaScript inside parenscript code?
I'm new to parenscript's internals, so maybe that's not the correct way, but here's a small patch that allows something like:
(ps (comment #?"Foo\nbar")) ;; => ;; "/* Foo ;; bar */;"
Cheers
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
On 08/22/2010 06:12 PM, Vladimir Sedach wrote:
Hi Vladmimir,
Are you making a library? If so, are you looking to document particular functions, or insert inline comments in arbitrary places? If it's the functions, then it might make sense for me to add optional output of function and variable docstrings to JS comments; that would spare the need for a new special form and syntax for comments.
As for arbitrary JS code, if there is a case where there is some JS code that you need that cannot be generated by Parenscript, it should be considered a bug in Parenscript.
Indeed, I'd like to create docstrings for functions and variables, so that Google's Closure compiler can be used to optimize and check the generated JavaScript Code. The annotations are documented here:
http://code.google.com/closure/compiler/docs/js-for-compiler.html
The comment special-form was the only thing I was able to add to parenscript. Docstrings would help a lot. On top of them, a separate library could provide convenience macros to generate the annotation comments compatible with Closure.
Cheers, Bastian
Would it make sense to use declaim/declare to give the Closure compiler hints?
(defun foo (x) (declare (param (*number *String) x)) (if (instanceof x *Number) (+ x "") x))
=>
"/* * @ param {Number|String} x */ function (x) { return x instanceof Number ? x + "" : x; }"
This seems like maybe it is too specific to be a part of ParenScript on the whole though...
_Nick_
On Sun, Aug 22, 2010 at 9:55 AM, Bastian Müller bastian@turbolent.comwrote:
On 08/22/2010 06:12 PM, Vladimir Sedach wrote:
Hi Vladmimir,
Are you making a library? If so, are you looking to document particular functions, or insert inline comments in arbitrary places? If it's the functions, then it might make sense for me to add optional output of function and variable docstrings to JS comments; that would spare the need for a new special form and syntax for comments.
As for arbitrary JS code, if there is a case where there is some JS code that you need that cannot be generated by Parenscript, it should be considered a bug in Parenscript.
Indeed, I'd like to create docstrings for functions and variables, so that Google's Closure compiler can be used to optimize and check the generated JavaScript Code. The annotations are documented here:
http://code.google.com/closure/compiler/docs/js-for-compiler.html
The comment special-form was the only thing I was able to add to parenscript. Docstrings would help a lot. On top of them, a separate library could provide convenience macros to generate the annotation comments compatible with Closure.
Cheers, Bastian
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
On 08/23/2010 05:58 PM, Nick Fitzgerald wrote:
Hi,
Would it make sense to use declaim/declare to give the Closure compiler hints? [...]
This seems like a good alternative to docstrings in general and seems more appropriate.
This seems like maybe it is too specific to be a part of ParenScript on the whole though...
Hmm. Maybe there should be support in parenscript for variable and function docstrings only. A separate library could provide declare, which would just produce closure-compatible annotations as a docstring.
Any pointers on where to start implementing docstrings in parenscript? Thanks!
Cheers, Bastian
I pushed a patch that should print docstring comments in a jsdoc-compatible way. Try it out and let us know.
Vladimir
2010/8/23 Bastian Müller bastian@turbolent.com:
On 08/23/2010 05:58 PM, Nick Fitzgerald wrote:
Hi,
Would it make sense to use declaim/declare to give the Closure compiler hints? [...]
This seems like a good alternative to docstrings in general and seems more appropriate.
This seems like maybe it is too specific to be a part of ParenScript on the whole though...
Hmm. Maybe there should be support in parenscript for variable and function docstrings only. A separate library could provide declare, which would just produce closure-compatible annotations as a docstring.
Any pointers on where to start implementing docstrings in parenscript? Thanks!
Cheers, Bastian
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net