Branch: Tag:

1996-03-29

1996-03-29 22:32:45 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

now works

Rev: bin/htmlify_docs.lpc:1.6

10:   mapping subpages = ([]);      string new_path; + int writepages;    -  +    /*    * Implode an array of strings to an english 'list'    * ie. ({"foo","bar","gazonk"}) beomces "foo bar, gazonk"
240:   inherit "/precompiled/regexp":is_example;      list(string) indexes_done=(<>); - string mkindex(string topic, int head) + string mkindex(string topic, int usehead)   {    string head;    string a,ret;
250:       switch(topic)    { +  case "pages": +  head="<b>All pages:</b>\n"; +  ret="<ul>\n"; +  foreach(sort_array(m_indices(pages)),a) +  ret+="<li><a href="+pages[a]+">"+a+"</a>"+short(a)+"\n"; +  +  ret+="</ul>\n"; +  break; +     case "programs":    head="<b>Builtin programs:</b>\n";    ret="<ul>\n";    foreach(sort_array(m_indices(pages)),a)    { -  if(-1 == search(a,"/")) continue; +  if(a[0]!='/') continue;       ret+="<li><a href="+pages[a]+">"+a+"</a>"+short(a)+"\n";    }
263:    ret+="</ul>\n";    break;    +  case "examples": +  head="<b>examples:</b>\n"; +  ret="<ul>\n"; +  foreach(sort_array(m_indices(pages)),a) +  { +  if(search(a,"example")==-1) continue; +  +  ret+="<li><a href="+pages[a]+">"+a+"</a>"+short(a)+"\n"; +  } +  +  ret+="</ul>\n"; +  break; +     case "other":    head="<b>Other pages</b>\n";    ret="<ul>\n"; -  foreach(sort_array(m_indices(pages) - `+(@m_values(keywords))),a) +  foreach(sort_array(m_indices(pages) - +  map_array(`|(@m_values(keywords)),html_quote) - +  map_array(m_indices(all_efuns()),html_quote)),a)    { -  if(-1 != search(a,"/")) continue; +  if(a[0]=='/') continue; +  if(a[0..4]=="index") continue; +  if(search(a,"example")!=-1) continue;    ret+="<li><a href="+pages[a]+">"+a+"</a>"+short(a)+"\n";    }    ret+="</ul>\n";
284:    {    ret+="<li><a href="+pages[a]+">"+a+"</a>"+short(a)+"\n";    }else{ +  if(writepages)    perror("Warning: no page for function: "+a+".\n");    }    }
302:    head+=short(topic);    head+="</b>\n";    ret="<ul>\n"; -  foreach(keywords[topic],a) +  foreach(sort_array(keywords[topic]),a)    {    a=html_quote(a);    ret+="<li><a href="+pages[a]+">"+a+"</a>"+ short(a) +"\n";
311:    break;    }    -  if(head) ret=head+ret; +  if(usehead) ret=head+ret;       return ret;   }    - int writepages; -  +    /* Convert a page */   string convert_page(string path, string fname)   {
402:    foreach(a,a)    {    // fixme!! -  keywords[a] = ( keywords[a] || ({}) ) + ({ name }); +  keywords[a] = ( keywords[a] || ({}) ) | ({ name });    b+=({ "<a href=index.html#"+a+">"+a+"</a>" });    }    rest=implode_nicely(b);
455:    smallcaps(type)+    "<dd>\n"+rest+"\n<p>";    } +  if(keywords[part_name]) +  { +  sections+=({"<dt>"+ +  smallcaps("RELATED PAGES")+"\n"+ +  mkindex(part_name,0)+"<p>"}); +  }    parts[partno]="<dl>\n"+implode(sections,"\n")+"\n</dl>\n";    if(part_name)    {
479:       for(section=0;section<sizeof(sections);section++)    { -  string tmp,pre,a; +  string tmp,pre,a,b;    tmp=sections[section];    sscanf(tmp,"%[\t ]",pre);       switch(pre)    {    case "": -  tmp="<h1><center>"+tmp+"</center></h1>"; +     title=tmp; -  +  tmp="<h1><center>"+tmp+"</center></h1>";    break;       case " ":
510:    tmp=mkindex(a, 1);    break;    +  case "KEYWORD_LIST": +  sscanf(a,"%s\n",a); +  tmp=mkindex(a, 0); +  break; +  +  case "LINK": +  sscanf(a,"%s %s",a,b); +  tmp="<a href="+a+".html>"+b+"</a>"; +  break; +     default:    perror("Unknown directive: "+pre+".\n");    }       } -  +  sections[section]=tmp;    }    cont=implode(sections,"\n<p>\n");   
671:    traversedir(".",scanfiles);       write("Writing html files.\n"); -  writepages=0; +  writepages=1;    traversedir(".",scanfiles);       foreach(indices(keywords) - indices(indexes_done),np)