]> 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 //==========================================================================
32 int main(int argc, char **argv)
33 {
34   std::string pack("-a");
35   if (argc==2) 
36     {
37       pack = std::string(argv[1]);
38     }
39   else if (argc==3)
40     {
41       pack = std::string(argv[1]);
42       bbtk::MessageManager::SetMessageLevel("max",0);
43     }
44   else 
45     {
46       std::cout << "usage : bbRegeneratePackageDoc [<package name>|-a] [-quiet]" << std::endl;
47       return 0;
48     }
49   
50   try
51     {
52       std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
53       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
54       doc_path += "bbdoc";
55       doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
56       
57       bbtk::Interpreter::Pointer I = bbtk::Interpreter::New();
58       I->SetCommandLine(true);
59       I->SetThrow(false);
60       I->InterpretLine( "exec freeze");
61       if (pack != "-a") 
62         {
63           I->InterpretLine( "include "+pack);
64           I->InterpretLine( "include "+pack+"-appli");
65           RegenerateDoc(I->GetExecuter()->GetFactory()->GetPackage(pack),doc_path);
66         }
67       else
68         {
69           I->InterpretLine( "include *");
70           bbtk::Factory::PackageMapType::const_iterator i;
71           for (i  = I->GetExecuter()->GetFactory()->GetPackageMap().begin();
72                i != I->GetExecuter()->GetFactory()->GetPackageMap().end();
73                ++i)
74             {
75               if (i->second->GetName()=="user") continue;
76               RegenerateDoc(i->second,doc_path);
77             }
78         }
79     }
80   catch (bbtk::Exception e)
81     {
82       std::cout << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
83       return 1;
84     }
85   return 0;
86 }
87 //==========================================================================
88
89