2004-2-16
ReSTedit (PyObjC based Restructued Text Editor)
I have been writing various random documents lately and have turned, again, to reStructured Text. ReST has a number of advantages. First and foremost, it is a plain text format that yields really nicely formatted documents and is easy to learn/use. The various writers provided with docutils can emit anything from plain text to HTML (with or without CSS) to PDF/PostScript/LaTeX.
When I interviewed with Apple last year, I revised my resum (for the first time in nearly 10 years) and used reStructuredText. Through the magic of Makefiles, my resum could then be compiled into any of a number of formats, including PDF with a bunch of live hyperlinks.
Though Emacs does well for editing ReST, it lacks a lot of the niceities of a Cocoa app. In particular, I really wanted decent spell-check-as-I-type and not having to deal with wrapped lines (emacs does not deal nearly as well as Cocoa with paragraphs of text). As well, I really wanted to easily see a preview of the rendered ReST source.
Dinu Gherman had solved the hard part of this problem a long time ago with ReSTedit. It was designed to be a ReST explorer and not to be a full blown editor.
Given that Dinu had solved the hard part of integrating ReST rendering into a Cocoa app via PyObjC, I just refactored the NIB file a bit into a vertical "preview on left, Safari WebView on right" form and moved the code around a bit.
It is a bit rough around the edges, but quite useful. I'm using it daily, at this point. The combination of ReST, Python, PyObjC, Cocoa and Xcode is such that tossing in a new feature or refining the UI a bit to support my immediate needs is perfectly reasonable.
Dinu -- master PyObjC example maker extraordinaire -- was kind enough to give me permission to toss the modified version of ReSTedit into a Subversion repository at red-bean.
Given that it is a Subversion repository, HTTP access is available. If you have the Subversion client installed the same URL (http://svn.red-bean.com/restedit/) can be used to check out the repository.
Of course, Subversion is built on WebDAV (when using HTTP as the transport protocol) and, as such, you can mount the same URL in the Finder. Checking out the latest version of the source is just a drag-n-drop copy away!
If you are feeling adventuresome and actually want to compile/run the app, you'll need to install PyObjC from the latest CVS version (replace modulename with pyobjc) as there have been a number of fixes in CVS that have not been cut into a release yet.
You will also need to install DocUtils. Rendering to PDF will require a bunch of other random bits, all of which can be had from Fink. Or you can just click the Open in Browser toolbar button and print to PDF from Safari...
Thanks to Dinu for building ReSTedit in the first place. He has commit rights on the repository and I'm hoping he will contribute again. And, of course, none of this would be possible without such an incredibly kick ass development environment. Between Cocoa, PyObjC, etc... recreational hacking can be incredibly productive!
If you feel like contributing, there are tons of obvious tasks and a ToDo List, too.
Update: The buildapp.py standalone build script was out of date. Fixed. Now the app can be built and packaged via the command line. I do all my work from within Xcode for a number of reasons, debugging with GDB and faster launch time of the app (difference being an embedded interpreter vs. execve() style startup) being the two major ones. We need to modify buildapp.py to provide a different bootstrap binary. Of course, I haven't been paying attention. This may already have been done.
Comment on this post [ so far] ... more like this: [Mac OS X, Python]