OptionParser, FDoc and a built-in debugger
I’ve been adding a bunch of new features to Fancy recently. The most exciting to me right now probably is the built-in debugger that comes with Fancy. It’s based on Rubinius’ built-in command-line debugger but obviously allows for Fancy-specific options and debugging support.
So if you want to debug some Fancy code, you can start up the command-line debugger like this:
This will launch you directly into the debugger before starting
execution of the program. If you don’t pass a source file to execute
along, it will simply start debugging Fancy’s REPL,
which always gets started when you don’t pass a source file to the
From the debugger prompt you can now specify breakpoints by class and method name, just as you’d do with Ruby and Rubinius’ debugger. See the official documentation page for Rubinius’ command-line debugger for general help on how to use it.
The main difference is that you can now set breakpoints on Fancy classes & methods, evaluate Fancy code right from within the debugger (and based on the environment you’re debugging) etc. It’s not perfect but it gets the job done. I do want to write a nicer, graphical debugger some time for Fancy using the available APIs Rubinius provides and that are used in the reference command-line debugger. Maybe once Nikita is ready and working, hooking it up with Fancy should be pretty straight forward.
The necessary changes to get the debugger working with Fancy are actually quite simple and short. The whole implementation is only 66 lines of Fancy code and is in Fancy’s repository at lib/rbx/debugger.fy.
Apart from starting up the debugger explicitly beforehand, you can also just set a breakpoint in your code explicitly and then run your code normally, like so:
For more information on available commands type
help in the debugger prompt.
Fancy now also comes with a built-in OptionParser class that deals
with your standard command-line option parsing needs. It’s basically
inspired by Ruby’s
optparse. It automatically provides a
option using the information you provided when setting up your
Here’s an example:
This will automatically provide the following
--help option output:
Options are sorted alphabetically in ascending order.
FDoc has been a part of Fancy for quite some time now (~1.75 years) and generates the JSON based output for the API documentation page for Fancy available at: api.fancy-lang.org. Initially started and written by Victor Borja back in 2010, it never really was finished up to what he intended to do. And I also never really fully got into how it all worked until recently when I decided to start cleaning things up a bit and making it useful outside of just generating documentation for Fancy’s standard library itself.
I’m happy to say that as of now FDoc can be used to generate documentation pages similar to api.fancy-lang.org for any Fancy based project. It will even provide those nice GitHub links to method definitions, if you pass along the github repository user/reponame combination. I also fixed some bugs that I found and now when you click on the little octocat on the right side of a method documentation section, it’ll jump to GitHub and highlight the complete code of the method you were looking at before. It’s quite nice if you want to see what the actual implementation of a method looks like.
fdoc --help to see all available options.
I’ve been working on a bunch of other stuff that makes day-to-day development with Fancy easier and more fun. There’s Fake, a simple Rake like automation tool. I’ve started work on FPR, Fancy’s package registry (still in the making), that will allow searching for and adding of new Fancy packages available on GitHub. And of course a bunch of libraries I added or other people have contributed to the community. It’s still quite small and growing, but as the language matures, I’m sure more people will find interest in the language and want to help out.
I for myself am committed to this either way. :)
More updates coming soon.
blog comments powered by Disqus