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