Roll src/third_party/skia 199ba8e:bb928a0
[chromium-blink-merge.git] / tools / metrics / histograms / print_style.py
blobe09f762ad8930ebc33e174f1a8a347459e2a8b8b
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."""
7 import os
8 import sys
10 # Import the metrics/common module for pretty print xml.
11 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common'))
12 import pretty_print_xml
14 # Desired order for tag attributes; attributes listed here will appear first,
15 # and in the same order as in these lists.
16 # { tag_name: [attribute_name, ...] }
17 ATTRIBUTE_ORDER = {
18 'enum': ['name', 'type'],
19 'histogram': ['name', 'enum', 'units'],
20 'int': ['value', 'label'],
21 'histogram_suffixes': ['name', 'separator', 'ordering'],
22 'suffix': ['name', 'label'],
23 'affected-histogram': ['name'],
24 'with-suffix': ['name'],
27 # Tag names for top-level nodes whose children we don't want to indent.
28 TAGS_THAT_DONT_INDENT = [
29 'histogram-configuration',
30 'histograms',
31 'histogram_suffixes_list',
32 'enums'
35 # Extra vertical spacing rules for special tag names.
36 # {tag_name: (newlines_after_open, newlines_before_close, newlines_after_close)}
37 TAGS_THAT_HAVE_EXTRA_NEWLINE = {
38 'histogram-configuration': (2, 1, 1),
39 'histograms': (2, 1, 1),
40 'histogram': (1, 1, 1),
41 'histogram_suffixes_list': (2, 1, 1),
42 'histogram_suffixes': (1, 1, 1),
43 'enums': (2, 1, 1),
44 'enum': (1, 1, 1),
47 # Tags that we allow to be squished into a single line for brevity.
48 TAGS_THAT_ALLOW_SINGLE_LINE = [
49 'summary',
50 'int',
51 'owner',
55 def GetPrintStyle():
56 """Returns an XmlStyle object for pretty printing histograms."""
57 return pretty_print_xml.XmlStyle(ATTRIBUTE_ORDER,
58 TAGS_THAT_HAVE_EXTRA_NEWLINE,
59 TAGS_THAT_DONT_INDENT,
60 TAGS_THAT_ALLOW_SINGLE_LINE)