MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Indent

Function Indent

tensorflow/python/framework/python_op_gen_internal.cc:120–141  ·  view source on GitHub ↗

Indent the first line by "initial" spaces and all following lines by "rest" spaces.

Source from the content-addressed store, hash-verified

118// Indent the first line by "initial" spaces and all following lines
119// by "rest" spaces.
120string Indent(int initial, int rest, StringPiece in) {
121 // TODO(josh11b): Also word-wrapping?
122 string copy(in.data(), in.size());
123 absl::StripTrailingAsciiWhitespace(&copy);
124 std::vector<string> v = str_util::Split(copy, '\n');
125
126 string result;
127 bool first = true;
128 for (const string& line : v) {
129 if (first) {
130 result = strings::StrCat(Spaces(initial), line, "\n");
131 first = false;
132 } else {
133 if (line.empty()) {
134 strings::StrAppend(&result, "\n");
135 } else {
136 strings::StrAppend(&result, Spaces(rest), line, "\n");
137 }
138 }
139 }
140 return result;
141}
142
143// Adds append to *dest, with a space if the first line will be <= width,
144// or a newline otherwise.

Callers 4

GetReturnsFunction · 0.70
AddDocStringInputsMethod · 0.70
AddDocStringAttrsMethod · 0.70

Calls 7

SpacesFunction · 0.85
SplitFunction · 0.50
StrCatFunction · 0.50
StrAppendFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected