Here’s a cheap and cheerful little script I threw together to automatically generate Markdown-formatted documentation for my QMF methods. I used this to make the Wallaby API documentation.

qmf2markdown.pylink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python

# qmf2markdown.py
# documents the QMF classes from the packages listed in argv; 
# runs against a broker in localhost.

# Public domain.
# Author:  William Benton (willb@redhat.com)

from qmf.console import Session
from sys import argv

s = Session()
s.addBroker()

qmftypes = {12:'float', 6:'sstr', 15:'map', 3:'uint32', 17:'int16', 8:'abstime', 19:'int64', 10:'ref', 2:'uint16', 16:'int8', 13:'double', 21:'list', 11:'bool', 4:'uint64', 22:'array', 1:'uint8', 9:'deltatime', 7:'lstr', 18:'int32', 14:'uuid', 20:'object'}
qmfdirs = {"I":"in", "O":"out", "IO":"in-out"}

for arg in argv[1:]:
  classes = s.getClasses(arg)
  for klass in classes:
    print "## %s:%s ##" % (klass.pname, klass.cname)
    schema = s.getSchema(klass)
    for prop in schema.getProperties():
      print "  * <tt>%s</tt> (<tt>%s</tt> property)" % (prop.name, qmftypes[prop.type])
      if prop.desc != None:
        print ""
        print "    %s" % prop.desc
    for stat in schema.getStatistics():
      print "  * <tt>%s</tt> (<tt>%s</tt> statistic)" % (stat.name, qmftypes[stat.type])
      if stat.desc != None:
        print ""
        print "    %s" % stat.desc
    for meth in schema.getMethods():
      print "  * <tt>%s</tt>" % repr(meth)
      if meth.desc != None:
        print ""
        print "    %s" % meth.desc
      for arg in meth.arguments:
        print "    * <tt>%s</tt> (<tt>%s</tt>/%s)" % (arg.name, qmftypes[arg.type], qmfdirs[arg.dir])
        if arg.desc != None:
          print ""
          print "      %s" % arg.desc
    print ""

  qmf, qpid • You may reply to this post on Twitter or