1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDumpDocumentation.cxx,v $
6 Date: $Date: 2007-12-13 22:56:49 $
7 Version: $Revision: 1.20 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 // Program extracts documentation describing commands from
22 #include "cmDocumentation.h"
23 #include "cmVersion.h"
25 //----------------------------------------------------------------------------
26 static const char *cmDocumentationName
[][3] =
29 " DumpDocumentation - Dump documentation for CMake.", 0},
33 //----------------------------------------------------------------------------
34 static const char *cmDocumentationUsage
[][3] =
37 " DumpDocumentation [filename]", 0},
41 //----------------------------------------------------------------------------
42 static const char *cmDocumentationDescription
[][3] =
45 "The \"DumpDocumentation\" executable is only available in the build "
46 "tree. It is used for testing, coverage, and documentation.", 0},
47 CMAKE_STANDARD_INTRODUCTION
,
51 //----------------------------------------------------------------------------
52 static const char *cmDocumentationOptions
[][3] =
54 {"--all-for-coverage",
55 "Dump all documentation to stdout. For testing.", 0},
60 int DumpHTML(const char* outname
)
62 std::ofstream
fout(outname
);
65 std::cerr
<< "failed to open output file: " << outname
<< "\n";
66 cmSystemTools::ReportLastSystemError("");
72 std::vector
<cmDocumentationEntry
> commands
;
73 cmi
.GetCommandDocumentation(commands
);
75 str
<< "Documentation for Commands of CMake "
76 << cmVersion::GetCMakeVersion();
77 doc
.SetSection(str
.str().c_str(), commands
);
78 doc
.Print(cmDocumentation::HTMLForm
, fout
);
83 int DumpForCoverageToStream(std::ostream
& out
)
87 std::vector
<cmDocumentationEntry
> commands
;
88 std::vector
<cmDocumentationEntry
> generators
;
89 cmi
.GetCommandDocumentation(commands
);
90 cmi
.GetGeneratorDocumentation(generators
);
91 doc
.SetSection("Name",cmDocumentationName
);
92 doc
.SetSection("Usage",cmDocumentationUsage
);
93 doc
.SetSection("Description",cmDocumentationDescription
);
94 doc
.SetSection("options",cmDocumentationOptions
);
95 doc
.SetSection("Commands",commands
);
96 doc
.SetSection("Generators",generators
);
97 doc
.PrintDocumentation(cmDocumentation::Usage
, out
);
98 doc
.PrintDocumentation(cmDocumentation::Full
, out
);
102 int DumpForCoverage(const char* outname
)
106 std::ofstream
fout(outname
);
109 std::cerr
<< "failed to open output file: " << outname
<< "\n";
110 cmSystemTools::ReportLastSystemError("");
113 return DumpForCoverageToStream(fout
);
117 return DumpForCoverageToStream(std::cout
);
121 int main(int ac
, char** av
)
123 cmSystemTools::EnableMSVCDebugHook();
124 cmSystemTools::FindExecutableDirectory(av
[0]);
125 const char* outname
= "cmake.html";
126 bool coverage
= false;
129 if(strcmp(av
[1], "--all-for-coverage") == 0)
149 return DumpForCoverage(outname
);
153 return DumpHTML(outname
);