]> Creatis software - bbtk.git/blob - kernel/appli/bbRegeneratePackageDoc/bbRegeneratePackageDoc.cpp
Commented the aborts launched at installation time.
[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   std::string pack("-a");
49   if (argc==2) 
50     {
51       pack = std::string(argv[1]);
52     }
53   else if (argc==3)
54     {
55       pack = std::string(argv[1]);
56       std::string param(argv[2]);
57       if (param=="-q") bbtk::MessageManager::SetMessageLevel("max",0);
58       else if (param=="-v") bbtk::MessageManager::SetMessageLevel("all",9);
59       else 
60         {
61           Usage();
62           return 0;
63         }
64     }
65   else 
66     {
67       Usage();
68       return 0;
69     }
70  
71   try
72     {
73                 std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
74       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
75       doc_path += "bbdoc";
76       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
77       bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
78       I->SetCommandLine(true);
79       I->SetThrow(false);
80 //std::cout<<"JCP bbRegeneratePackageDoc.cpp  I->InterpretLine( exec freeze_no_error);"<<std::endl;
81           I->InterpretLine( "exec freeze_no_error");
82       if (pack != "-a") 
83         {
84
85                 I->InterpretLine( "include "+pack);
86                 I->InterpretLine( "include "+pack+"-appli");
87                 bbtk::Package::Pointer p = I->GetExecuter()->GetFactory()->GetPackage(pack);
88 //std::cout<<"JCP bbRegeneratePackageDoc.cpp RegenerateDoc(I->GetExecuter()->GetFactory()->GetPackage(pack),doc_path);"<<std::endl;
89                 RegenerateDoc(I->GetExecuter()->GetFactory()->GetPackage(pack),doc_path);
90         }
91       else
92         {
93 //std::cout<<"JCP bbRegeneratePackageDoc.cpp I->InterpretLine( include );"<<std::endl;
94                 I->InterpretLine( "include *");
95                 bbtk::Factory::PackageMapType::const_iterator i;
96           for (i  = I->GetExecuter()->GetFactory()->GetPackageMap().begin();
97                i != I->GetExecuter()->GetFactory()->GetPackageMap().end();
98                ++i)
99             {
100 //std::cout<<" if (i->second->GetName()==user) continue;"<<std::endl;
101               if (i->second->GetName()=="user") continue;
102               RegenerateDoc(i->second,doc_path);
103             }
104         }
105     }
106   catch (bbtk::Exception e)
107     {
108       std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
109       return 1;
110     }
111     // JGRR & CM : this kills this never-ending process when it's supposed to! 
112     std::cout << "bbRegeneratePackageDoc has finished normally. It will be aborted on purpose."<< std::endl; 
113     abort();
114     // EO JGRR CM
115         return 0;
116 }
117 //==========================================================================
118
119