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