Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tools/gn/function_read_file.cc

Issue 2481423002: Convert gn docstrings to C++11 raw strings. (Closed)
Patch Set: Newlines Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "tools/gn/err.h" 6 #include "tools/gn/err.h"
7 #include "tools/gn/filesystem_utils.h" 7 #include "tools/gn/filesystem_utils.h"
8 #include "tools/gn/functions.h" 8 #include "tools/gn/functions.h"
9 #include "tools/gn/input_conversion.h" 9 #include "tools/gn/input_conversion.h"
10 #include "tools/gn/input_file.h" 10 #include "tools/gn/input_file.h"
11 #include "tools/gn/scheduler.h" 11 #include "tools/gn/scheduler.h"
12 12
13 // TODO(brettw) consider removing this. I originally wrote it for making the 13 // TODO(brettw) consider removing this. I originally wrote it for making the
14 // WebKit bindings but misundersood what was required, and didn't need to 14 // WebKit bindings but misundersood what was required, and didn't need to
15 // use this. This seems to have a high potential for misuse. 15 // use this. This seems to have a high potential for misuse.
16 16
17 namespace functions { 17 namespace functions {
18 18
19 const char kReadFile[] = "read_file"; 19 const char kReadFile[] = "read_file";
20 const char kReadFile_HelpShort[] = 20 const char kReadFile_HelpShort[] =
21 "read_file: Read a file into a variable."; 21 "read_file: Read a file into a variable.";
22 const char kReadFile_Help[] = 22 const char kReadFile_Help[] =
23 "read_file: Read a file into a variable.\n" 23 R"(read_file: Read a file into a variable.
24 "\n" 24
25 " read_file(filename, input_conversion)\n" 25 read_file(filename, input_conversion)
26 "\n" 26
27 " Whitespace will be trimmed from the end of the file. Throws an error\n" 27 Whitespace will be trimmed from the end of the file. Throws an error if the
28 " if the file can not be opened.\n" 28 file can not be opened.
29 "\n" 29
30 "Arguments:\n" 30 Arguments
31 "\n" 31
32 " filename\n" 32 filename
33 " Filename to read, relative to the build file.\n" 33 Filename to read, relative to the build file.
34 "\n" 34
35 " input_conversion\n" 35 input_conversion
36 " Controls how the file is read and parsed.\n" 36 Controls how the file is read and parsed. See "gn help input_conversion".
37 " See \"gn help input_conversion\".\n" 37
38 "\n" 38 Example
39 "Example\n" 39
40 " lines = read_file(\"foo.txt\", \"list lines\")\n"; 40 lines = read_file("foo.txt", "list lines"))";
scottmg 2016/11/08 00:27:53 here
41 41
42 Value RunReadFile(Scope* scope, 42 Value RunReadFile(Scope* scope,
43 const FunctionCallNode* function, 43 const FunctionCallNode* function,
44 const std::vector<Value>& args, 44 const std::vector<Value>& args,
45 Err* err) { 45 Err* err) {
46 if (args.size() != 2) { 46 if (args.size() != 2) {
47 *err = Err(function->function(), "Wrong number of arguments to read_file", 47 *err = Err(function->function(), "Wrong number of arguments to read_file",
48 "I expected two arguments."); 48 "I expected two arguments.");
49 return Value(); 49 return Value();
50 } 50 }
(...skipping 18 matching lines...) Expand all
69 *err = Err(args[0], "Could not read file.", 69 *err = Err(args[0], "Could not read file.",
70 "I resolved this to \"" + FilePathToUTF8(file_path) + "\"."); 70 "I resolved this to \"" + FilePathToUTF8(file_path) + "\".");
71 return Value(); 71 return Value();
72 } 72 }
73 73
74 return ConvertInputToValue(scope->settings(), file_contents, function, 74 return ConvertInputToValue(scope->settings(), file_contents, function,
75 args[1], err); 75 args[1], err);
76 } 76 }
77 77
78 } // namespace functions 78 } // namespace functions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698