source: trunk/SRC/Utilities/mergeonline_help.pro @ 226

Last change on this file since 226 was 224, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

  • Property svn:keywords set to Id
File size: 7.2 KB
Line 
1;+
2; @file_comments
3; Have one unique online help for IDL and SAXO
4;
5; @categories
6; Documentation
7;
8; @restrictions
9; Needs at least version 6.2
10;
11; @history
12; Sept 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
13;
14; @version
15; $Id$
16;-
17PRO mergeonline_help
18;
19  compile_opt idl2, strictarrsubs
20;
21; is the IDL version at least 6.2 ?
22  idlversion = float(strmid(!version.release, 0, 3))
23  IF idlversion LT 6.2 THEN BEGIN
24    print, 'Warning: You need at least IDL 6.2 to use SAXO/IDL merged online help'
25    return
26  ENDIF
27;---------------------------------------------------------------
28; check directories
29;---------------------------------------------------------------
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
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
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
49; is $HOME/.assistant/src a directory ? if not, create it?
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
55
56  homesaxo = file_dirname((find('buildinit.pro'))[0], /mark_directory) + 'Documentation/idldoc_assistant_output/'
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;---------------------------------------------------------------
62; check existence and version of the file that need to be created
63;---------------------------------------------------------------
64
65; do idl.adp and home.html already exists?
66  IF file_test(homesrc + 'home.html') AND file_test(homesrc + 'idl.adp') $
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]
81; are the 2 revision tags the same ?
82        IF array_equal(old, new) THEN BEGIN
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
92        ENDIF
93      ENDIF
94    ENDIF
95  ENDIF
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)]
128;
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"/> &#160;&#160;<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"/> &#160;&#160;<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"')
155;
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', '']
166;
167  putfile, homesrc + 'aboutsaxo.txt', temporary(about)
168;---------------------------------------------------------------
169  print, 'Merge of SAXO and IDL online help done...'
170  !help_path = homesrc
171;
172  RETURN
173END
Note: See TracBrowser for help on using the repository browser.