#!/usr/bin/python # # Copyright (C) 2008 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. """Script to generate documentation for remote API resources. """ import re import cgi import inspect from ganeti.rapi import rlib1 from ganeti.rapi import rlib2 from ganeti.rapi import connector CHECKED_COMMANDS = ["GET", "POST", "PUT", "DELETE"] def main(): # Get list of all resources all = list(connector.CONNECTOR.itervalues()) # Sort rlib1 by URI all.sort(cmp=lambda a, b: cmp(a.DOC_URI, b.DOC_URI)) print "" for cls in all: print "" print "%s" % cgi.escape(cls.DOC_URI) # Class docstring description = inspect.getdoc(cls) if description: print ("%s" % cgi.escape(description.strip())) print '' print '' print '' print "" print " " print " Method" print " Description" print " " print "" print '' for cmd in CHECKED_COMMANDS: if not hasattr(cls, cmd): continue # Get docstring text = inspect.getdoc(getattr(cls, cmd)) if not text: text = "" print "" print " %s" % cgi.escape(cmd) print (" %s" % cgi.escape(text.strip())) print "" print "" print "" print "" if __name__ == "__main__": main()