;+ ; ; @file_comments ; Have one unique online help for IDL and SAXO ; ; @categories ; Documentation ; ; @restrictions ; Needs at least version 6.2 ; ; @history ; Sept 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr) ; ; @version ; $Id$ ; ;- ; PRO mergeonline_help ; compile_opt idl2, strictarrsubs ; ; is the IDL version at least 6.2 ? idlversion = float(strmid(!version.release, 0, 3)) IF idlversion LT 6.2 THEN BEGIN ras = report('Warning: You need at least IDL 6.2 to use SAXO/IDL merged online help') return ENDIF ;--------------------------------------------------------------- ; check directories ;--------------------------------------------------------------- ; get the environment variable $HOME home = getenv('HOME') ; is it defined? IF home EQ '' THEN return ; is $HOME a writable directory? home = (file_search(home, /test_directory, /test_write, /mark_directory))[0] IF home EQ '' THEN return ; is !dir + '/help/online_help a directory ? homeidl = !dir + '/help/online_help' homeidl = (file_search(homeidl, /test_directory, /mark_directory))[0] IF homeidl EQ '' THEN return ; is $HOME/.assistant a directory ? if not, create it homeassist = home + '.assistant' IF file_test(homeassist, /directory) EQ 0 THEN file_mkdir, homeassist ; is $HOME/.assistant a writable directory? homeassist = (file_search(homeassist, /test_directory, /test_write, /mark_directory))[0] IF homeassist EQ '' THEN return ; is $HOME/.assistant/src a directory ? if not, create it? homesrc = homeassist + 'src' IF file_test(homesrc, /directory) EQ 0 THEN file_mkdir, homesrc ; is $HOME/.assistant/src a writable directory? homesrc = (file_search(homesrc, /test_directory, /test_write, /mark_directory))[0] IF homesrc EQ '' THEN return homesaxo = file_dirname((find('buildinit.pro'))[0], /mark_directory) + 'Documentation/idldoc_assistant_output/' IF file_test(homesaxo + 'idldoc-lib.adp') EQ 0 THEN BEGIN print, 'Error when looking for the file '+ homesaxo + 'idldoc-lib.adp...' return ENDIF ;--------------------------------------------------------------- ; check existence and version of the file that need to be created ;--------------------------------------------------------------- ; do idl.adp and home.html already exists? IF file_test(homesrc + 'home.html') AND file_test(homesrc + 'idl.adp') $ AND file_test(homesrc + 'aboutsaxo.txt') THEN BEGIN ; is the revision version of homesrc+'idl.adp' the same of homesaxo + 'idldoc-lib.adp' ? ; is $Id found in homesrc+'idl.adp' idladp = getfile(homesrc+'idl.adp') line = strmatch(idladp, '*$Id*') line = (where(line EQ 1))[0] IF line NE -1 THEN BEGIN new = idladp[line] ; is $Id found in homesaxo + 'idldoc-lib.adp' saxoadp = getfile(homesaxo + 'idldoc-lib.adp') line = strmatch(saxoadp, '*$Id*') line = (where(line EQ 1))[0] IF line NE -1 THEN BEGIN old = saxoadp[line] ; are the 2 revision tags the same ? IF array_equal(old, new) THEN BEGIN ; is IDL version the same of homesrc + 'home.html' ? homehtml = getfile(homesrc+'home.html') line = strmatch(homehtml, '*IDL '+ string(idlversion, format = '(f3.1)') + '*') line = (where(line EQ 1))[0] IF line NE -1 THEN BEGIN !help_path = homesrc print, 'Use SAXO/IDL merged online help...' return ENDIF ENDIF ENDIF ENDIF ENDIF ;--------------------------------------------------------------- ; build homesrc + 'idl.adp' ;--------------------------------------------------------------- ; --- modify the original idl.adp --- idladp = getfile(homeidl+'idl.adp') ; extract part from to line1 = strmatch(idladp, '**') line1 = (where(line1 EQ 1))[0] line2 = strmatch(idladp, '**') line2 = (where(line2 EQ 1))[0] - 1L idladp = idladp[line1:line2] ; put the complete path of the references idladp = strsed(idladp, 'ref=\"', 'ref="'+homeidl) ; --- modify the original idldoc-lib.adp --- saxoadp = getfile(homesaxo + 'idldoc-lib.adp') ; extract part from line1 = strmatch(saxoadp, '**') line1 = (where(line1 EQ 1))[0] + 1 saxoadp = saxoadp[line1:*] ; put the complete path of the references saxoadp = strsed(saxoadp, 'ref=\"', 'ref="'+homesaxo) ; --- merge idl.adp and idldoc-lib.adp, add an header and write it in a new file --- header = ['' $ , '' $ , ' ' $ , ' SAXO - IDL ' + !version.release + ' Help' $ , ' SAXO - IDL ' + !version.release + ' Help' $ , ' ' + homesrc + 'home.html' $ , ' About SAXO' $ , ' ' + homesrc + 'aboutsaxo.txt' $ , ' ' + homeidl + ''] newadp = [temporary(header), temporary(idladp), temporary(saxoadp)] ; putfile, homesrc + 'idl.adp', temporary(newadp) ;--------------------------------------------------------------- ; build homesrc + 'home.html' ;--------------------------------------------------------------- homehtml = getfile(homeidl+'home.html') ; put the complete path of the references homehtml = strsed(homehtml, 'ref=\"', 'ref="'+homeidl) ; find the first line containing '' line = strmatch(homehtml, '**') line = (where(line EQ 1))[0] ; insert one line after this line homehtml = [homehtml[0:line] $ , '

  SAXO Directory

' $ , homehtml[line+1:*]] ; find the last line containing '' line = strmatch(homehtml, '**') line = (where(line EQ 1, cnt))[cnt-1] ; insert one line after this line homehtml = [homehtml[0:line] $ , '

  SAXO Home Page

' $ , homehtml[line+1:*]] ; put the complete path of the images homehtml = strsed(homehtml, 'src=\"', 'src="'+homeidl) ; except for SAXOIDL_OnlineHelp_title.png parent = path_sep(/parent_directory)+path_sep() homehtml = strsed(homehtml, 'src=\".*IDL_OnlineHelp_Title\.gif\"', 'src="' + homesaxo + parent + 'xmldoc/images/SAXOIDL_OnlineHelp_title.png"') ; putfile, homesrc + 'home.html', temporary(homehtml) ;--------------------------------------------------------------- ; build homesrc + 'aboutsaxo.txt' ;--------------------------------------------------------------- about = getfile(homesaxo + parent + parent + 'overview') ; remove the lines containing @ lines = strmatch(about, '@*') about = about[where(lines EQ 0)] ; add some informattions: about = [about, '', 'More informations on', 'http://forge.ipsl.jussieu.fr/saxo', ''] ; putfile, homesrc + 'aboutsaxo.txt', temporary(about) ;--------------------------------------------------------------- ras = report('Merge of SAXO and IDL online help done...') !help_path = homesrc ; RETURN END