4 # Copyright (C) 2008 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 """Script to generate documentation for remote API resources.
29 from ganeti.rapi import rlib1
30 from ganeti.rapi import rlib2
31 from ganeti.rapi import connector
34 CHECKED_COMMANDS = ["GET", "POST", "PUT", "DELETE"]
38 # Get list of all resources
39 all = list(connector.CONNECTOR.itervalues())
42 all.sort(cmp=lambda a, b: cmp(a.DOC_URI, b.DOC_URI))
44 print "<!-- Automatically generated, do not edit -->"
48 print "<title>%s</title>" % cgi.escape(cls.DOC_URI)
51 description = inspect.getdoc(cls)
53 print ("<literallayout>%s</literallayout>" %
54 cgi.escape(description.strip()))
56 print '<informaltable><tgroup cols="2">'
57 print '<colspec colwidth="1*">'
58 print '<colspec colwidth="5*">'
61 print " <entry>Method</entry>"
62 print " <entry>Description</entry>"
65 print '<tbody valign="top">'
67 for cmd in CHECKED_COMMANDS:
68 if not hasattr(cls, cmd):
72 text = inspect.getdoc(getattr(cls, cmd))
77 print " <entry>%s</entry>" % cgi.escape(cmd)
78 print (" <entry><literallayout>%s</literallayout></entry>" %
79 cgi.escape(text.strip()))
83 print "</tgroup></informaltable>"
88 if __name__ == "__main__":