| 145 | } |
| 146 | |
| 147 | void cmDocumentationFormatter::PrintSection( |
| 148 | std::ostream& os, cmDocumentationSection const& section) |
| 149 | { |
| 150 | std::size_t const PREFIX_SIZE = |
| 151 | sizeof(cmDocumentationEntry::CustomNamePrefix) + 1u; |
| 152 | // length of the "= " literal (see below) |
| 153 | std::size_t const SUFFIX_SIZE = 2u; |
| 154 | // legacy magic number ;-) |
| 155 | std::size_t const NAME_SIZE = 29u; |
| 156 | |
| 157 | std::size_t const PADDING_SIZE = PREFIX_SIZE + SUFFIX_SIZE; |
| 158 | std::size_t const TITLE_SIZE = NAME_SIZE + PADDING_SIZE; |
| 159 | |
| 160 | auto const savedIndent = this->TextIndent; |
| 161 | |
| 162 | os << section.GetName() << '\n'; |
| 163 | |
| 164 | for (cmDocumentationEntry const& entry : section.GetEntries()) { |
| 165 | if (!entry.Name.empty()) { |
| 166 | this->TextIndent = TITLE_SIZE; |
| 167 | os << std::setw(PREFIX_SIZE) << std::left << entry.CustomNamePrefix |
| 168 | << std::setw(int(std::max(NAME_SIZE, entry.Name.size()))) |
| 169 | << entry.Name; |
| 170 | if (entry.Name.size() > NAME_SIZE) { |
| 171 | os << '\n' << std::setw(int(this->TextIndent - PREFIX_SIZE)) << ' '; |
| 172 | } |
| 173 | os << "= " << this->Format(entry.Brief).substr(this->TextIndent); |
| 174 | } else { |
| 175 | this->TextIndent = 0u; |
| 176 | os << '\n' << this->Format(entry.Brief); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | os << '\n'; |
| 181 | |
| 182 | this->TextIndent = savedIndent; |
| 183 | } |
| 184 | |
| 185 | void cmDocumentationFormatter::PrintFormatted(std::ostream& os, |
| 186 | std::string const& text) const |