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