diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2022-08-23 05:11:34 (GMT) |
---|---|---|
committer | Alex Turbov <i.zaufi@gmail.com> | 2022-11-17 12:35:01 (GMT) |
commit | 1d6c8797fc5ec28f548defd9e8e2d3131e6f3036 (patch) | |
tree | ae9c8062863b2d1e45eb2fed200dc86f2ccea0ca /Source | |
parent | 5f3f8118363e4e483471733d1a89d6ae6ab179f1 (diff) | |
download | CMake-1d6c8797fc5ec28f548defd9e8e2d3131e6f3036.zip CMake-1d6c8797fc5ec28f548defd9e8e2d3131e6f3036.tar.gz CMake-1d6c8797fc5ec28f548defd9e8e2d3131e6f3036.tar.bz2 |
cmDocumentationFormatter: Use `std::ostream` padding capabitily
… instead of manually print spaces to align fields.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentationFormatter.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index c6964d2..527e755 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -160,14 +160,13 @@ void cmDocumentationFormatter::PrintSection( const std::vector<cmDocumentationEntry>& entries = section.GetEntries(); for (cmDocumentationEntry const& entry : entries) { if (!entry.Name.empty()) { - os << std::setw(2) << std::left << entry.CustomNamePrefix << entry.Name; this->TextIndent = NAME_SIZED_PADDING; - int align = static_cast<int>(this->TextIndent.size()) - 4; - for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) { - os << ' '; - } - if (static_cast<int>(entry.Name.size()) > align) { - os << '\n' << this->TextIndent.substr(0, this->TextIndent.size() - 2); + os << std::setw(2) << std::left << entry.CustomNamePrefix + << std::setw( + int(std::max(this->TextIndent.size() - 4, entry.Name.size()))) + << entry.Name; + if (entry.Name.size() > (this->TextIndent.size() - 4)) { + os << '\n' << std::setw(int(this->TextIndent.size() - 2)) << ' '; } os << "= "; this->PrintColumn(os, entry.Brief.c_str()); |