Exemple #1
0
    def setUp(self):
        self.root_node = tree.xml_string_to_tree(example_xml)
        collapse_resources(self.root_node)
        invert_method(self.root_node)

        self.resources = self.root_node.find_first("resources")
        self.method = self.root_node.find_first("method")
def main():
    """ Application entry point.
    Collects the command line options and passes them to wadl2rst for
    processing. """

    # get our config file from the arguments
    config_file = parse_arguments()
    config = yaml.load(file(config_file, 'r'))

    # for each wadl_file in the options
    for filename, options in config.items():
        print "Processing WADL: {}".format(filename)

        # resolve the entities in the wadl docs
        proc = subprocess.Popen(
            ['xmllint', '-noent', "-encode", "utf8", filename],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        )

        xml_data, err = proc.communicate()

        # if the returncode from this is bad, throw an error
        if proc.returncode != 0:
            print err
            sys.exit(1)

        # parse the xml file
        xml_data = unicode(xml_data, "utf-8")
        ir = tree.xml_string_to_tree(xml_data)
        execute_translations(ir, filename)
        convert_ir_to_rst(ir, filename, options)
Exemple #3
0
def main():
    """ Application entry point.
    Collects the command line options and passes them to wadl2rst for
    processing. """

    # get our config file from the arguments
    config_file = parse_arguments()
    config = yaml.load(file(config_file, 'r'))

    # for each wadl_file in the options
    for filename, options in config.items():
        print "Processing WADL: {}".format(filename)

        # resolve the entities in the wadl docs
        proc = subprocess.Popen(
            ['xmllint', '-noent', "-encode", "utf8", filename],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        )

        xml_data, err = proc.communicate()

        # if the returncode from this is bad, throw an error
        if proc.returncode != 0:
            print err
            sys.exit(1)

        # parse the xml file
        xml_data = unicode(xml_data, "utf-8")
        ir = tree.xml_string_to_tree(xml_data)
        execute_translations(ir, filename)
        convert_ir_to_rst(ir, filename, options)
Exemple #4
0
    def test_wrapped_no_responses(self):
        self.root_node = tree.xml_string_to_tree(test_no_responses_xml)
        wrap_response_elements(self.root_node)

        responses = self.root_node.find_first("responses")
        self.assertTrue(responses is not None)

        names = [c.attributes.get("name", None) for c in responses.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)
    def test_wrapped_no_params(self):
        self.root_node = tree.xml_string_to_tree(test_no_params_xml)
        wrap_param_elements(self.root_node)

        parameters = self.root_node.find_first("params")
        self.assertTrue(parameters is not None)

        names = [c.attributes.get("name", None) for c in parameters.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)
    def test_wrapped_no_params(self):
        self.root_node = tree.xml_string_to_tree(test_no_params_xml)
        wrap_param_elements(self.root_node)

        parameters = self.root_node.find_first("params")
        self.assertTrue(parameters is not None)

        names = [c.attributes.get("name", None) for c in parameters.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)
    def test_wrapped_no_responses(self):
        self.root_node = tree.xml_string_to_tree(test_no_responses_xml)
        wrap_response_elements(self.root_node)

        responses = self.root_node.find_first("responses")
        self.assertTrue(responses is not None)

        names = [c.attributes.get("name", None) for c in responses.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)
Exemple #8
0
def main():
    """ Application entry point.
    Collects the command line options and passes them to wadl2rst for
    processing. """

    # get our config file from the arguments
    config_file = parse_arguments()
    config = yaml.load(file(config_file, 'r'), Loader=yamlordereddictloader.Loader)

    # for each wadl_file in the options
    for filename, options in config.items():
        print "Processing WADL: {}".format(filename)

        # resolve the entities in the wadl docs
        proc = subprocess.Popen(
            ['xmllint', '-noent', "-encode", "utf8", filename],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        )

        xml_data, err = proc.communicate()

        # if the returncode from this is bad, throw an error
        if proc.returncode != 0:
            print err
            sys.exit(1)

        # location of the api samples json files in the target code repo
        # defaulting this to nova for now
        if 'samples_path' not in options:
            options['samples_path'] = '../../doc/api_samples'

        # parse the xml file
        xml_data = unicode(xml_data, "utf-8")
        ir = tree.xml_string_to_tree(xml_data)
        execute_translations(ir, filename, options['samples_path'])

        convert_ir_to_rst(ir,
                          options['output_file'],
                          options.get('preamble', ''),
                          options['title'])

    # Write out index
    with open('dist/index.rst', 'w') as f:
        f.write(""":tocdepth: 2

=============
 Compute API
=============
""")
        for filename, options in config.items():
            f.write(".. include:: %s\n" % os.path.basename(options['output_file']))
 def setUp(self):
     self.root_node = tree.xml_string_to_tree(example_xml)
     resolve_internal(self.root_node)
Exemple #10
0
 def setUp(self):
     self.root_node = tree.xml_string_to_tree(test_xml)
     cleanup_application_node(self.root_node)
 def setUp(self):
     self.root_node = tree.xml_string_to_tree(example_xml)
     collapse_resources(self.root_node)
     self.resource = self.root_node.find_first("resource")
 def setUp(self):
     self.root_node = tree.xml_string_to_tree(example_xml)
     resolve_internal(self.root_node)
 def setUp(self):
     self.root_node = tree.xml_string_to_tree(example_xml)
     collapse_resources(self.root_node)
     self.resource = self.root_node.find_first("resource")
 def setUp(self):
     self.root_node = tree.xml_string_to_tree(test_xml)
     cleanup_application_node(self.root_node)