Skip to main content

Posts about programming (old posts, page 24)

Shareware has always seemed weird to me

Anyone actually buying Tree?

Because I just have to wonder: I am pretty sure I could clone it in a weekend.

It's very basic, only for Mac...

And yet the author asks for $40 for the full version. Tell you what, readers, pledge me $400 (american dollars, that is ;-) and I promise I can deliver:

  • An app of similar features

  • Open Source

  • Multiplatform (Mac/Win/Linux at least)

In one week. While doing my job and taking care of my boy.

In fact, I don't expect it to take more than one full day of coding, and 400 bucks is more than my usual rate anyway.

If I don't release it, don't give me the money and keep the code anyway, which would be in a public repo for progress monitoring.

Session 5 is slightly delayed

I planned to have it ready for today, but my current consulting job (migrating a firm from Exchange to FLOSS) is getting a bit gnarly (mostly because of Outlook 2000) (Yes, I know).

It may be done this saturday, maybe next tuesday, I just don't know yet.

Rawdog is flexible: using Mako templates

I am using rawdog for Planeta PyAr and I am very happy with it. One thing I really didn't like was the templating.

Why? It's basically undocumented, it looks ugly and it doesn't support template inheritance, which in this case is very useful, because I am actually doing two very similar planets: 1 2.

So, since I saw a plugin to use Vellum templates, which means the templating is pluggable, why not use my favourite templating library (Mako) instead?

It turns out to be very easy to do!

Just put this in your plugins folder and start using Mako templates (yes, the planet's config and stuff is in github. Why not?).

# -*- coding: utf-8 -*-
import rawdoglib.plugins

from mako.template import Template
from mako.lookup import TemplateLookup
from mako import exceptions

class MakoPlugin:
    def __init__(self):
        self.lookup = TemplateLookup(directories=['.'],\

    def fill_template(self,template, bits, result):
        return False

p = MakoPlugin()

Yup, 20 lines of code!

rst2qhc 0.2: the insomnia release

Today I woke up at 6AM. I had nothing to do until 9, but I woke up and couldn't sleep again.

So, what can I do? I hacked rst2qhc a bit more :-D

Since this is a small project, it is quickly approaching feature complete status (there is really only so much this thing can do).

So, what's new?

  • Passing options to rst2html, so you can do things like set stylesheets.

  • Support for a manifest file, so you can list what files should be embedded in the helpfile.

  • Fixed project support. Now you can optionally ask rst2qhc to create a qhcp file that will build your document.

  • Better, more complete example that displays most features.

I have only one thing left in my TODO, which is calling the HTML writer via API instead of via system() because that way there is no need to define the keyword role in the document, and I can add syntax highlighting via pygments.

Since I now do have work to do, I will just release 0.2 now ;-)

You can get it from the usual place:

And here's a sample of the input/output:


Now you, too can create Qt Help Files painlessly

I decided to add a manual for uRSSus. Since it's a Qt app, I checked how to do one of those neat help files, like the ones that come with Qt apps.

It turns out it's not so simple to create one of those.

You need to create your help in one or more HTML files, then create a XML file that describes what each file is, references for each section, and references for each keyword you want in the index.

For any real-life-size document, that's going to be incredibly annoying.

So, I took my usual escape route when I don't want to do grunt work on docs: Docutils.

Specifically, I wrote rst2qhc which takes one (or more) restructured text files, and creates a nice and clean Qt Help Project file from them, including section titles, references and keywords, which you mark on the text using the 'keyword' role.

What does this mean? Let me be graphical:


The one on the right is nice to read. The one on the left is nice to write. The arrow in the middle is rst2qhc :-)

And here's how the generated qhp file looks for a trivial outline of a manual (and the reason why I don't want to do this manually ;-):

<?xml version="1.0" encoding="UTF-8"?>
<QtHelpProject version="1.0">
    <customFilter name="Unknown">
            <section title="The uRSSus Handbook" ref="manual.html">
                <section title="Introduction" ref="manual.html#introduction"/>
                <section title="Quick Start" ref="manual.html#quick-start"/>
                <section title="Configuration" ref="manual.html#configuration"/>
                <section title="Credits and License" ref="manual.html#credits-and-license"/>
                <keyword name="what can you" ref="manual.html#what-can-you-do-using-urssus"/>
                <keyword name="quick" ref="manual.html#quick-start"/>
                <keyword name="main window" ref="manual.html#the-main-window"/>

Also, as a bonus, you can create PDF, LaTeX, HTML and ODT files from the same source (heck, you can create freaking man pages).