Root/
Source at commit 1322 created 12 years 8 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * Copyright (C) 1997-2011 by Dimitri van Heesch.␊ |
4 | *␊ |
5 | * Permission to use, copy, modify, and distribute this software and its␊ |
6 | * documentation under the terms of the GNU General Public License is hereby ␊ |
7 | * granted. No representations are made about the suitability of this software ␊ |
8 | * for any purpose. It is provided "as is" without express or implied warranty.␊ |
9 | * See the GNU General Public License for more details.␊ |
10 | *␊ |
11 | * Documents produced by Doxygen are derivative works derived from the␊ |
12 | * input used in their production; they are not affected by this license.␊ |
13 | *␊ |
14 | */␊ |
15 | #include "eclipsehelp.h"␊ |
16 | #include "util.h"␊ |
17 | #include "config.h"␊ |
18 | #include "message.h"␊ |
19 | #include "doxygen.h"␊ |
20 | ␊ |
21 | EclipseHelp::EclipseHelp() : m_depth(0), m_endtag(FALSE), m_tocfile(0) ␊ |
22 | {␊ |
23 | }␊ |
24 | ␊ |
25 | EclipseHelp::~EclipseHelp() ␊ |
26 | {␊ |
27 | }␊ |
28 | ␊ |
29 | void EclipseHelp::indent()␊ |
30 | {␊ |
31 | int i;␊ |
32 | for (i=0; i<m_depth; i++)␊ |
33 | {␊ |
34 | m_tocstream << " ";␊ |
35 | }␊ |
36 | }␊ |
37 | ␊ |
38 | void EclipseHelp::closedTag()␊ |
39 | {␊ |
40 | if (m_endtag) ␊ |
41 | {␊ |
42 | m_tocstream << "/>" << endl;␊ |
43 | m_endtag = FALSE;␊ |
44 | }␊ |
45 | }␊ |
46 | ␊ |
47 | void EclipseHelp::openedTag()␊ |
48 | {␊ |
49 | if (m_endtag) ␊ |
50 | {␊ |
51 | m_tocstream << ">" << endl;␊ |
52 | m_endtag = FALSE;␊ |
53 | }␊ |
54 | }␊ |
55 | ␊ |
56 | /*!␊ |
57 | * \brief Initialize the Eclipse generator␊ |
58 | *␊ |
59 | * This method opens the XML TOC file and writes headers of the files.␊ |
60 | * \sa finalize()␊ |
61 | */␊ |
62 | void EclipseHelp::initialize() ␊ |
63 | {␊ |
64 | // -- read path prefix from the configuration␊ |
65 | //m_pathprefix = Config_getString("ECLIPSE_PATHPREFIX");␊ |
66 | //if (m_pathprefix.isEmpty()) m_pathprefix = "html/";␊ |
67 | ␊ |
68 | // -- open the contents file ␊ |
69 | QCString name = Config_getString("HTML_OUTPUT") + "/toc.xml";␊ |
70 | m_tocfile = new QFile(name);␊ |
71 | if (!m_tocfile->open(IO_WriteOnly)) ␊ |
72 | {␊ |
73 | err("Could not open file %s for writing\n", name.data());␊ |
74 | exit(1);␊ |
75 | }␊ |
76 | ␊ |
77 | // -- initialize its text stream␊ |
78 | m_tocstream.setDevice(m_tocfile);␊ |
79 | //m_tocstream.setEncoding(FTextStream::UnicodeUTF8);␊ |
80 | ␊ |
81 | // -- write the opening tag␊ |
82 | QCString title = Config_getString("PROJECT_NAME");␊ |
83 | if (title.isEmpty())␊ |
84 | {␊ |
85 | title = "Doxygen generated documentation";␊ |
86 | }␊ |
87 | m_tocstream << "<toc label=\"" << convertToXML(title) ␊ |
88 | << "\" topic=\"" << convertToXML(m_pathprefix) ␊ |
89 | << "index" << Doxygen::htmlFileExtension << "\">" << endl;␊ |
90 | ++ m_depth;␊ |
91 | }␊ |
92 | ␊ |
93 | /*!␊ |
94 | * \brief Finish generation of the Eclipse specific help files␊ |
95 | *␊ |
96 | * This method writes footers of the files and closes them.␊ |
97 | * \sa initialize()␊ |
98 | */␊ |
99 | void EclipseHelp::finalize() ␊ |
100 | {␊ |
101 | closedTag(); // -- close previous tag␊ |
102 | ␊ |
103 | // -- write ending tag ␊ |
104 | --m_depth;␊ |
105 | m_tocstream << "</toc>" << endl;␊ |
106 | ␊ |
107 | // -- close the content file␊ |
108 | m_tocstream.unsetDevice();␊ |
109 | m_tocfile->close();␊ |
110 | delete m_tocfile; m_tocfile = 0;␊ |
111 | ␊ |
112 | QCString name = Config_getString("HTML_OUTPUT") + "/plugin.xml";␊ |
113 | QFile pluginFile(name);␊ |
114 | if (pluginFile.open(IO_WriteOnly))␊ |
115 | {␊ |
116 | QString docId = Config_getString("ECLIPSE_DOC_ID");␊ |
117 | FTextStream t(&pluginFile);␊ |
118 | t << "<plugin name=\"" << docId << "\" id=\"" << docId << "\"" << endl;␊ |
119 | t << " version=\"1.0.0\" provider-name=\"Doxygen\">" << endl;␊ |
120 | t << " <extension point=\"org.eclipse.help.toc\">" << endl;␊ |
121 | t << " <toc file=\"toc.xml\" primary=\"true\" />" << endl;␊ |
122 | t << " </extension>" << endl;␊ |
123 | t << "</plugin>" << endl;␊ |
124 | }␊ |
125 | }␊ |
126 | ␊ |
127 | /*!␊ |
128 | * \brief Increase the level of content hierarchy␊ |
129 | */␊ |
130 | void EclipseHelp::incContentsDepth() ␊ |
131 | {␊ |
132 | openedTag();␊ |
133 | ++m_depth;␊ |
134 | }␊ |
135 | ␊ |
136 | /*!␊ |
137 | * \brief Decrease the level of content hierarchy␊ |
138 | *␊ |
139 | * It closes currently opened topic tag.␊ |
140 | */␊ |
141 | void EclipseHelp::decContentsDepth() ␊ |
142 | {␊ |
143 | // -- end of the opened topic␊ |
144 | closedTag();␊ |
145 | --m_depth;␊ |
146 | indent();␊ |
147 | m_tocstream << "</topic>" << endl;␊ |
148 | }␊ |
149 | ␊ |
150 | /*!␊ |
151 | * \brief Add an item to the content␊ |
152 | *␊ |
153 | * @param isDir Flag whether the argument \a file is a directory or a file entry␊ |
154 | * @param name Name of the item␊ |
155 | * @param ref URL of the item␊ |
156 | * @param file Name of a file which the item is defined in (without extension)␊ |
157 | * @param anchor Name of an anchor of the item.␊ |
158 | */␊ |
159 | void EclipseHelp::addContentsItem(␊ |
160 | bool /* isDir */,␊ |
161 | const char *name,␊ |
162 | const char * /* ref */,␊ |
163 | const char *file,␊ |
164 | const char *anchor) ␊ |
165 | {␊ |
166 | // -- write the topic tag ␊ |
167 | closedTag();␊ |
168 | indent();␊ |
169 | m_tocstream << "<topic label=\"" << convertToXML(name) << "\"";␊ |
170 | if (file) ␊ |
171 | { ␊ |
172 | m_tocstream << " href=\"" << convertToXML(m_pathprefix) ␊ |
173 | << file << Doxygen::htmlFileExtension;␊ |
174 | if (anchor)␊ |
175 | {␊ |
176 | m_tocstream << "#" << anchor;␊ |
177 | }␊ |
178 | m_tocstream << "\"";␊ |
179 | }␊ |
180 | m_endtag = TRUE;␊ |
181 | }␊ |
182 | ␊ |
183 | void EclipseHelp::addIndexItem(␊ |
184 | Definition * /* context */,␊ |
185 | MemberDef * /* md */,␊ |
186 | const char * /* title */)␊ |
187 | {␊ |
188 | }␊ |
189 | ␊ |
190 | void EclipseHelp::addIndexFile(const char * /* name */) ␊ |
191 | {␊ |
192 | }␊ |
193 | ␊ |
194 | void EclipseHelp::addImageFile(const char * /* name */) ␊ |
195 | {␊ |
196 | }␊ |
197 | ␊ |
198 | void EclipseHelp::addStyleSheetFile(const char * /* name */) ␊ |
199 | {␊ |
200 | }␊ |
201 | ␊ |
202 |