1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Holds the constants for pretty printing histograms.xml."""
10 sys
.path
.append(os
.path
.join(os
.path
.dirname(__file__
), '..', 'common'))
11 import pretty_print_xml
13 # Desired order for tag attributes; attributes listed here will appear first,
14 # and in the same order as in these lists.
15 # { tag_name: [attribute_name, ...] }
17 'enum': ['name', 'type'],
18 'histogram': ['name', 'enum', 'units'],
19 'int': ['value', 'label'],
20 'histogram_suffixes': ['name', 'separator', 'ordering'],
21 'suffix': ['name', 'label'],
22 'affected-histogram': ['name'],
23 'with-suffix': ['name'],
26 # Tag names for top-level nodes whose children we don't want to indent.
27 TAGS_THAT_DONT_INDENT
= [
28 'histogram-configuration',
30 'histogram_suffixes_list',
34 # Extra vertical spacing rules for special tag names.
35 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)}
36 TAGS_THAT_HAVE_EXTRA_NEWLINE
= {
37 'histogram-configuration': (2, 1, 1),
38 'histograms': (2, 1, 1),
39 'histogram': (1, 1, 1),
40 'histogram_suffixes_list': (2, 1, 1),
41 'histogram_suffixes': (1, 1, 1),
46 # Tags that we allow to be squished into a single line for brevity.
47 TAGS_THAT_ALLOW_SINGLE_LINE
= [
55 """Returns an XmlStyle object for pretty printing histograms."""
56 return pretty_print_xml
.XmlStyle(ATTRIBUTE_ORDER
,
57 TAGS_THAT_HAVE_EXTRA_NEWLINE
,
58 TAGS_THAT_DONT_INDENT
,
59 TAGS_THAT_ALLOW_SINGLE_LINE
)