| 152 | } |
| 153 | |
| 154 | void cmRST::ProcessLine(std::string const& line) |
| 155 | { |
| 156 | bool lastLineEndedInColonColon = this->LastLineEndedInColonColon; |
| 157 | this->LastLineEndedInColonColon = false; |
| 158 | |
| 159 | // A line starting in .. is an explicit markup start. |
| 160 | if (line == ".." || |
| 161 | (line.size() >= 3 && line[0] == '.' && line[1] == '.' && |
| 162 | cmsysString_isspace(line[2]))) { |
| 163 | this->Reset(); |
| 164 | this->MarkupType = |
| 165 | (line.find_first_not_of(" \t", 2) == std::string::npos ? Markup::Empty |
| 166 | : Markup::Normal); |
| 167 | // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165 |
| 168 | // NOLINTNEXTLINE(bugprone-branch-clone) |
| 169 | if (this->CMakeDirective.find(line)) { |
| 170 | // Output cmake domain directives and their content normally. |
| 171 | this->NormalLine(line); |
| 172 | } else if (this->CMakeModuleDirective.find(line)) { |
| 173 | // Process cmake-module directive: scan .cmake file comments. |
| 174 | std::string file = this->CMakeModuleDirective.match(1); |
| 175 | if (file.empty() || !this->ProcessInclude(file, Include::Module)) { |
| 176 | this->NormalLine(line); |
| 177 | } |
| 178 | } else if (this->ParsedLiteralDirective.find(line)) { |
| 179 | // Record the literal lines to output after whole block. |
| 180 | this->DirectiveType = Directive::ParsedLiteral; |
| 181 | this->MarkupLines.push_back(this->ParsedLiteralDirective.match(1)); |
| 182 | } else if (this->CodeBlockDirective.find(line)) { |
| 183 | // Record the literal lines to output after whole block. |
| 184 | // Ignore the language spec and record the opening line as blank. |
| 185 | this->DirectiveType = Directive::CodeBlock; |
| 186 | this->MarkupLines.emplace_back(); |
| 187 | } else if (this->ReplaceDirective.find(line)) { |
| 188 | // Record the replace directive content. |
| 189 | this->DirectiveType = Directive::Replace; |
| 190 | this->ReplaceName = this->ReplaceDirective.match(1); |
| 191 | this->MarkupLines.push_back(this->ReplaceDirective.match(2)); |
| 192 | } else if (this->IncludeDirective.find(line)) { |
| 193 | // Process the include directive or output the directive and its |
| 194 | // content normally if it fails. |
| 195 | std::string file = this->IncludeDirective.match(1); |
| 196 | if (file.empty() || !this->ProcessInclude(file, Include::Normal)) { |
| 197 | this->NormalLine(line); |
| 198 | } |
| 199 | } else if (this->TocTreeDirective.find(line)) { |
| 200 | // Record the toctree entries to process after whole block. |
| 201 | this->DirectiveType = Directive::TocTree; |
| 202 | this->MarkupLines.push_back(this->TocTreeDirective.match(1)); |
| 203 | } else if (this->ProductionListDirective.find(line)) { |
| 204 | // Output productionlist directives and their content normally. |
| 205 | this->NormalLine(line); |
| 206 | } else if (this->NoteDirective.find(line)) { |
| 207 | // Output note directives and their content normally. |
| 208 | this->NormalLine(line); |
| 209 | } else if (this->VersionDirective.find(line)) { |
| 210 | // Output versionadded and versionchanged directives and their content |
| 211 | // normally. |
no test coverage detected