source: trunk/SRC/Utilities/mergeonline_help.pro

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • Property svn:keywords set to Id
File size: 7.7 KB
Line 
1;+
2;
3; @file_comments
4; Have one unique online help for IDL and SAXO
5;
6; @categories
7; Documentation
8;
9; @restrictions
10; Needs at least version greater than 6.2 and lower than 7,
11;
12; @history
13; Sept 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
14;
15; @version
16; $Id$
17;
18; - pinsard 2011-04-14T14:43:31Z loholt1.ipsl.polytechnique.fr (Linux)
19;
20;   * add restriction with IDL 7 and above
21;
22;-
23PRO mergeonline_help
24;
25  compile_opt idl2, strictarrsubs
26;
27; is the IDL version at least 6.2 ?
28  idlversion = float(strmid(!version.release, 0, 3))
29  IF idlversion LT 6.2 THEN BEGIN
30    ras = report('Warning: You need at least IDL 6.2 to use SAXO/IDL merged online help')
31    return
32  ENDIF
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
39;---------------------------------------------------------------
40;---------------------------------------------------------------
41; check directories
42;---------------------------------------------------------------
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
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
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
62; is $HOME/.assistant/src a directory ? if not, create it?
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
68
69  homesaxo = file_dirname((find('buildinit.pro'))[0], /mark_directory) + 'Documentation/idldoc_assistant_output/'
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;---------------------------------------------------------------
75; check existence and version of the file that need to be created
76;---------------------------------------------------------------
77
78; do idl.adp and home.html already exists?
79  IF file_test(homesrc + 'home.html') AND file_test(homesrc + 'idl.adp') $
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]
94; are the 2 revision tags the same ?
95        IF array_equal(old, new) THEN BEGIN
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
105        ENDIF
106      ENDIF
107    ENDIF
108  ENDIF
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)]
141;
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"/> &#160;&#160;<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"/> &#160;&#160;<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
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"')
169;
170  putfile, homesrc + 'home.html', temporary(homehtml)
171;---------------------------------------------------------------
172; build homesrc + 'aboutsaxo.txt'
173;---------------------------------------------------------------
174  about = getfile(homesaxo + parent + parent + 'overview')
175; remove the lines containing @
176  lines = strmatch(about, '@*')
177  about = about[where(lines EQ 0)]
178; add some informations:
179  about = [about, '', 'More informations on', 'http://forge.ipsl.jussieu.fr/saxo', '']
180;
181  putfile, homesrc + 'aboutsaxo.txt', temporary(about)
182;---------------------------------------------------------------
183  ras = report('Merge of SAXO and IDL online help done...')
184  !help_path = homesrc
185;
186  RETURN
187  END
Note: See TracBrowser for help on using the repository browser.