/src/jsonnet/core/formatter.h
Line | Count | Source |
1 | | /* |
2 | | Copyright 2015 Google Inc. All rights reserved. |
3 | | |
4 | | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | you may not use this file except in compliance with the License. |
6 | | You may obtain a copy of the License at |
7 | | |
8 | | http://www.apache.org/licenses/LICENSE-2.0 |
9 | | |
10 | | Unless required by applicable law or agreed to in writing, software |
11 | | distributed under the License is distributed on an "AS IS" BASIS, |
12 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | See the License for the specific language governing permissions and |
14 | | limitations under the License. |
15 | | */ |
16 | | |
17 | | #ifndef JSONNET_FORMATTER_H |
18 | | #define JSONNET_FORMATTER_H |
19 | | |
20 | | #include "ast.h" |
21 | | |
22 | | namespace jsonnet::internal { |
23 | | |
24 | | struct FmtOpts { |
25 | | char stringStyle; |
26 | | char commentStyle; |
27 | | unsigned indent; |
28 | | unsigned maxBlankLines; |
29 | | bool padArrays; |
30 | | bool padObjects; |
31 | | bool stripComments; |
32 | | bool stripAllButComments; |
33 | | bool stripEverything; |
34 | | bool prettyFieldNames; |
35 | | bool sortImports; |
36 | | FmtOpts(void) |
37 | 20.6k | : stringStyle('s'), |
38 | 20.6k | commentStyle('s'), |
39 | 20.6k | indent(2), |
40 | 20.6k | maxBlankLines(2), |
41 | 20.6k | padArrays(false), |
42 | 20.6k | padObjects(true), |
43 | 20.6k | stripComments(false), |
44 | 20.6k | stripAllButComments(false), |
45 | 20.6k | stripEverything(false), |
46 | 20.6k | prettyFieldNames(true), |
47 | 20.6k | sortImports(true) |
48 | 20.6k | { |
49 | 20.6k | } |
50 | | }; |
51 | | |
52 | | /** The inverse of jsonnet_parse. |
53 | | */ |
54 | | std::string jsonnet_fmt(AST *ast, Fodder &final_fodder, const FmtOpts &opts); |
55 | | |
56 | | } // namespace jsonnet::internal |
57 | | |
58 | | #endif // JSONNET_PARSER_H |