cmDocumentationFormatterMan.cxx 2.3 KB

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