]> Creatis software - bbtk.git/blob - kernel/appli/bbRegeneratePackageDoc/bbRegeneratePackageDoc.cpp
BUG MACOS
[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         
11   std::string pack_name(p->GetName());
12   std::string pack_path = doc_path + pack_name;
13   // Creating directory
14   if ( ! bbtk::Utilities::FileExists(pack_path) )
15     {
16       std::string command("mkdir \"" +pack_path+ "\"");
17       system( command.c_str() );
18     }
19   std::string pack_index(pack_path);
20   pack_index += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
21   pack_index += "index.html";
22   
23   std::cout << "* Generating doc for package '"<<pack_name<<"' in "
24             << pack_index << std::endl;
25   
26   p->SetDocURL(pack_index);
27   p->SetDocRelativeURL("index.html");
28         
29         
30   p->CreateHtmlPage(pack_index,"bbtk",pack_name,"","",0,0,true); //true);
31         
32         
33 }
34
35
36 void Usage()
37 {
38   std::cout << "usage : bbRegeneratePackageDoc [<package name>|-a] [-q|-v]" 
39             << std::endl
40             << "        -a : All packages"<<std::endl
41             << "        -q : Quiet"<<std::endl
42             << "        -v : Verbose"<<std::endl;
43 }
44
45 //==========================================================================
46 int main(int argc, char **argv)
47 {
48
49   std::string pack("-a");
50   if (argc==2) 
51     {
52       pack = std::string(argv[1]);
53     }
54   else if (argc==3)
55     {
56       pack = std::string(argv[1]);
57       std::string param(argv[2]);
58       if (param=="-q") bbtk::MessageManager::SetMessageLevel("max",0);
59       else if (param=="-v") bbtk::MessageManager::SetMessageLevel("all",9);
60       else 
61         {
62           Usage();
63           return 0;
64         }
65     }
66   else 
67     {
68       Usage();
69       return 0;
70     }
71   
72   try
73     {
74                 std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
75       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
76       doc_path += "bbdoc";
77       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
78                                 
79       bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
80       I->SetCommandLine(true);
81       I->SetThrow(false);
82           I->InterpretLine( "exec freeze_no_error");
83       if (pack != "-a") 
84         {
85                 I->InterpretLine( "include "+pack);
86                 I->InterpretLine( "include "+pack+"-appli");
87                 bbtk::Package::Pointer p = I->GetExecuter()->GetFactory()->GetPackage(pack);
88                 
89                 RegenerateDoc(I->GetExecuter()->GetFactory()->GetPackage(pack),doc_path);
90         }
91       else
92         {
93 I->InterpretLine( "include *");
94                 bbtk::Factory::PackageMapType::const_iterator i;
95           for (i  = I->GetExecuter()->GetFactory()->GetPackageMap().begin();
96                i != I->GetExecuter()->GetFactory()->GetPackageMap().end();
97                ++i)
98             {
99               if (i->second->GetName()=="user") continue;
100               RegenerateDoc(i->second,doc_path);
101             }
102         }
103     }
104   catch (bbtk::Exception e)
105     {
106       std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
107       return 1;
108     }
109         return 0;
110 }
111 //==========================================================================
112
113