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

Function FinalizeDoc

tensorflow/core/framework/op_def_builder.cc:464–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464void FinalizeDoc(const string& text, OpDef* op_def,
465 std::vector<string>* errors) {
466 std::vector<string> lines = str_util::Split(text, '\n');
467
468 // Remove trailing spaces.
469 for (string& line : lines) {
470 absl::StripTrailingAsciiWhitespace(&line);
471 }
472
473 // First non-blank line -> summary.
474 int l = 0;
475 while (static_cast<size_t>(l) < lines.size() && lines[l].empty()) ++l;
476 if (static_cast<size_t>(l) < lines.size()) {
477 op_def->set_summary(lines[l]);
478 ++l;
479 }
480 while (static_cast<size_t>(l) < lines.size() && lines[l].empty()) ++l;
481
482 // Lines until we see name: -> description.
483 int start_l = l;
484 while (static_cast<size_t>(l) < lines.size() && !IsDocNameColon(lines[l])) {
485 ++l;
486 }
487 int end_l = l;
488 // Trim trailing blank lines from the description.
489 while (start_l < end_l && lines[end_l - 1].empty()) --end_l;
490 string desc = absl::StrJoin(
491 gtl::ArraySlice<string>(lines.data() + start_l, end_l - start_l), "\n");
492 if (!desc.empty()) op_def->set_description(desc);
493
494 // name: description
495 // possibly continued on the next line
496 // if so, we remove the minimum indent
497 StringPiece name;
498 std::vector<StringPiece> description;
499 while (static_cast<size_t>(l) < lines.size()) {
500 description.clear();
501 description.push_back(lines[l]);
502 ConsumeDocNameColon(&description.back(), &name);
503 ++l;
504 while (static_cast<size_t>(l) < lines.size() && !IsDocNameColon(lines[l])) {
505 description.push_back(lines[l]);
506 ++l;
507 }
508 // Remove any trailing blank lines.
509 while (!description.empty() && description.back().empty()) {
510 description.pop_back();
511 }
512 // Compute the minimum indent of all lines after the first.
513 int min_indent = -1;
514 for (size_t i = 1; i < description.size(); ++i) {
515 if (!description[i].empty()) {
516 int indent = num_leading_spaces(description[i]);
517 if (min_indent < 0 || indent < min_indent) min_indent = indent;
518 }
519 }
520 // Remove min_indent spaces from all lines after the first.
521 for (size_t i = 1; i < description.size(); ++i) {

Callers 1

FinalizeMethod · 0.85

Calls 14

IsDocNameColonFunction · 0.85
ConsumeDocNameColonFunction · 0.85
num_leading_spacesFunction · 0.85
pop_backMethod · 0.80
attrMethod · 0.80
SplitFunction · 0.70
nameMethod · 0.65
StrCatFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected