cmDocumentation.h 5.01 KB
Newer Older
1
2
3
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4

5
6
  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.
7

8
9
10
11
  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
12
13
14
15
#ifndef _cmDocumentation_h
#define _cmDocumentation_h

#include "cmStandardIncludes.h"
Alexander Neundorf's avatar
 
Alexander Neundorf committed
16
#include "cmProperty.h"
Alexander Neundorf's avatar
 
Alexander Neundorf committed
17
#include "cmDocumentationFormatter.h"
18
#include "cmDocumentationSection.h"
19
#include "cmake.h"
Alexander Neundorf's avatar
 
Alexander Neundorf committed
20

Alexander Neundorf's avatar
 
Alexander Neundorf committed
21
22
23
24
25
namespace cmsys
{
  class Directory;
}

26
/** Class to generate documentation.  */
Alexander Neundorf's avatar
 
Alexander Neundorf committed
27
class cmDocumentation: public cmDocumentationEnums
28
29
30
{
public:
  cmDocumentation();
31

32
  ~cmDocumentation();
33

34
35
  /**
   * Check command line arguments for documentation options.  Returns
36
37
   * true if documentation options are found, and false otherwise.
   * When true is returned, PrintRequestedDocumentation should be
38
   * called.  exitOpt can be used for things like cmake -E, so that
39
40
   * all arguments after the -E are ignored and not searched for
   * help arguments.
41
   */
42
  bool CheckOptions(int argc, const char* const* argv,
43
                    const char* exitOpt =0);
44

45
46
47
48
49
50
51
  /**
   * Print help requested on the command line.  Call after
   * CheckOptions returns true.  Returns true on success, and false
   * otherwise.  Failure can occur when output files specified on the
   * command line cannot be written.
   */
  bool PrintRequestedDocumentation(std::ostream& os);
52

53
  /** Print help of the given type.  */
54
  bool PrintDocumentation(Type ht, std::ostream& os);
55
56

  void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
57

58
  /** Set the program name for standard document generation.  */
59
60
  void SetName(const char* name);

61
  /** Set a section of the documentation. Typical sections include Name,
62
      Usage, Description, Options */
63
64
65
66
67
68
69
70
  void SetSection(const char *sectionName,
                  cmDocumentationSection *section);
  void SetSection(const char *sectionName,
                  std::vector<cmDocumentationEntry> &docs);
  void SetSection(const char *sectionName,
                  const char *docs[][3]);
  void SetSections(std::map<std::string,cmDocumentationSection *>
                   &sections);
71

72
73
74
  /** Add the documentation to the beginning/end of the section */
  void PrependSection(const char *sectionName,
                      const char *docs[][3]);
75
76
77
78
  void PrependSection(const char *sectionName,
                      std::vector<cmDocumentationEntry> &docs);
  void PrependSection(const char *sectionName,
                      cmDocumentationEntry &docs);
79
80
81
82
  void AppendSection(const char *sectionName,
                     const char *docs[][3]);
  void AppendSection(const char *sectionName,
                     std::vector<cmDocumentationEntry> &docs);
83
84
  void AppendSection(const char *sectionName,
                     cmDocumentationEntry &docs);
85

86
87
  /** Set cmake root so we can find installed files */
  void SetCMakeRoot(const char* root)  { this->CMakeRoot = root;}
Alexander Neundorf's avatar
 
Alexander Neundorf committed
88

89
90
91
92
93
94
95
96
97
98
99
100
  /** Add common (to all tools) documentation section(s) */
  void addCommonStandardDocSections();

  /** Add the CMake standard documentation section(s) */
  void addCMakeStandardDocSections();

  /** Add the CTest standard documentation section(s) */
  void addCTestStandardDocSections();

  /** Add the CPack standard documentation section(s) */
  void addCPackStandardDocSections();

101
private:
102

103
104
105
106
  void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
  void PrintNames(std::ostream& os, std::string const& pattern);
  bool PrintFiles(std::ostream& os, std::string const& pattern);

107
  bool PrintVersion(std::ostream& os);
108
109
110
111
112
113
114
115
116
117
118
119
  bool PrintHelpOneManual(std::ostream& os);
  bool PrintHelpOneCommand(std::ostream& os);
  bool PrintHelpOneModule(std::ostream& os);
  bool PrintHelpOnePolicy(std::ostream& os);
  bool PrintHelpOneProperty(std::ostream& os);
  bool PrintHelpOneVariable(std::ostream& os);
  bool PrintHelpListManuals(std::ostream& os);
  bool PrintHelpListCommands(std::ostream& os);
  bool PrintHelpListModules(std::ostream& os);
  bool PrintHelpListProperties(std::ostream& os);
  bool PrintHelpListVariables(std::ostream& os);
  bool PrintHelpListPolicies(std::ostream& os);
120
  bool PrintDocumentationUsage(std::ostream& os);
121

122
123
  const char* GetNameString() const;
  bool IsOption(const char* arg) const;
124

125
126
  bool ShowGenerators;

127
  std::string NameString;
128
  std::map<std::string,cmDocumentationSection*> AllSections;
129

130
  std::string CMakeRoot;
Alexander Neundorf's avatar
 
Alexander Neundorf committed
131
132
133
134
  std::string CurrentArgument;

  struct RequestedHelpItem
  {
135
    RequestedHelpItem(): HelpType(None) {}
Alexander Neundorf's avatar
 
Alexander Neundorf committed
136
    cmDocumentationEnums::Type HelpType;
Alexander Neundorf's avatar
 
Alexander Neundorf committed
137
138
139
140
141
    std::string Filename;
    std::string Argument;
  };

  std::vector<RequestedHelpItem> RequestedHelpItems;
142
143
144
  cmDocumentationFormatter Formatter;

  static void WarnFormFromFilename(RequestedHelpItem& request);
145
146
147
};

#endif