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 rlib2
30 from ganeti.rapi import connector
33 CHECKED_COMMANDS = ["GET", "POST", "PUT", "DELETE"]
37 # Get list of all resources
38 all = list(connector.CONNECTOR.itervalues())
41 all.sort(cmp=lambda a, b: cmp(a.DOC_URI, b.DOC_URI))
43 print "<!-- Automatically generated, do not edit -->"
47 print "<title>%s</title>" % cgi.escape(cls.DOC_URI)
50 description = inspect.getdoc(cls)
52 print ("<literallayout>%s</literallayout>" %
53 cgi.escape(description.strip()))
55 print '<informaltable><tgroup cols="2">'
56 print '<colspec colwidth="1*">'
57 print '<colspec colwidth="5*">'
60 print " <entry>Method</entry>"
61 print " <entry>Description</entry>"
64 print '<tbody valign="top">'
66 for cmd in CHECKED_COMMANDS:
67 if not hasattr(cls, cmd):
71 text = inspect.getdoc(getattr(cls, cmd))
76 print " <entry>%s</entry>" % cgi.escape(cmd)
77 print (" <entry><literallayout>%s</literallayout></entry>" %
78 cgi.escape(text.strip()))
82 print "</tgroup></informaltable>"
87 if __name__ == "__main__":