February 20, 2013 by Rob Nichols
Sinatra is a lovely light weight alternative to rails, and today I have used it to create my simplest web app to date.
I have never been quite sure what my README.rdoc file will look like until I’ve posted it on github. Using rdoc markup ensures that the README is rendered nicely in github, but getting anchors and indentation to play nicely can be a bit of a fag.
You can generate an html version of the README.rdoc by entering this at the app root:
But if you look at all the gubbins that is created along with the html file, it is evident that this is over the top. If nothing else, it creates a load of files you’ll need to git ignore, or delete after you’ve used them.
Fortunately, the rdocs documentation offered a simpler solution. RDoc::Markup::ToHtml will convert rdoc markup to HTML. That gave me an HTML output, but how do I display it?
Sinatra to the rescue. I’ve posted my code here. I think the code speaks for itself.
To use it, just copy display_readme.rb to your app root, and
Then point your browser at http://localhost:4567 and your README.rdoc will be displayed in HTML.
It really is that easy, and that really is a web app in 10 lines of code!