pike.git / bin / htmlify_docs.lpc

version» Context lines:

pike.git/bin/htmlify_docs.lpc:4:   // Written by Fredrik Hubinette, dark sourceror and inventor of BMML      mapping efuns = all_efuns();   mapping pages = ([]);   mapping short_descs = ([]);   mapping keywords = ([]);   mapping subpages = ([]);      string new_path;   int writepages; + string docdir;         /*    * Implode an array of strings to an english 'list'    * ie. ({"foo","bar","gazonk"}) beomces "foo bar, gazonk"    */   string implode_nicely(string *foo)   {    switch(sizeof(foo))    {
pike.git/bin/htmlify_docs.lpc:44:   /*    * convert original path to internal format    */   string fippel_path(string path)   {    sscanf(path,"./%s",path);    path=replace(path,"/","_");    if(path[strlen(path)-5..]==".bmml") path=path[..strlen(path)-6];    if(path[strlen(path)-5..]!=".html") path+=".html";    -  return path; +  return docdir+path;   }      /*    * Three step conversion process...    */   string even_more_magic(string block, int indent)   {    if(-1==search(block,"\t"))    {    return replace(block,"\n","<br>\n");
pike.git/bin/htmlify_docs.lpc:686:    {    np=combine_path(new_path,fippel_path(path));   // write("Writing "+np+".\n");    if(file_size(np)>=0)    rm (np);    write_file(np,nf);    }   }      /** Traverse directory **/ - void traversedir(string path,function fun) + void traversedir(string path)   {    string file;    foreach(get_dir(path) - ({"CVS","RCS",".cvsignore"}),file)    {    string tmp;    if(file[-1]=='~') continue;    if(file[0]=='#' && file[-1]=='#') continue;    if(file[0]=='.' && file[1]=='#') continue;       tmp=path+"/"+file;       if(file_size(tmp)==-2)    {    traversedir(tmp,fun);    }else{ -  fun(tmp,file); +  scanfiles(tmp,file);    }    }   }    -  + void dodocs(string path, int module) + { +  cd(path); +  if(!module) +  { +  docdir=""; +  }else{ +  docdir="module"+module; +  if(sscanf(reverse(path),"cod/%s",docdir)) +  { +  sscanf(docdir,"%s/",docdir); +  docdir=reverse(docdir); +  } +  docdir+="_"; +  } +  traversedir("."); + } +    int main(int argc, string *argv)   {    string np; -  +  int e;    -  +  if(argc < 3) +  { +  perror("Usage: html_docs.lpc to_path from_path [module_doc_path ...]\n"); +  exit(0); +  } +     megamagic::create("^(.*)&lt;([a-z_0-9]+)&gt;(.*)$");    lastident::create("^(.*[^<>a-z_0-9])([a-z_0-9]+)([^<>a-z_0-9]*)$");      #define BEGIN1 "[0-9]+(\\.[0-9]+)*(\\.|) "   #define BEGIN2 "\t"   #define BEGIN3 " "   #define LEND "[^\n]*"   #define LINE "(" BEGIN1 LEND ")|(" BEGIN2 LEND ")|(" BEGIN3 LEND ")|()\n"       is_example::create("^(" LINE ")+$");    -  new_path=combine_path(getcwd(),argv[2]); -  cd(argv[1]); +  for(e=1;e<sizeof(argv);e++) +  argv[e]=combine_path(getcwd(),argv[e]);       write("Scanning pages for links and keywords.\n");    writepages=0; -  traversedir(".",scanfiles); +  for(e=2;e<sizeof(argv);e++) dodocs(argv[e],e-2);       write("Writing html files.\n");    writepages=1; -  traversedir(".",scanfiles); +  for(e=2;e<sizeof(argv);e++) dodocs(argv[e],e-2);       foreach(indices(keywords) - indices(indexes_done),np)    {    perror("Keywords never indexed: "+np+"\n");    }   }