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