Commit 1f556803 authored by Brad King's avatar Brad King

ENH: Added cmDocumentation class to generate various forms of documentation. ...

ENH: Added cmDocumentation class to generate various forms of documentation.  Each executable will be able to generate its own documentation.
parent d9a74e1b
......@@ -9,6 +9,7 @@ cmRegularExpression.cxx
cmSourceFile.cxx
cmSystemTools.cxx
cmDirectory.cxx
cmDocumentation.cxx
cmDynamicLoader.cxx
cmCommands.cxx
cmTarget.cxx
......
......@@ -17,6 +17,7 @@
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
#include "../cmake.h"
#include "../cmDocumentation.h"
#include <signal.h>
#include <sys/ioctl.h>
......@@ -26,6 +27,30 @@
#include <curses.h>
#include <form.h>
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationName[] =
{
{"ccmake",
"- Curses Interface for CMake.", 0},
{0,0,0}
};
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationUsage[] =
{
{0,
"ccmake <path-to-source>", 0},
{0,0,0}
};
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationDescription[] =
{
{0,
"CMake reads ... ", 0},
{0,0,0}
};
cmCursesForm* cmCursesForm::CurrentForm=0;
extern "C"
......@@ -60,6 +85,16 @@ void CMakeErrorHandler(const char* message, const char* title, bool&, void* clie
int main(int argc, char** argv)
{
cmDocumentation doc;
if(cmDocumentation::Type ht = doc.CheckOptions(argc, argv))
{
doc.SetName(cmDocumentationName);
doc.SetUsage(cmDocumentationUsage);
doc.SetDescription(cmDocumentationDescription);
doc.Print(ht, std::cout);
return 0;
}
bool debug = false;
unsigned int i;
int j;
......
......@@ -19,6 +19,7 @@ cmakewizard.o \
cmakemain.o \
cmMakeDepend.o \
cmMakefile.o \
cmDocumentation.o \
cmGlobalGenerator.o \
cmLocalGenerator.o \
cmRegularExpression.o \
......
This diff is collapsed.
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _cmDocumentation_h
#define _cmDocumentation_h
#include "cmStandardIncludes.h"
/** Class to generate documentation. */
class cmDocumentation
{
public:
cmDocumentation();
enum Type { None, Usage, Help, HelpHTML, Man, Copyright, Version };
void Print(Type ht, std::ostream& os);
void PrintUsage(std::ostream& os);
void PrintHelp(std::ostream& os);
void PrintHelpHTML(std::ostream& os);
void PrintManPage(std::ostream& os);
void PrintCopyright(std::ostream& os);
void PrintVersion(std::ostream& os);
void SetCommands(const cmDocumentationEntry* d) {this->Commands = d;}
void SetDescription(const cmDocumentationEntry* d) {this->Description = d;}
void SetName(const cmDocumentationEntry* d) {this->Name = d;}
void SetOptions(const cmDocumentationEntry* d);
void SetUsage(const cmDocumentationEntry* d) {this->UsageHelp = d;}
Type CheckOptions(int argc, char** argv);
private:
void PrintColumn(std::ostream& os, int width,
const char* indent, const char* text);
void PrintManSection(std::ostream& os, const cmDocumentationEntry* section,
const char* name);
void PrintHelpSection(std::ostream& os, const cmDocumentationEntry* section);
void PrintHTMLEscapes(std::ostream& os, const char* text);
void PrintHelpHTMLSection(std::ostream& os,
const cmDocumentationEntry* section,
const char* header);
void PrintUsageSection(std::ostream& os,
const cmDocumentationEntry* section);
const cmDocumentationEntry* Commands;
const cmDocumentationEntry* Description;
const cmDocumentationEntry* Name;
std::vector<cmDocumentationEntry> Options;
const cmDocumentationEntry* UsageHelp;
};
#endif
......@@ -244,4 +244,12 @@ private:
};
#endif
/** Standard documentation entry for cmDocumentation's formatting. */
struct cmDocumentationEntry
{
const char* name;
const char* brief;
const char* full;
};
#endif
......@@ -2363,6 +2363,15 @@ void cmSystemTools::SplitProgramFromArgs(const char* path,
args = "";
}
std::string cmSystemTools::GetCurrentDateTime(const char* format)
{
char buf[1024];
time_t t;
time(&t);
strftime(buf, sizeof(buf), format, localtime(&t));
return buf;
}
std::string cmSystemTools::MakeCindentifier(const char* s)
{
std::string str(s);
......
......@@ -352,6 +352,8 @@ public:
*/
static FileFormat GetFileFormat(const char* ext);
static std::string GetCurrentDateTime(const char* format);
/**
* On Windows 9x we need a comspec (command.com) substitute to run
* programs correctly. This string has to be constant available
......
......@@ -1120,3 +1120,20 @@ void cmake::UpdateProgress(const char *msg, float prog)
return;
}
}
void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const
{
for(RegisteredCommandsMap::const_iterator j = m_Commands.begin();
j != m_Commands.end(); ++j)
{
cmDocumentationEntry e =
{
(*j).second->GetName(),
(*j).second->GetTerseDocumentation(),
(*j).second->GetFullDocumentation()
};
v.push_back(e);
}
cmDocumentationEntry empty = {0,0,0};
v.push_back(empty);
}
......@@ -232,6 +232,8 @@ class cmake
///! Get the variable watch object
cmVariableWatch* GetVariableWatch() { return m_VariableWatch; }
void GetCommandDocumentation(std::vector<cmDocumentationEntry>&) const;
protected:
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
RegisteredCommandsMap m_Commands;
......
......@@ -19,6 +19,31 @@
#include "cmCacheManager.h"
#include "cmDynamicLoader.h"
#include "cmListFileCache.h"
#include "cmDocumentation.h"
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationName[] =
{
{"cmake",
"- Cross-Platform Makefile Generator.", 0},
{0,0,0}
};
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationUsage[] =
{
{0,
"cmake <path-to-source>", 0},
{0,0,0}
};
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationDescription[] =
{
{0,
"CMake reads ... ", 0},
{0,0,0}
};
int do_cmake(int ac, char** av);
void updateProgress(const char *msg, float prog, void *cd);
......@@ -36,6 +61,20 @@ int main(int ac, char** av)
int do_cmake(int ac, char** av)
{
cmDocumentation doc;
if(cmDocumentation::Type ht = doc.CheckOptions(ac, av))
{
cmake hcm;
std::vector<cmDocumentationEntry> commands;
hcm.GetCommandDocumentation(commands);
doc.SetName(cmDocumentationName);
doc.SetUsage(cmDocumentationUsage);
doc.SetDescription(cmDocumentationDescription);
doc.SetCommands(&commands[0]);
doc.Print(ht, std::cout);
return 0;
}
bool wiz = false;
bool command = false;
std::vector<std::string> args;
......@@ -45,16 +84,13 @@ int do_cmake(int ac, char** av)
{
wiz = true;
}
else
else if (strcmp(av[i], "-E") == 0)
{
command = true;
}
else
{
if (strcmp(av[i], "-E") == 0)
{
command = true;
}
else
{
args.push_back(av[i]);
}
args.push_back(av[i]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment