Branch: Tag:

1996-03-28

1996-03-28 21:32:34 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

not yet finished

Rev: bin/htmlify_docs.lpc:1.5

231:    "</html>");   }    + string short(string s) + { +  return short_descs[s] ? " - "+short_descs[s] : ""; + } +  +    inherit "/precompiled/regexp":is_example;      list(string) indexes_done=(<>);
292:    }       head="<a name="+topic+">"; -  head+="<b>"+capitalize(b)+"</a>"; -  head+=short(b); +  head+="<b>"+capitalize(topic)+"</a>"; +  head+=short(topic);    head+="</b>\n";    ret="<ul>\n"; -  foreach(keywords[b],a) +  foreach(keywords[topic],a)    {    a=html_quote(a);    ret+="<li><a href="+pages[a]+">"+a+"</a>"+ short(a) +"\n";
310:    return ret;   }    + int writepages; +    /* Convert a page */   string convert_page(string path, string fname)   {
321:       cont=read_bytes(path);    + // perror("foo: "+path[strlen(path)-5..]+".\n");    if(sscanf(cont,"NAME\n\t%s - %s\n",name,short))    {    int partno;       cont=html_quote(cont); -  +  path=fippel_path(path); +     short_descs[html_quote(name)]=short; -  +  pages[html_quote(name)]=path;    -  +     string *parts=explode(cont,"============================================================================\n");    for(partno=0;partno<sizeof(parts);partno++)    {
367:    perror("Warning NAME section broken!\n");    rest="\t<tt>"+part_name+"</tt> - "+b;    +  if(partno) +  { +  subpages[fname+"-&gt;"+part_name]=path+"#"+part_name; +  } +     case "DESCRIPTION":    case "NOTA BENE":    case "BUGS":
407:    }else if(subpages[fname+"-&gt;"+a]){    b+=({ "<a href="+subpages[name+"-&gt;"+a]+">" + a + "</a>" });    }else{ +  if(writepages)    perror("Warning, unlinked SEE ALSO: "+a+"\n");    b+=({ tmp });    }
424:    case "DIRECTIVE":    case "PREPROCESSOR DIRECTIVES":    rest="<tt>"+magic(rest,1)+"</tt>"; +  break;       case "RELATED FUNCTIONS":    a=name;
451:    string title;    int section;    +  pages[(path[..strlen(path)-6]/"/")[-1]]=fippel_path(path); +     cont=replace(cont,"$version",version());    cont=html_quote(cont);    sections=explode(cont,"\n\n");
459:    {    string tmp,pre,a;    tmp=sections[section]; -  sscanf(tmp,"%[\t ]",per); +  sscanf(tmp,"%[\t ]",pre);    -  switch(space) +  switch(pre)    {    case "":    tmp="<h1><center>"+tmp+"</center></h1>";
476:    case " ":    sscanf(tmp," %s",tmp);    tmp=replace(tmp,"\n ","\n"); -  tmp=more_magic(tmp); +  tmp=more_magic(tmp,0);    break;       case "\t":
484:    switch(pre)    {    case "KEYWORD_INDEX": +  sscanf(a,"%s\n",a);    tmp=mkindex(a, 1); -  +  break;       default:    perror("Unknown directive: "+pre+".\n");
498:    }    else if(path[strlen(path)-5..]==".html")    { +  pages[(path[..strlen(path)-6]/"/")[-1]]=fippel_path(path); +     if(sscanf(cont,"<title>%s</title>",part))    short_descs[(path/"/")[-1]]=part;    output=cont;
508:    string line,tmp;    int pre,p;    +  pages[(path/"/")[-1]]=fippel_path(path); +     if(sscanf(cont,"%*[0-9.] %s\n",part)==2)    short_descs[(path/"/")[-1]]=part;   
546:    output=mkdocument(output,"uLPC: "+    replace(explode(fname,"/")[-1],"_"," "));    } -  return output; - } -  -  - string short(string s) - { -  return short_descs[s] ? " - "+short_descs[s] : ""; - } -  - string convert_dot_bmml(string path, string fname) - { -  string output; -  -  output=""; -  -  if(path[strlen(path)-5..]==".bmml") -  { -  } -  return 0; - } -  - int writepages; -  - void scanfiles(string path, string fname) - { -  string nf,np; -  nf=convert(path, fname); -  -  if(nf && strlen(nf) && writepages) -  { -  np=combine_path(new_path,fippel_path(path)); - // write("Writing "+np+".\n"); -  if(file_size(np)>=0) -  rm (np); -  write_file(np,nf); -  } - } -  - /* -  * Pre-read all files and sort out where to link it to -  */ - void scanlinks(string path, string fname) - { -  string cont,name; -  cont=read_bytes(path); -  cont=html_quote(cont); -  -  if(sscanf(cont,"NAME\n\t%s -",name)) -  { -  path=fippel_path(path); -  pages[name]=path; -  -  int e; -  string *parts=explode(cont,"============================================================================\n"); -  for(e=1;e<sizeof(parts);e++) -  { -  string part_name; -  if(sscanf(parts[e],"NAME\n\t%s -",part_name)) -  { -  subpages[fname+"-&gt;"+part_name]=path+"#"+part_name; -  } -  } -  } -  else if(path[strlen(path)-5..]==".html") -  { -  pages[(path[..strlen(path)-6]/"/")[-1]]=fippel_path(path); -  } -  else if(is_example::match(cont)) -  { -  pages[(path/"/")[-1]]=fippel_path(path); -  } +     else    { -  +  if(writepages) +  {    string tmp;    int l, i;   
646:    }    perror("Warning: not converting "+path+".\n");    } +  output="";    } -  +  return output; + }       -  + void scanfiles(string path, string fname) + { +  string nf,np; +  nf=convert_page(path, fname); +  +  if(nf && strlen(nf) && writepages) +  { +  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)   {
686:       is_example::create("^(" LINE ")+$");    -  write("Scanning links.\n"); +     new_path=combine_path(getcwd(),argv[2]);    cd(argv[1]); -  traversedir(".",scanlinks); +     -  write("Scanning pages.\n"); +  write("Scanning pages for links and keywords.\n");    writepages=0;    traversedir(".",scanfiles);    -  write("Writing html.\n"); +  write("Writing html files.\n");    writepages=0;    traversedir(".",scanfiles);