cmDocumentationFormatterMan.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "cmDocumentationFormatterMan.h"
  14. #include "cmDocumentationSection.h"
  15. #include "cmSystemTools.h"
  16. #include "cmVersion.h"
  17. cmDocumentationFormatterMan::cmDocumentationFormatterMan()
  18. :cmDocumentationFormatter()
  19. {
  20. }
  21. void cmDocumentationFormatterMan
  22. ::PrintSection(std::ostream& os,
  23. const cmDocumentationSection &section,
  24. const char* name)
  25. {
  26. if(name)
  27. {
  28. os << ".SH " << name << "\n";
  29. }
  30. const std::vector<cmDocumentationEntry> &entries =
  31. section.GetEntries();
  32. for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
  33. op != entries.end(); ++op)
  34. {
  35. if(op->Name.size())
  36. {
  37. os << ".TP\n"
  38. << ".B " << (op->Name.size()?op->Name.c_str():"*") << "\n";
  39. this->PrintFormatted(os, op->Brief.c_str());
  40. this->PrintFormatted(os, op->Full.c_str());
  41. }
  42. else
  43. {
  44. os << ".PP\n";
  45. this->PrintFormatted(os, op->Brief.c_str());
  46. }
  47. }
  48. }
  49. void cmDocumentationFormatterMan::PrintPreformatted(std::ostream& os,
  50. const char* text)
  51. {
  52. std::string man_text = text;
  53. cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
  54. os << man_text << "\n";
  55. }
  56. void cmDocumentationFormatterMan::PrintParagraph(std::ostream& os,
  57. const char* text)
  58. {
  59. std::string man_text = text;
  60. cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
  61. os << man_text << "\n\n";
  62. }
  63. //----------------------------------------------------------------------------
  64. void cmDocumentationFormatterMan::PrintHeader(const char* name,
  65. std::ostream& os)
  66. {
  67. os << ".TH " << name << " 1 \""
  68. << cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
  69. << "\" \"" << name
  70. << " " << cmVersion::GetCMakeVersion()
  71. << "\"\n";
  72. }