Example #1
0
 def setUp(self):
     self.dm = docsmodel.DocsModel()
     self.schema = docsmodel.get_schema_from_file(
         'test_schemas/simple_object.json')
     self.parsed_items = self.dm.parse(self.schema)
Example #2
0
 def setUp(self):
     """Tests set up."""
     self.docs_model = docsmodel.DocsModel()
     self.schema = docsmodel.get_schema_from_file('test_schemas/enum.json')
Example #3
0
 def setUp(self):
     self.docs_model = docsmodel.DocsModel()
     self.schema = docsmodel.get_schema_from_file(
         'test_schemas/array_list.json')
Example #4
0
 def setUp(self):
     self.docs_model = docsmodel.DocsModel()
     self.schema = docsmodel.get_schema_from_file(
         'test_schemas/string_defaults.json')
     self.parsed_items = self.docs_model.parse(self.schema)
Example #5
0
 def setUp(self):
     self.dm = docsmodel.DocsModel()
     self.schema = docsmodel.get_schema_from_file(
         'test_schemas/number_defaults.json')
     self.parsed_items = self.dm.parse(self.schema)
Example #6
0
    def process(stuff):
        if isinstance(stuff, dict):
            l = [(k, process(v)) for (k, v) in stuff.iteritems()]
            keys = set(stuff)
            for order in orders:
                if keys.issubset(order) or keys.issuperset(order):
                    return OrderedDict(sorted(l, key=lambda x: order.get(x[0], 0)))
            return OrderedDict(sorted(l))
        if isinstance(stuff, list):
            return [process(x) for x in stuff]
        return stuff

    return process


SCHEMA_HTML_FILE = "schema.html"

schema = json.dumps(CONFIG_SCHEMA, sort_keys=True)
schema = json.loads(schema, object_pairs_hook=OrderedDict)

req = sorted(schema["required"])
custom_sort = make_custom_sort([req])
schema = custom_sort(schema)

parsed_items = docsmodel.DocsModel().parse(schema)[1:]
output = html_output.HtmlOutput().generate_output(parsed_items)

with open(SCHEMA_HTML_FILE, "wt") as f:
    f.write(output)