]> Creatis software - bbtk.git/blob - kernel/appli/bbRegeneratePackageDoc/bbRegeneratePackageDoc.cpp
Created 2 applis :
[bbtk.git] / kernel / appli / bbRegeneratePackageDoc / bbRegeneratePackageDoc.cpp
1
2 #include <bbtkWx.h>
3 #include <bbtkInterpreter.h>
4 #include <bbtkConfigurationFile.h>
5 #include <bbtkUtilities.h>
6
7 //==========================================================================
8 void RegenerateDoc ( bbtk::Package::Pointer p, std::string& doc_path )
9 {
10         std::string pack_name(p->GetName());
11         std::string pack_path = doc_path + pack_name;
12         // Creating directory
13         if ( ! bbtk::Utilities::FileExists(pack_path) )
14         {
15                 std::string command("mkdir \"" +pack_path+ "\"");
16                 system( command.c_str() );
17         }
18         std::string pack_index(pack_path);
19         pack_index += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
20         pack_index += "index.html";
21
22         std::cout << "* Generating doc for '"<<pack_name<<"' in "
23                           << pack_index << std::endl;
24                         
25         p->SetDocURL(pack_index);
26         p->SetDocRelativeURL("index.html");
27         p->CreateHtmlPage(pack_index,"bbtk",pack_name,"","",0,0,true);
28 }
29
30 //==========================================================================
31 int main(int argc, char **argv)
32 {
33         std::string pack("*");
34         if (argc==1)
35         {
36                 /*
37                 // TO DO : make a Wx app
38            wxString name = wxGetTextFromUser(_T("Enter package name (* for all)"),
39                              _T("Regenerate package doc"),
40                              _T(""));
41            if (name.IsEmpty()) return 0;
42            pack = bbtk::wx2std(name);
43         */
44         }
45         else if (argc==2) 
46         {
47                 pack = std::string(argv[1]);
48         }
49         else 
50         {
51                 std::cout << "usage : bbRegeneratePackageDoc [package-name]" << std::endl;
52                 return 0;
53         }
54
55         try
56     {
57                 std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
58                 doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
59                 doc_path += "bbdoc";
60                 doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
61
62                 bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
63                 I->SetCommandLine(true);
64                 I->SetThrow(false);
65                 I->InterpretLine( "exec freeze");
66                 I->InterpretLine( "include "+pack);
67                 if (pack != "*") 
68                 {
69                         I->InterpretLine( "include "+pack+"-appli");
70                         RegenerateDoc(I->GetExecuter()->GetFactory()->GetPackage(pack),doc_path);
71                 }
72                 else
73                 {
74                         bbtk::Factory::PackageMapType::const_iterator i;
75                         for (i  = I->GetExecuter()->GetFactory()->GetPackageMap().begin();
76                                 i != I->GetExecuter()->GetFactory()->GetPackageMap().end();
77                                 ++i)
78                         {
79                                 RegenerateDoc(i->second,doc_path);
80                         }
81                 }
82         }
83         catch (bbtk::Exception e)
84         {
85                 std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
86                 return 1;
87         }
88         return 0;
89 }
90 //==========================================================================
91
92