cmDocumentationFormatterUsage.cxx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmDocumentationFormatterUsage.h"
  11. #include "cmDocumentationSection.h"
  12. cmDocumentationFormatterUsage::cmDocumentationFormatterUsage()
  13. :cmDocumentationFormatterText()
  14. {
  15. }
  16. void cmDocumentationFormatterUsage
  17. ::PrintSection(std::ostream& os,
  18. const cmDocumentationSection &section,
  19. const char* name)
  20. {
  21. if(name)
  22. {
  23. os << name << "\n";
  24. }
  25. const std::vector<cmDocumentationEntry> &entries =
  26. section.GetEntries();
  27. for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
  28. op != entries.end(); ++op)
  29. {
  30. if(op->Name.size())
  31. {
  32. os << " " << op->Name;
  33. this->TextIndent = " ";
  34. int align = static_cast<int>(strlen(this->TextIndent))-4;
  35. for(int i = static_cast<int>(op->Name.size()); i < align; ++i)
  36. {
  37. os << " ";
  38. }
  39. if (op->Name.size() > strlen(this->TextIndent)-4 )
  40. {
  41. os << "\n";
  42. os.write(this->TextIndent, strlen(this->TextIndent)-2);
  43. }
  44. os << "= ";
  45. this->PrintColumn(os, op->Brief.c_str());
  46. os << "\n";
  47. }
  48. else
  49. {
  50. os << "\n";
  51. this->TextIndent = "";
  52. this->PrintFormatted(os, op->Brief.c_str());
  53. }
  54. }
  55. os << "\n";
  56. }