[175] | 1 | ;+ |
---|
| 2 | ; @file_comments |
---|
| 3 | ; Have one unique online help for IDL and SAXO |
---|
| 4 | ; |
---|
| 5 | ; @categories |
---|
| 6 | ; Documentation |
---|
| 7 | ; |
---|
| 8 | ; @restrictions |
---|
[224] | 9 | ; Needs at least version 6.2 |
---|
[175] | 10 | ; |
---|
| 11 | ; @history |
---|
| 12 | ; Sept 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
| 13 | ; |
---|
| 14 | ; @version |
---|
| 15 | ; $Id$ |
---|
| 16 | ;- |
---|
| 17 | PRO mergeonline_help |
---|
| 18 | ; |
---|
| 19 | compile_opt idl2, strictarrsubs |
---|
| 20 | ; |
---|
| 21 | ; is the IDL version at least 6.2 ? |
---|
[197] | 22 | idlversion = float(strmid(!version.release, 0, 3)) |
---|
| 23 | IF idlversion LT 6.2 THEN BEGIN |
---|
[192] | 24 | print, 'Warning: You need at least IDL 6.2 to use SAXO/IDL merged online help' |
---|
| 25 | return |
---|
| 26 | ENDIF |
---|
| 27 | ;--------------------------------------------------------------- |
---|
[224] | 28 | ; check directories |
---|
[192] | 29 | ;--------------------------------------------------------------- |
---|
[175] | 30 | ; get the environment variable $HOME |
---|
| 31 | home = getenv('HOME') |
---|
| 32 | ; is it defined? |
---|
| 33 | IF home EQ '' THEN return |
---|
| 34 | ; is $HOME a writable directory? |
---|
| 35 | home = (file_search(home, /test_directory, /test_write, /mark_directory))[0] |
---|
| 36 | IF home EQ '' THEN return |
---|
[192] | 37 | |
---|
| 38 | ; is !dir + '/help/online_help a directory ? |
---|
| 39 | homeidl = !dir + '/help/online_help' |
---|
| 40 | homeidl = (file_search(homeidl, /test_directory, /mark_directory))[0] |
---|
| 41 | IF homeidl EQ '' THEN return |
---|
| 42 | |
---|
[175] | 43 | ; is $HOME/.assistant a directory ? if not, create it |
---|
| 44 | homeassist = home + '.assistant' |
---|
| 45 | IF file_test(homeassist, /directory) EQ 0 THEN file_mkdir, homeassist |
---|
| 46 | ; is $HOME/.assistant a writable directory? |
---|
| 47 | homeassist = (file_search(homeassist, /test_directory, /test_write, /mark_directory))[0] |
---|
| 48 | IF homeassist EQ '' THEN return |
---|
[192] | 49 | ; is $HOME/.assistant/src a directory ? if not, create it? |
---|
[175] | 50 | homesrc = homeassist + 'src' |
---|
| 51 | IF file_test(homesrc, /directory) EQ 0 THEN file_mkdir, homesrc |
---|
| 52 | ; is $HOME/.assistant/src a writable directory? |
---|
| 53 | homesrc = (file_search(homesrc, /test_directory, /test_write, /mark_directory))[0] |
---|
| 54 | IF homesrc EQ '' THEN return |
---|
[192] | 55 | |
---|
[197] | 56 | homesaxo = file_dirname((find('buildinit.pro'))[0], /mark_directory) + 'Documentation/idldoc_assistant_output/' |
---|
[192] | 57 | IF file_test(homesaxo + 'idldoc-lib.adp') EQ 0 THEN BEGIN |
---|
| 58 | print, 'Error when looking for the file '+ homesaxo + 'idldoc-lib.adp...' |
---|
| 59 | return |
---|
| 60 | ENDIF |
---|
| 61 | ;--------------------------------------------------------------- |
---|
[224] | 62 | ; check existence and version of the file that need to be created |
---|
[192] | 63 | ;--------------------------------------------------------------- |
---|
| 64 | |
---|
[175] | 65 | ; do idl.adp and home.html already exists? |
---|
| 66 | IF file_test(homesrc + 'home.html') AND file_test(homesrc + 'idl.adp') $ |
---|
[192] | 67 | AND file_test(homesrc + 'aboutsaxo.txt') THEN BEGIN |
---|
| 68 | ; is the revision version of homesrc+'idl.adp' the same of homesaxo + 'idldoc-lib.adp' ? |
---|
| 69 | ; is $Id found in homesrc+'idl.adp' |
---|
| 70 | idladp = getfile(homesrc+'idl.adp') |
---|
| 71 | line = strmatch(idladp, '*$Id*') |
---|
| 72 | line = (where(line EQ 1))[0] |
---|
| 73 | IF line NE -1 THEN BEGIN |
---|
| 74 | new = idladp[line] |
---|
| 75 | ; is $Id found in homesaxo + 'idldoc-lib.adp' |
---|
| 76 | saxoadp = getfile(homesaxo + 'idldoc-lib.adp') |
---|
| 77 | line = strmatch(saxoadp, '*$Id*') |
---|
| 78 | line = (where(line EQ 1))[0] |
---|
| 79 | IF line NE -1 THEN BEGIN |
---|
| 80 | old = saxoadp[line] |
---|
[224] | 81 | ; are the 2 revision tags the same ? |
---|
[192] | 82 | IF array_equal(old, new) THEN BEGIN |
---|
[197] | 83 | ; is IDL version the same of homesrc + 'home.html' ? |
---|
| 84 | homehtml = getfile(homesrc+'home.html') |
---|
| 85 | line = strmatch(homehtml, '*IDL '+ string(idlversion, format = '(f3.1)') + '*') |
---|
| 86 | line = (where(line EQ 1))[0] |
---|
| 87 | IF line NE -1 THEN BEGIN |
---|
| 88 | !help_path = homesrc |
---|
| 89 | print, 'Use SAXO/IDL merged online help...' |
---|
| 90 | return |
---|
| 91 | ENDIF |
---|
[192] | 92 | ENDIF |
---|
| 93 | ENDIF |
---|
| 94 | ENDIF |
---|
[175] | 95 | ENDIF |
---|
[192] | 96 | ;--------------------------------------------------------------- |
---|
| 97 | ; build homesrc + 'idl.adp' |
---|
| 98 | ;--------------------------------------------------------------- |
---|
| 99 | ; --- modify the original idl.adp --- |
---|
| 100 | idladp = getfile(homeidl+'idl.adp') |
---|
| 101 | ; extract part from </profile> to </assistantconfig> |
---|
| 102 | line1 = strmatch(idladp, '*</profile>*') |
---|
| 103 | line1 = (where(line1 EQ 1))[0] |
---|
| 104 | line2 = strmatch(idladp, '*</assistantconfig>*') |
---|
| 105 | line2 = (where(line2 EQ 1))[0] - 1L |
---|
| 106 | idladp = idladp[line1:line2] |
---|
| 107 | ; put the complete path of the references |
---|
| 108 | idladp = strsed(idladp, 'ref=\"', 'ref="'+homeidl) |
---|
| 109 | ; --- modify the original idldoc-lib.adp --- |
---|
| 110 | saxoadp = getfile(homesaxo + 'idldoc-lib.adp') |
---|
| 111 | ; extract part from </profile> |
---|
| 112 | line1 = strmatch(saxoadp, '*</profile>*') |
---|
| 113 | line1 = (where(line1 EQ 1))[0] + 1 |
---|
| 114 | saxoadp = saxoadp[line1:*] |
---|
| 115 | ; put the complete path of the references |
---|
| 116 | saxoadp = strsed(saxoadp, 'ref=\"', 'ref="'+homesaxo) |
---|
| 117 | ; --- merge idl.adp and idldoc-lib.adp, add an header and write it in a new file --- |
---|
| 118 | header = ['<!DOCTYPE DCF>' $ |
---|
| 119 | , '<assistantconfig version="3.3.0">' $ |
---|
| 120 | , ' <profile>' $ |
---|
| 121 | , ' <property name="name">SAXO - IDL ' + !version.release + ' Help</property>' $ |
---|
| 122 | , ' <property name="title">SAXO - IDL ' + !version.release + ' Help</property>' $ |
---|
| 123 | , ' <property name="startpage">' + homesrc + 'home.html</property>' $ |
---|
| 124 | , ' <property name="aboutmenutext">About SAXO</property>' $ |
---|
| 125 | , ' <property name="abouturl">' + homesrc + 'aboutsaxo.txt</property>' $ |
---|
| 126 | , ' <property name="assistantdocs">' + homeidl + '</property>'] |
---|
| 127 | newadp = [temporary(header), temporary(idladp), temporary(saxoadp)] |
---|
[175] | 128 | ; |
---|
[192] | 129 | putfile, homesrc + 'idl.adp', temporary(newadp) |
---|
| 130 | ;--------------------------------------------------------------- |
---|
| 131 | ; build homesrc + 'home.html' |
---|
| 132 | ;--------------------------------------------------------------- |
---|
| 133 | homehtml = getfile(homeidl+'home.html') |
---|
| 134 | ; put the complete path of the references |
---|
| 135 | homehtml = strsed(homehtml, 'ref=\"', 'ref="'+homeidl) |
---|
| 136 | ; find the first line containing '</h3>' |
---|
| 137 | line = strmatch(homehtml, '*</h3>*') |
---|
| 138 | line = (where(line EQ 1))[0] |
---|
| 139 | ; insert one line after this line |
---|
| 140 | homehtml = [homehtml[0:line] $ |
---|
| 141 | , '<a name="SAXOdir"> </a><p class="pIndentedRelative"><img src="images/blueball_idl.gif" id="blueballSAXOdir" border="0" hspace="0" vspace="0"/>   <a href="' + homesaxo + 'home.html">SAXO Directory</a></p>' $ |
---|
| 142 | , homehtml[line+1:*]] |
---|
| 143 | ; find the last line containing '</h3>' |
---|
| 144 | line = strmatch(homehtml, '*</h3>*') |
---|
| 145 | line = (where(line EQ 1, cnt))[cnt-1] |
---|
| 146 | ; insert one line after this line |
---|
| 147 | homehtml = [homehtml[0:line] $ |
---|
| 148 | , '<a name="SAXOweb"> </a><p class="pIndentedRelative"><img src="images/blueball_idl.gif" id="blueballSAXOweb" border="0" hspace="0" vspace="0"/>   <a href="http://forge.ipsl.jussieu.fr/saxo">SAXO Home Page</a> </p>' $ |
---|
| 149 | , homehtml[line+1:*]] |
---|
| 150 | |
---|
| 151 | ; put the complete path of the images |
---|
| 152 | homehtml = strsed(homehtml, 'src=\"', 'src="'+homeidl) |
---|
| 153 | ; except for SAXOIDL_OnlineHelp_title.png |
---|
| 154 | homehtml = strsed(homehtml, 'src=\".*IDL_OnlineHelp_Title\.gif\"', 'src="' + homesaxo + '../xmldoc/images/SAXOIDL_OnlineHelp_title.png"') |
---|
[175] | 155 | ; |
---|
[192] | 156 | putfile, homesrc + 'home.html', temporary(homehtml) |
---|
| 157 | ;--------------------------------------------------------------- |
---|
| 158 | ; build homesrc + 'aboutsaxo.txt' |
---|
| 159 | ;--------------------------------------------------------------- |
---|
| 160 | about = getfile(homesaxo + '../../overview') |
---|
| 161 | ; remove the lines containing @ |
---|
| 162 | lines = strmatch(about, '@*') |
---|
| 163 | about = about[where(lines EQ 0)] |
---|
| 164 | ; add some informattions: |
---|
| 165 | about = [about, '', 'More informations on', 'http://forge.ipsl.jussieu.fr/saxo', ''] |
---|
[224] | 166 | ; |
---|
[192] | 167 | putfile, homesrc + 'aboutsaxo.txt', temporary(about) |
---|
| 168 | ;--------------------------------------------------------------- |
---|
| 169 | print, 'Merge of SAXO and IDL online help done...' |
---|
| 170 | !help_path = homesrc |
---|
| 171 | ; |
---|
[175] | 172 | RETURN |
---|
| 173 | END |
---|