forward_function setup_sources
function setup_sources,base
compile_opt idl2
sources = findfile(base+'*')
i = where( strpos(sources,':') gt 0,cnt)
if cnt gt 0 then sources = sources[i] else return,''
i = where( strpos(sources,'SCCS') lt 0,cnt)
if cnt gt 0 then sources = sources[i] else return,''
i = where( strpos(sources,'obsolete') lt 0,cnt)
if cnt gt 0 then sources = sources[i] else return,''
on_ioerror,cantwrite
indx = [-1]
for i = 0,n_elements(sources)-1 do begin
sepsource = str_sep(sources[i],':')
sources[i] = sepsource[0]
openw,lun,sources[i]+'/foo',/get_lun,/delete
free_lun,lun
indx = [indx,i]
cantwrite:
endfor
if n_elements(indx) eq 1 then return,''
sources = sources[indx[1:*]]
for i = 0,n_elements(sources)-1 do $
sources = [sources,setup_sources(sources[i]+'/')]
i = where(sources ne '',cnt)
if cnt gt 0 then sources = sources[i] else return,''
return,sources
end
PRO alt_mhh_strict, txtlines
compile_opt idl2
count = N_ELEMENTS(txtlines)
FOR i=0,count-1 DO BEGIN
txt = txtlines[i]
spos = STRPOS(txt,'&')
WHILE (spos NE -1) DO BEGIN
newtxt = STRMID(txt,0,spos)+'&'+STRMID(txt,spos+1,STRLEN(txt)-spos+1)
txt = newtxt
spos = STRPOS(txt,'&',spos+1)
ENDWHILE
txtlines[i] = txt
spos = STRPOS(txt,'<')
WHILE (spos NE -1) DO BEGIN
newtxt = STRMID(txt,0,spos)+'<'+STRMID(txt,spos+1,STRLEN(txt)-spos+1)
txt = newtxt
spos = STRPOS(txt,'<',spos+1)
ENDWHILE
txtlines[i] = txt
spos = STRPOS(txt,'>')
WHILE (spos NE -1) DO BEGIN
newtxt = STRMID(txt,0,spos)+'>'+STRMID(txt,spos+1,STRLEN(txt)-spos+1)
txt = newtxt
spos = STRPOS(txt,'>',spos+1)
ENDWHILE
txtlines[i] = txt
spos = STRPOS(txt,'"')
WHILE (spos NE -1) DO BEGIN
newtxt = STRMID(txt,0,spos)+'"'+STRMID(txt,spos+1,STRLEN(txt)-spos+1)
txt = newtxt
spos = STRPOS(txt,'"',spos+1)
ENDWHILE
txtlines[i] = txt
ENDFOR
END
PRO alt_mhh_grab_hdr,name,dict,infile_indx,libfile_indx,txt_file,verbose,$
strict, print_purpose=print_purpose,allfiles=allfiles
compile_opt idl2
LF=10B
on_ioerror,bad
IF (libfile_indx NE -1L) THEN $
OPENR, in_file, /GET, FILEPATH('mkhtmlhelp.scr',/TMP), /DELETE $
ELSE $
OPENR, in_file, /GET, name
IF (verbose NE 0) THEN dprint, 'File = '+name,dlevel=2
if keyword_set(allfiles) then docum=0 else docum=1
WHILE (1) DO BEGIN
tmp = ''
found = 0
num = 0
header = ''
ON_IOERROR, DONE
WHILE (NOT found) DO BEGIN
READF, in_file, tmp
IF (STRMID(tmp,0,2) EQ ';+') THEN found = 1
if eof(in_file) and docum eq 0 then begin
found=1
docum=2
endif
ENDWHILE
IF (found) THEN BEGIN
if docum eq 2 then begin
header = [header,'No Documentation for this routine.']
num = num+1
endif else begin
found = 0
WHILE (NOT found) DO BEGIN
READF,in_file,tmp
IF (STRMID(tmp,0,2) EQ ';-') THEN BEGIN
found =1
ENDIF ELSE BEGIN
tmp = strmid(tmp, 1, 1000)
header = [header, tmp]
num = num + 1
ENDELSE
ENDWHILE
endelse
docum=1
IF (strict) THEN alt_mhh_strict,header
POINT_LUN,-txt_file,pos
FOR i=1, num DO BEGIN
WRITEU, txt_file, header[i],LF
ENDFOR
index = WHERE(STRTRIM(header, 2) EQ 'NAME:', count)
IF (count eq 1) THEN BEGIN
sub = STRUPCASE(STRTRIM(header[index[0]+1], 2))
IF (verbose NE 0) THEN dprint, 'Routine = '+sub
ENDIF ELSE BEGIN
IF (verbose NE 0) THEN dprint,'Properly formatted NAME entry not found...'
ifname = name
CASE !VERSION.OS_FAMILY OF
'Windows': tok = '\'
'MacOS': tok = ':'
ELSE: tok = '/'
ENDCASE
sp0 = 0
spos = STRPOS(ifname,tok,sp0)
WHILE (spos NE -1) DO BEGIN
sp0 = spos+1
spos = STRPOS(ifname,tok,sp0)
ENDWHILE
ifname = STRMID(ifname,sp0,(STRLEN(ifname)-sp0))
spos = STRPOS(ifname,'.')
IF (spos NE -1) THEN ifname = STRMID(ifname,0,spos[0])
IF (strict) THEN alt_mhh_strict, ifname
sub = STRUPCASE(ifname)
IF (verbose NE 0) THEN dprint,' Setting subject to filename: '+sub+'.'
ENDELSE
index = WHERE(STRTRIM(header, 2) EQ 'PURPOSE:', count)
IF keyword_set(print_purpose) and (count eq 1) THEN BEGIN
purpose = STRTRIM(header[index[0]+1], 2)
IF (verbose NE 0) THEN dprint, 'Purpose = '+purpose,dlevel=2
ENDIF ELSE purpose=''
IF (N_ELEMENTS(dict) EQ 0) THEN $
ndup=0 $
ELSE BEGIN
dpos = WHERE(dict.subject EQ sub,ndup)
IF (ndup EQ 1) THEN BEGIN
dict[dpos[0]].id = 1
ndup = ndup + 1
ENDIF
ENDELSE
entry = {DICT_STR,subject:sub,purpose:purpose,indx:infile_indx,lib:libfile_indx,$
id:ndup,offset:pos,nline:num}
IF (N_ELEMENTS(dict) EQ 0) THEN dict = [entry] ELSE dict = [dict,entry]
ENDIF
ENDWHILE
DONE:
FREE_LUN, in_file
BAD:
ON_IOERROR, NULL
END
PRO alt_mhh_dum_file,outfile,title,verbose
compile_opt idl2
OPENW,final_file,outfile,/GET_LUN
IF (verbose NE 0) THEN dprint,'Building '+outfile+'...',dlevel=2
PRINTF,final_file,'<!-- This file was generated by mk_html_help.pro -->'
PRINTF,final_file,'<html>'
PRINTF,final_file,' '
PRINTF,final_file,'<head>'
PRINTF,final_file,'<TITLE>',title,'</TITLE>
PRINTF,final_file,'</head>'
PRINTF,final_file,' '
PRINTF,final_file,'<body>'
PRINTF,final_file,'<H2>',title,'</H2>'
PRINTF,final_file,'<P>'
PRINTF,final_file,'This page was created by the IDL library routine '
PRINTF,final_file,'<CODE>mk_html_help2</CODE>.'
PRINTF,final_file,'<br>'
PRINTF,final_file,'<P>'
PRINTF,final_file,'<STRONG>Last modified: </STRONG>',SYSTIME(),'.<P>'
PRINTF,final_file,' '
PRINTF,final_file,'<HR>'
PRINTF,final_file,' '
PRINTF,final_file,'No Documented Routines'
PRINTF,final_file,' '
PRINTF,final_file,'</body>'
PRINTF,final_file,'</html>'
FREE_LUN,final_file
return
end
PRO alt_mhh_gen_file,dict,txt_file,infiles,libfiles,outfile,verbose,title,strict $
,crosslink = crosslink, clturbo = clturbo, no_dirlist=no_dirlist, $
mastlist = mastlist, listname = listname, nolist = nolist
compile_opt idl2
pathnames = strippath(infiles[dict.indx])
dictpaths = pathnames.dir_name
s = sort(pathnames.dir_name)
pathnames = pathnames[s]
u = uniq(pathnames.dir_name)
dictwhdir = lonarr(n_elements(dictpaths))
for i = 0, n_elements(dictpaths)-1 do begin
whdir = where(pathnames[u].dir_name eq dictpaths[i])
dictwhdir[i] = whdir[0]
endfor
dpos = WHERE(dict.id GT 0, ndup)
FOR i = 0, ndup-1 DO BEGIN
entry = dict[dpos[i]]
dict[dpos[i]].subject = entry.subject+'['+STRTRIM(STRING(entry.id), 2)+']'
ENDFOR
count = N_ELEMENTS(dict)
indices = SORT(dict.subject)
OPENW, final_file, outfile+'.html', /GET_LUN
IF (verbose NE 0) THEN dprint, 'Building '+outfile+'...'
PRINTF, final_file, '<!-- This file was generated by mk_html_help.pro -->'
PRINTF, final_file, '<html>'
PRINTF, final_file, ' '
PRINTF, final_file, '<head>'
PRINTF, final_file, '<TITLE>', title, '</TITLE>
PRINTF, final_file, '</head>'
PRINTF, final_file, ' '
PRINTF, final_file, '<body>'
PRINTF, final_file, '<H2>', title, '</H2>'
PRINTF, final_file, '<P>'
PRINTF, final_file, 'This page was created by the IDL library routine '
PRINTF, final_file, '<CODE>mk_html_help2</CODE>.'
PRINTF, final_file, '<br>'
PRINTF, final_file, '<P>'
PRINTF, final_file, '<STRONG>Last modified: </STRONG>', SYSTIME(), '.<P>'
PRINTF, final_file, ' '
PRINTF, final_file, '<HR>'
PRINTF, final_file, ' '
PRINTF, final_file, '<A NAME="ROUTINELIST">'
first_letter = strmid((dict[indices].subject), 0, 1)
first_uniq = uniq(first_letter)
if n_elements(first_uniq) gt 1 then $
first_uniq = [0, first_uniq[0:n_elements(first_uniq)-2]+1] $
else first_uniq = [0]
nfu = n_elements(first_uniq)
PRINTF, final_file, '<A NAME="JUMPLIST">'
FOR i = 0, nfu-1 DO BEGIN
entry = dict[indices[first_uniq[i]]]
letter = first_letter[first_uniq[i]]
IF (entry.nline GT 0) THEN BEGIN
PRINTF, final_file, '<A HREF="#LIST_', letter, '">', letter, '</A>'
IF i NE (nfu-1) THEN PRINTF, final_file, ','
ENDIF
ENDFOR
PRINTF, final_file, '<HR>'
PRINTF, final_file, ' '
purp_delim = '<br>'
if keyword_set(print_purpose) then if print_purpose eq 2 then purp_delim = ' '
PRINTF, final_file, '<P>'
PRINTF, final_file, '<H1>Directories Searched:</H1></A>'
PRINTF, final_file, '<UL>'
pathnames = strippath(infiles[dict.indx])
s = sort(pathnames.dir_name)
pathnames = pathnames[s]
u = uniq(pathnames.dir_name)
suboutfile = pathnames[u].dir_name+listname
for i = 0, n_elements(u)-1 do begin
d = pathnames[u[i]].dir_name
PRINTF, final_file, '<LI><A HREF="'+suboutfile[i]+'.html">', d, '</A>'
endfor
PRINTF, final_file, '</UL><P>'
PRINTF, final_file, '<HR>'
if not keyword_set(mastlist) then begin
for i = 0, n_elements(u)-1 do begin
openw, templun, suboutfile[i]+'.html', /get_lun
PRINTF, templun, '<!-- This file was generated by mk_html_help.pro -->'
PRINTF, templun, '<html>'
PRINTF, templun, ' '
PRINTF, templun, '<head>'
PRINTF, templun, '<TITLE>', pathnames[u[i]].dir_name, '</TITLE>'
PRINTF, templun, '</head>'
PRINTF, templun, ' '
PRINTF, templun, '<body>'
PRINTF, templun, '<P>'
PRINTF, templun, 'This page was created by the IDL library routine '
PRINTF, templun, '<CODE>mk_html_help2</CODE>.'
PRINTF, templun, '<br>'
PRINTF, templun, '<P>'
PRINTF, templun, '<STRONG>Last modified: </STRONG>', SYSTIME(), '.<P>'
PRINTF, templun, ' '
PRINTF, templun, '<HR>'
PRINTF, templun, ' '
PRINTF, templun, '<A NAME="ROUTINELIST">'
PRINTF, templun, '<H1>Directory Listing of Routines</H1></A>'
PRINTF, templun, '<UL>'
d = pathnames[u[i]].dir_name
PRINTF, templun, '<H1>', d, '</H1>'
w = where(d eq pathnames.dir_name, c)
if c ne 0 then begin
ws = sort(pathnames[w].file_name)
w = w[ws]
for j = 0, c-1 do begin
entry = dict[s[w[j]]]
IF (entry.nline GT 0) THEN begin
PRINTF, templun, '<LI><A HREF="#', entry.subject, '">', entry.subject, '</A>'
if strlen(entry.purpose) ne 0 then $
printf, templun, purp_delim+entry.purpose
endif
endfor
endif
PRINTF, templun, '<br>'
PRINTF, templun, '</UL><P>'
free_lun, templun
endfor
endif
PRINTF, final_file, '<P>'
PRINTF, final_file, '<H1>Alphabetical List of Routines</H1></A>'
PRINTF, final_file, '<UL>'
ifu = 0
FOR i = 0, count-1 DO BEGIN
entry = dict[indices[i]]
whdir = dictwhdir[indices[i]]
IF i EQ first_uniq[ifu] THEN BEGIN
PRINTF, final_file, '<A NAME="LIST_', first_letter[first_uniq[ifu]], '">'
ifu = (ifu + 1) MOD nfu
ENDIF
IF (entry.nline GT 0) THEN begin
PRINTF, final_file, '<LI><A HREF="'+suboutfile[whdir]+'.html#', entry.subject, '">', $
entry.subject, '</A>'
if strlen(entry.purpose) ne 0 then $
printf, final_file, purp_delim+entry.purpose
endif
ENDFOR
PRINTF, final_file, '</UL><P>'
PRINTF, final_file, ' '
if not keyword_set(mastlist) then begin
for i = 0, n_elements(u)-1 do begin
openw, templun, suboutfile[i]+'.html', /get_lun, /append
PRINTF, templun, '<HR>'
PRINTF, templun, ' '
is_letter = bytarr(256)
is_letter[65:90] = 1
is_letter[97:122] = 1
is_letter[48:57] = 1
is_letter[95] = 1
PRINTF, templun, '<H1>Routine Descriptions</H1>'
free_lun, templun
endfor
ON_IOERROR, TXT_DONE
FOR i = 0, count-1 DO BEGIN
entry = dict[indices[i]]
whdir = dictwhdir[indices[i]]
allwhdir = (dictwhdir eq whdir)
IF(entry.nline GT 0) THEN BEGIN
openw, templun, suboutfile[whdir]+'.html', /get_lun, /append
PRINTF, templun, '<A NAME="', entry.subject, '">'
PRINTF, templun, '<H2>', entry.subject, '</H2></A>'
prev_i = i - 1
IF (prev_i LT 0) THEN $
dostep = 0 $
ELSE BEGIN
prev_ent = dict[indices[prev_i]]
in_dir = allwhdir[indices[prev_i]]
dostep = prev_ent.nline EQ 0 or in_dir eq 0
ENDELSE
WHILE dostep DO BEGIN
prev_i = prev_i - 1
IF (prev_i LT 0) THEN $
dostep = 0 $
ELSE BEGIN
prev_ent = dict[indices[prev_i]]
in_dir = allwhdir[indices[prev_i]]
dostep = prev_ent.nline EQ 0 or in_dir eq 0
ENDELSE
ENDWHILE
IF (prev_i GE 0) THEN $
PRINTF, templun, '<A HREF="#', prev_ent.subject, '">[Previous Routine]</A>'
next_i = i + 1
IF (next_i GE count) THEN $
dostep = 0 $
ELSE BEGIN
next_ent = dict[indices[next_i]]
in_dir = allwhdir[indices[next_i]]
dostep = next_ent.nline EQ 0 or in_dir eq 0
ENDELSE
WHILE dostep DO BEGIN
next_i = next_i + 1
IF (next_i GE count) THEN $
dostep = 0 $
ELSE BEGIN
next_ent = dict[indices[next_i]]
in_dir = allwhdir[indices[next_i]]
dostep = next_ent.nline EQ 0 or in_dir eq 0
ENDELSE
ENDWHILE
IF (next_i LT count) THEN $
PRINTF, templun, '<A HREF="#', next_ent.subject, '">[Next Routine]</A>'
PRINTF, templun, '<A HREF="#ROUTINELIST">[List of Routines]</A>'
PRINTF, templun, '<PRE>'
tmp = ''
POINT_LUN, txt_file, entry.offset
FOR j = 1, entry.nline DO BEGIN
READF, txt_file, tmp
if keyword_set(crosslink) then begin
pos = 0
if keyword_set(clturbo) then pos = strpos(tmp, clturbo)
if pos lt 0 then goto, norefsatall
for cross = 0, count-1 do begin
reference = dict[cross].subject
if entry.subject eq reference then goto, noreference
refdir = dictwhdir[cross]
pos = strpos(strupcase(tmp), reference)
if pos lt 0 then goto, noreference
reflen = strlen(reference)
tmplen = strlen(tmp)
refarr = bytarr(tmplen+2)
refarr[1:tmplen] = byte(tmp)
if is_letter[refarr[pos]] then goto, noreference
if is_letter[refarr[pos+reflen+1]] then goto, noreference
newref = '<A href="'+suboutfile[refdir]+'.html#'+reference+'">'+reference+'</A>'
refarr = string(refarr[1:tmplen+1])
tmp = strmid(refarr, 0, pos)+newref+strmid(refarr, pos+reflen, 300)
IF (verbose NE 0) THEN $
dprint, reference+' cross linked in '+entry.subject,dlevel=2
noreference:
endfor
norefsatall:
endif
PRINTF, templun, tmp
ENDFOR
PRINTF, templun, '</PRE><P>'
IF (entry.lib NE -1L) THEN BEGIN
fname = libfiles[entry.lib]
lname = infiles[entry.indx]
IF (strict) THEN BEGIN
alt_mhh_strict, fname
alt_mhh_strict, lname
ENDIF
PRINTF, templun, '<STRONG>(See '+fname+' in '+lname+')</STRONG><P>'
ENDIF ELSE BEGIN
fname = strippath(infiles[entry.indx])
dir = fname.dir_name
reldir = strippath(fname.dir_name)
reldir = reldir.file_name
fname = fname.file_name
IF (strict) THEN alt_mhh_strict, fname
fname = '<A href="'+reldir+'/'+fname+'">'+dir+'/'+fname+'</A>'
PRINTF, templun, '<STRONG>(See '+fname+')</STRONG><P>'
ENDELSE
PRINTF, templun, '<HR>'
PRINTF, templun, ' '
free_lun, templun
ENDIF
ENDFOR
TXT_DONE:
ON_IOERROR, NULL
FREE_LUN, txt_file
endif
PRINTF, final_file, '</body>'
PRINTF, final_file, '</html>'
FREE_LUN, final_file
END
PRO mk_html_help2, sources, outfile, VERBOSE=verbose,TITLE=title,STRICT=strict $
,crosslink=crosslink,clturbo=clturbo,print_purpose=print_purpose $
,FILENAME= outfile2,allfiles=allfiles,no_dirlist=no_dirlist,mastlist=mastlist $
,listname= listname
compile_opt idl2
IF (NOT KEYWORD_SET(verbose)) THEN verbose=0
IF (NOT KEYWORD_SET(title)) THEN title="Extended IDL Help"
IF (NOT KEYWORD_SET(strict)) THEN strict=0
if n_elements(crosslink) eq 0 then crosslink = 1
if n_elements(print_purpose) eq 0 then print_purpose = 1
infiles = ''
istlb = 0b
if not keyword_set(sources) then begin
sources = setup_sources('')
sources = ['./',sources]
endif
if keyword_set(outfile2) then outfile = outfile2
if not keyword_set(outfile) then outfile = 'help'
if not keyword_set(listname) then listname = outfile+'_list'
if n_elements(clturbo) eq 0 then clturbo = '"'
count = N_ELEMENTS(sources)
IF (count EQ 0) THEN BEGIN
DPRINT,'No source IDL directories found.'
RETURN
ENDIF
OPENW, txt_file, FILEPATH('userhtml.txt', /TMP), /GET_LUN, /DELETE
FOR i=0, count-1 DO BEGIN
src = sources[i]
vpos = STRPOS(src,';')
IF (vpos NE -1) THEN vsource = STRMID(src,0,vpos) ELSE vsource = src
IF (!VERSION.OS EQ 'vms') AND (STRLEN(vsource) GT 4) AND $
(STRUPCASE(STRMID(vsource, STRLEN(vsource)-4,4)) EQ '.TLB') THEN BEGIN
infiles = [infiles,src]
istlb = [istlb, 1b]
ENDIF ELSE BEGIN
IF (STRUPCASE(STRMID(vsource, STRLEN(vsource)-4,4)) EQ '.PRO') THEN BEGIN
infiles = [infiles,src]
istlb = [istlb, 0b]
ENDIF ELSE BEGIN
CASE !VERSION.OS_FAMILY OF
'Windows': tok = '\'
'MacOS': tok = ':'
'unix': tok = '/'
'vms': tok = ''
ENDCASE
flist = FINDFILE(src+tok+'*.pro',COUNT=npro)
IF (npro GT 0) THEN BEGIN
infiles = [infiles,flist]
istlb = [istlb, REPLICATE(0b,npro)]
ENDIF
flist = FINDFILE(src+tok+'*.tlb',COUNT=ntlb)
IF (ntlb GT 0) THEN BEGIN
infiles = [infiles,flist]
istlb = [istlb, REPLICATE(1b,ntlb)]
ENDIF
ENDELSE
ENDELSE
ENDFOR
count = N_ELEMENTS(infiles)
IF (count EQ 1) THEN BEGIN
DPRINT,'No IDL files found.'
RETURN
ENDIF
infiles = infiles[1:*]
istlb = istlb[1:*]
count = count-1
FOR i=0,count-1 DO BEGIN
src = infiles[i]
IF (istlb[i]) THEN BEGIN
SPAWN,'LIBRARY/TEXT/LIST ' + src,files
lib_count = N_ELEMENTS(files)
j=0
WHILE ((j LT lib_count) AND (STRLEN(files[j]) NE 0)) DO j = j + 1
lib_count = lib_count - j - 1
IF (count GT 0) THEN files = files[j+1:*]
lib_total = N_ELEMENTS(libfiles)
IF (lib_total EQ 0) THEN libfiles = files ELSE libfiles = [libfiles, files]
FOR j=0, lib_count-1 DO BEGIN
name = FILEPATH('mkhtmlhelp.scr',/TMP)
SPAWN,'LIBRARY/TEXT/EXTRACT='+files[j]+'/OUT='+name+' '+src
alt_mhh_grab_hdr,files[j],dict,i,lib_total+j,txt_file,verbose,strict $
,print_purpose = print_purpose
ENDFOR
ENDIF ELSE BEGIN
name = infiles[i]
alt_mhh_grab_hdr,name,dict,i,-1L,txt_file,verbose,strict, $
print_pu=print_purpose,allfile=allfiles
ENDELSE
ENDFOR
if keyword_set(dict) then $
alt_mhh_gen_file,dict,txt_file,infiles,libfiles,outfile,verbose,title,strict $
,crosslink=crosslink,clturbo = clturbo,no_dirlist=no_dirlist, $
mastlist=mastlist, listname=listname $
else alt_mhh_dum_file,outfile,title,verbose
END