;+
; NAME:
; www_help_add_header
; PURPOSE:
; Add header information to list of header
; CATEGORY:
; www_help
; CALLING SEQUENCE:
FUNCTION www_help_add_header, name, header, origin, style, section, is_incl, lines
; INPUTS:
; name
; header array; type: structure
; all the headers. One header will be added to the list.
; origin array[2]; type: string
; string array describing location of source code
; origin[0] : full name of the source file or text library
; origin[1] : the module name when processing a library
; style
; section
; is_incl set to 1 if the header was extracted from an include file (*.h)
; lines all lines in the header
; OUTPUTS:
; result scalar; type: integer
; always zero
; header array; type: structure
; list of headers; one more than the input list.
; INCLUDE:
@compile_opt.pro ; On error, return to caller
; CALLS:
; www_help_clean, www_help_is_section
; PROCEDURE:
; Each header is stored in a structure of the form
;
; tmp = {HEADER_INFO, $
; name : name, $ ; Procedure name
; link : link, $ ; Link name (=name visible on screen)
; flink : flink, $ ; Full html link of form link
; version : version, $ ; Non-zero for duplicate entries (used in link name)
; origin : origin, $ ; Full file name of source file
; is_incl : is_incl, $ ; 1 if the file was an include file
; auto : 0, $ ; 1 if CALLS section determined automatically
; calls : calls, $ ; Comma separated list of called procedure (the CALLS section)
; nline : nline, $ ; # lines in header
; lines : ptr_new(lines, /no_copy)} ; Header lines
;
; MODIFICATION HISTORY:
; FEB-2002, Paul Hick (UCSD/CASS)
; JUL-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
; Fixed bug setting up header.flink for the first version of a module
; when multiple versions exist.
;-
nline = n_elements(lines)
; Check everything that goes into the html files for special html characters.
www_help_clean, name
www_help_clean, origin
www_help_clean, lines
; Check for duplicate entries. If found add a unique id. Note that for the first
; duplicate found the original procedure needs to be given version number 1.
version = n_elements(header)
IF version NE 0 THEN BEGIN
tmp = where(strupcase(header.name) EQ strupcase(name), version)
IF version EQ 1 THEN BEGIN
tmp = tmp[0]
header[tmp].version = 1
header[tmp].link = header[tmp].link+' [1]'
flink = header[tmp].flink
ip1 = strpos(flink,'">' )
ip2 = strpos(flink,'')
header[tmp].flink = strmid(flink,0,ip1)+' [1]'+strmid(flink,ip1,ip2-ip1)+' [1]'+strmid(flink,ip2)
ENDIF
IF version GE 1 THEN version = version+1
ENDIF
calls = ''
; Create the structure for the header and add it to the list
link = name
IF version NE 0 THEN link = link+' ['+strcompress(version, /rem)+']'
flink = ''+link+''
tmp = {HEADER_INFO, $ ; Create a header entry for header
name : name, $ ; Procedure name
link : link, $ ; Link name
flink : flink, $ ; Full html link of form link
version : version, $ ; Non-zero for duplicate entries
origin : origin, $ ; Index of source file
is_incl : is_incl, $ ; 1 if the file was an include file
auto : 0, $
calls : calls, $
nline : nline, $ ; # lines in header
lines : ptr_new(lines, /no_copy)} ; Header lines
CASE n_elements(header) OF
0 : header = [ tmp]
ELSE: header = [header, tmp]
ENDCASE
RETURN, 0 & END