cmDocumentationFormatterUsage.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmDocumentationFormatterUsage.h"
  14. #include "cmDocumentationSection.h"
  15. cmDocumentationFormatterUsage::cmDocumentationFormatterUsage()
  16. :cmDocumentationFormatterText()
  17. {
  18. }
  19. void cmDocumentationFormatterUsage
  20. ::PrintSection(std::ostream& os,
  21. const cmDocumentationSection &section,
  22. const char* name)
  23. {
  24. if(name)
  25. {
  26. os << name << "\n";
  27. }
  28. const std::vector<cmDocumentationEntry> &entries =
  29. section.GetEntries();
  30. for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
  31. op != entries.end(); ++op)
  32. {
  33. if(op->Name.size())
  34. {
  35. os << " " << op->Name;
  36. this->TextIndent = " ";
  37. int align = static_cast<int>(strlen(this->TextIndent))-4;
  38. for(int i = static_cast<int>(op->Name.size()); i < align; ++i)
  39. {
  40. os << " ";
  41. }
  42. if (op->Name.size() > strlen(this->TextIndent)-4 )
  43. {
  44. os << "\n";
  45. os.write(this->TextIndent, strlen(this->TextIndent)-2);
  46. }
  47. os << "= ";
  48. this->PrintColumn(os, op->Brief.c_str());
  49. os << "\n";
  50. }
  51. else
  52. {
  53. os << "\n";
  54. this->TextIndent = "";
  55. this->PrintFormatted(os, op->Brief.c_str());
  56. }
  57. }
  58. os << "\n";
  59. }