]> Creatis software - bbtk.git/blob - kernel/appli/bbRegeneratePackageDoc/bbRegeneratePackageDoc.cpp
*** empty log message ***
[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 package '"<<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,false); //true);
28 }
29
30
31 void Usage()
32 {
33   std::cout << "usage : bbRegeneratePackageDoc [<package name>|-a] [-q|-v]" 
34             << std::endl
35             << "        -a : All packages"<<std::endl
36             << "        -q : Quiet"<<std::endl
37             << "        -v : Verbose"<<std::endl;
38 }
39
40 //==========================================================================
41 int main(int argc, char **argv)
42 {
43   std::string pack("-a");
44   if (argc==2) 
45     {
46       pack = std::string(argv[1]);
47     }
48   else if (argc==3)
49     {
50       pack = std::string(argv[1]);
51       std::string param(argv[2]);
52       if (param=="-q") bbtk::MessageManager::SetMessageLevel("max",0);
53       else if (param=="-v") bbtk::MessageManager::SetMessageLevel("all",9);
54       else 
55         {
56           Usage();
57           return 0;
58         }
59     }
60   else 
61     {
62       Usage();
63       return 0;
64     }
65   
66   try
67     {
68       std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
69       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
70       doc_path += "bbdoc";
71       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
72       
73       bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
74       I->SetCommandLine(true);
75       I->SetThrow(false);
76       I->InterpretLine( "exec freeze");
77       if (pack != "-a") 
78         {
79           I->InterpretLine( "include "+pack);
80           I->InterpretLine( "include "+pack+"-appli");
81           RegenerateDoc(I->GetExecuter()->GetFactory()->GetPackage(pack),doc_path);
82         }
83       else
84         {
85           I->InterpretLine( "include *");
86           bbtk::Factory::PackageMapType::const_iterator i;
87           for (i  = I->GetExecuter()->GetFactory()->GetPackageMap().begin();
88                i != I->GetExecuter()->GetFactory()->GetPackageMap().end();
89                ++i)
90             {
91               if (i->second->GetName()=="user") continue;
92               RegenerateDoc(i->second,doc_path);
93             }
94         }
95     }
96   catch (bbtk::Exception e)
97     {
98       std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
99       return 1;
100     }
101   return 0;
102 }
103 //==========================================================================
104
105