-
Notifications
You must be signed in to change notification settings - Fork 1
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
doctest syntax #1
Comments
I started down that path but rejected it because in Python you can do this...
But in CoffeeScripts REPL, you have to hit ctrl-v to get multi-line behavior. Without it, you get this...
And as others reported in the linked issue above, it doesn't seem to work on my Mac. Maybe I have a funky key mapping, but I got tired of mucking with it and changed gears. I didn't want to deviate from Python's doctest so much, but now that I have implemented it this way, I like it because:
|
With the coffeescript REPL, you can get multiline behaviour by ending lines with a backspace:
If you ditch the sqrt = (x) ->
###
Return the square root of `x`.
> square = (x) ->
> return x*x
> sqrt square 4
4
> sqrt square 100
100
###
return Math.sqrt x It's a silly example but I think it looks cleaner than having As for my last point, the coffeedoc documentation includes
|
You had to point that out. :-) Yeah, I need to fix that. That's a separate issue that I think I know what's wrong. I'll add an issue for that separately. It could use a bunch more testing. The coffeedoctest has no inline code/pre blocks in its headers so there is not much point running it on that so it's been low priority. However, if you run `coffeedoctest --readme src, it chokes on the coffeedoctest README.md file because it's code/pre blocks. I need a way to escape some stuff from coffedoctest processing... or switch to a syntax like you are proposing. The thing I don't like the most about what you are proposing is that it's not true REPL session recording either. It's sorta between. The current syntax, at least, is real code... console.log() and all. I think that when I clean up those few edge cases that I haven't tested (no code/pre blocks) and figure out how to escape stuff from processing, I'll prefer the current syntax. Any ideas on how to escape some stuff from processing while preserving the current syntax? |
Hey this is very cool. I think it would be better if you change the doctest syntax from
to something like this:
Why?
console.log()
makes the doctests more readable.<pre><code>
block. Having each line of example code start with a>
is an easy way for your parser to differentiate between code and other text.The text was updated successfully, but these errors were encountered: