| 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 |
: stringStyle('s'), |
| 38 |
commentStyle('s'), |
| 39 |
indent(2), |
| 40 |
maxBlankLines(2), |
| 41 |
padArrays(false), |
| 42 |
padObjects(true), |
| 43 |
stripComments(false), |
| 44 |
stripAllButComments(false), |
| 45 |
stripEverything(false), |
| 46 |
prettyFieldNames(true), |
| 47 |
sortImports(true) |
| 48 |
{ |
| 49 |
} |
| 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 |