def write_documentation(self, doc_type):
        """
        Build all the doc page for handlers

        :param doc_type: Type of doc to generate (controller, compute)
        """
        for handler_name in sorted(self._documentation):
            if "controller." in handler_name:
                server_type = "controller"
            elif "compute" in handler_name:
                server_type = "compute"
            else:
                server_type = "root"

            if doc_type != server_type:
                continue

            print("Build {}".format(handler_name))

            for path in sorted(self._documentation[handler_name]):

                api_version = self._documentation[handler_name][path]["api_version"]
                if api_version is None:
                    continue

                filename = self._file_path(path)
                handler_doc = self._documentation[handler_name][path]
                handler = handler_name.replace(server_type + ".", "")

                self._create_handler_directory(handler, api_version, server_type)
                with open("{}/api/v{}/{}/{}/{}.rst".format(self._directory, api_version, server_type, handler, filename), 'w+') as f:
                    f.write('{}\n------------------------------------------------------------------------------------------------------------------------------------------\n\n'.format(path))
                    f.write('.. contents::\n')
                    for method in handler_doc["methods"]:
                        f.write('\n{} {}\n'.format(method["method"], path.replace("{", '**{').replace("}", "}**")))
                        f.write('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
                        f.write('{}\n\n'.format(method["description"]))

                        if len(method["parameters"]) > 0:
                            f.write("Parameters\n**********\n")
                            for parameter in method["parameters"]:
                                desc = method["parameters"][parameter]
                                f.write("- **{}**: {}\n".format(parameter, desc))
                            f.write("\n")

                        f.write("Response status codes\n**********************\n")
                        for code in method["status_codes"]:
                            desc = method["status_codes"][code]
                            f.write("- **{}**: {}\n".format(code, desc))
                        f.write("\n")

                        if "properties" in method["input_schema"]:
                            f.write("Input\n*******\n")
                            self._write_definitions(f, method["input_schema"])
                            self._write_json_schema(f, method["input_schema"])

                        if "properties" in method["output_schema"]:
                            f.write("Output\n*******\n")
                            self._write_json_schema(f, method["output_schema"])

                        self._include_query_example(f, method, path, api_version, server_type)
def write_documentation ( self , doc_type ) : for handler_name in sorted ( self . _documentation ) : if "controller." in handler_name : server_type = "controller" elif "compute" in handler_name : server_type = "compute" else : server_type = "root" if doc_type != server_type : continue print ( "Build {}" . format ( handler_name ) ) for path in sorted ( self . _documentation [ handler_name ] ) : api_version = self . _documentation [ handler_name ] [ path ] [ "api_version" ] if api_version is None : continue filename = self . _file_path ( path ) handler_doc = self . _documentation [ handler_name ] [ path ] handler = handler_name . replace ( server_type + "." , "" ) self . _create_handler_directory ( handler , api_version , server_type ) with open ( "{}/api/v{}/{}/{}/{}.rst" . format ( self . _directory , api_version , server_type , handler , filename ) , 'w+' ) as f : f . write ( '{}\n------------------------------------------------------------------------------------------------------------------------------------------\n\n' . format ( path ) ) f . write ( '.. contents::\n' ) for method in handler_doc [ "methods" ] : f . write ( '\n{} {}\n' . format ( method [ "method" ] , path . replace ( "{" , '**{' ) . replace ( "}" , "}**" ) ) ) f . write ( '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' ) f . write ( '{}\n\n' . format ( method [ "description" ] ) ) if len ( method [ "parameters" ] ) > 0 : f . write ( "Parameters\n**********\n" ) for parameter in method [ "parameters" ] : desc = method [ "parameters" ] [ parameter ] f . write ( "- **{}**: {}\n" . format ( parameter , desc ) ) f . write ( "\n" ) f . write ( "Response status codes\n**********************\n" ) for code in method [ "status_codes" ] : desc = method [ "status_codes" ] [ code ] f . write ( "- **{}**: {}\n" . format ( code , desc ) ) f . write ( "\n" ) if "properties" in method [ "input_schema" ] : f . write ( "Input\n*******\n" ) self . _write_definitions ( f , method [ "input_schema" ] ) self . _write_json_schema ( f , method [ "input_schema" ] ) if "properties" in method [ "output_schema" ] : f . write ( "Output\n*******\n" ) self . _write_json_schema ( f , method [ "output_schema" ] ) self . _include_query_example ( f , method , path , api_version , server_type )
Build all the doc page for handlers

        :param doc_type: Type of doc to generate (controller, compute)