-
Notifications
You must be signed in to change notification settings - Fork 23
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
Literate CoffeeScript support #66
Comments
This is very weird, because any file that doesn't end with Check this line: You'll see this: result = fsu.find folder.path, /.coffee$/m I've added a file Can you provide more info so I can investigate it better? |
Here is the blog post from coffee-script author about it: http://ashkenas.com/literate-coffeescript/ I tried to replicate your issue, but it is working as expected. When I have The REGEXI think the regex to match coffeescript files, including literate coffeescript should be...
Note: the dots are escaped, otherwise they are matching any character, not a dot This will match all files ending in I found several parts of your code that rever to Literate CoffeeScriptLiterate CoffeeScript concept is extremely simple. It is just Markdown files, named Firstly, you need a more up-to-date version of coffee-script for it to work at all. I would switch to the latest, 1.6.1. I was getting an old version in your package, and therefore coffee-script was throwing errors itself. I have only used literate coffee-script from the command line. It automatically uses literate mode when the filename is one of the new extensions. I expect your script calls coffee-script from inside, rather than running a command line on the target files. I will look into the changes made in coffee-script to enable literate mode, to try to figure out how the literate version is called, and get back to you. I can not find any documentation to explain how to call from within a nodejs app yet. |
Oh well, thanks for clarifying. I'm not a literate-programmer myself so I guess I completely misunderstood you first comment. Lets make a fresh start. About the regex, you're right about the dots. Also, the version in master (0.6.12 now) is pretty old since I'm working on a complete refactoring of the library (that changes everything), so my focus is in this refactoring now instead of the current version. That said, lets get back to your problem. Yes, Toaster use CS in |
Ok, there's no 'respective' file at all. Both source and literate annotations resides in the same file. The differing of plain I suppose you're using |
Any markdown renderer can generate the docs, because the files are perfectly ordinary markdown files... or you can just read them in a text editor (as that is how markdown is designed). I think this is a (very smart) diversion from docco, to use a more standard, very expressive documenting syntax. In fact, there are probably accidental literate coffee-script files, that pre-date the compiler being able to handle them - simply when people are blogging/documenting their coffee-script using markdown. |
There's an undocumented option cs = require 'coffee-script'
fs = require 'fs'
filename = 'app.coffee.md'
file = fs.readFileSync filename, 'utf-8'
literate = /\.(litcoffee|md)$/m.test filename
compiled = cs.compile file, {literate}
console.log compiled With this As you said, there's some places with mention to I'll see if I can find the time to apply this on top of maste. If not I'll add this in the Pull requests are very welcome if you (or from anyone following this topic) have urgency on having this feature implemented on top of the master/dev branch and got the time to implement it right away. Note: Thank you very much for the Stylus package for Sublime! :) Just now I realised who you are. ㊗️ |
I had a go at adding it to master, and for a simple case it was pretty easy, but after testing with more files, I was coming up against a problem. As far as I can tell, your script concatenates the source files together, and then compiles right? To me, it would be more intuitive, to compile each file separately, and then concatenate them. This would allow different source file types (which literate coffee-script is, and could include others in the future), and also, would allow the source files to retain their header comments in the final output file...
I am going to leave this alone for now, as I don't want to waste efforts on something that will become obsolete soon (master branch). Let me know when you finish re-factoring. |
In the debug mode files are compiled individually and saved individually as well. Compiling files individually before the concatenation would include CS helpers (extends, etc) in each file, which is very bad. As CS doesn't provide a way for excluding helpers for certain cases, it'd require some extra mapping and cleaning regexes to handle the extra code. I believe the header's comments is actually an aesthetic thing since it wouldn't affect functionalities, and you can split libraries using more than on As for the docs you are trying to generate, if it's an immediate option take a look at codo. It generates API docs (okay, not literate) properly for toaster projects when |
Re: debug mode… Re: Headers The bigger benefit from compiling each file individually, and only concatenating afterwards, is that you can compile many languages, not just the coffee-script. What about if I want my stylus files compiled too for example? Or some Dart files? If you are refactoring now, it is a good time to consider how to make your software more versatile, even if you don't add the functionality now - at least you could make the space for it to be added in the future. Re: codoc The thing that is really great about literal coffee-script, is that the markdown files are editable/renderable anywhere that can handle markdown. There is no other special requirement - and because the documentation is right there with the code, it makes it extremely easy to keep it up-to-date. And because it is markdown, you can be very expressive, rather than just writing a list of parameters. On Mar 27, 2013, at 8:40 PM, Anderson Arboleya [email protected] wrote:
|
Literate coffee-script wont work on master in any way by now.
If you're doing it manually, surely. But if you're using dependencies in a more fashion way, using NPM for example, there's no copying paste, just the concatenation of many files. You'll probably never pay attention on headers. But it surely has its utilities.
What do you mean by an 'auto-generated API from param tags? Are referring to some specific tool? I agree with you, maybe I just need to dive into this literate thing a little more, to explore its beauties. I don't know if it replaces API docs completely, maybe a merge of both can be even more interesting? |
Re: Debug I had modified the master a little, but was not successful in getting it to work reliably, because at some point, the coffee-script compiler is called, with a string of coffee and literate coffee concatenated together. This was happening only in some circumstances, but often enough to be a showstopper for me. The solution in my mind, to allow for addition of other languages also, is to re-factor so that all files are always compiled independently, then concatenated, rather than concatenated and compiled. Re: Headers Yes, this is not an important point, but something I would find useful never the less, for example, when authoring a micro framework, where you could easily compile everything so that each function is minified onto a line, and it's usage info retained as a comment above. I would use your script more if it was more versatile like that. Re: Docs Yes, an augmentation between the formulaic API approach, and the expressive markdown approach is excellent. I see no conflict, you can just add the JavaDoc style tags into the markdown. The only question is how will it be used. Maybe JavaDoc style will be used for documents expected to be read by module consumers, and literate comments by module developers. Personally, I have started using literate style for the root document, where an overall architecture needs to be explained, and regular coffee-script for the other documents. On Mar 27, 2013, at 11:55 PM, Anderson Arboleya [email protected] wrote:
|
I got it, in master the release/output file is always generated whether you set de I thought a lot about adding more languages to Regarding this multi-language approach, I recommend you to check brunch.io. It didn't meet my specific needs, but definitely worts a try. It's very versatile, check it out. |
@billymoon Hi, I just want to tell you that I'm discontinuing Toaster in favor of it's new fork named Polvo. More info here: https://github.com/serpentem/coffee-toaster
|
Looks great - thanks for the pointer. On Apr 12, 2013, at 7:04 PM, Anderson Arboleya [email protected] wrote:
|
It seems that having any
file.coffee.md
named files in the source folder breaks the toaster, with this error...The text was updated successfully, but these errors were encountered: