Doxygen
Loading...
Searching...
No Matches
eclipsehelp.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2015 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
16#include "eclipsehelp.h"
17#include "util.h"
18#include "config.h"
19#include "message.h"
20#include "doxygen.h"
21#include "portable.h"
22
24{
25 int depth = 0;
26 bool endtag = false;
27 int openTags = 0;
28
29 std::ofstream tocstream;
30 QCString pathprefix;
31
32 /* -- formatting helpers */
33 void indent()
34 {
35 for (int i=0; i<depth; i++)
36 {
37 tocstream << " ";
38 }
39 }
40 void closedTag()
41 {
42 if (endtag)
43 {
44 tocstream << "/>\n";
45 endtag = FALSE;
46 }
47 }
48 void openedTag()
49 {
50 if (endtag)
51 {
52 tocstream << ">\n";
53 endtag = FALSE;
54 ++openTags;
55 }
56 }
57};
58
59EclipseHelp::EclipseHelp() : p(std::make_unique<Private>()) {}
61
62/*!
63 * \brief Initialize the Eclipse generator
64 *
65 * This method opens the XML TOC file and writes headers of the files.
66 * \sa finalize()
67 */
69{
70 // -- open the contents file
71 QCString name = Config_getString(HTML_OUTPUT) + "/toc.xml";
72 p->tocstream = Portable::openOutputStream(name);
73 if (!p->tocstream.is_open())
74 {
75 term("Could not open file %s for writing\n", qPrint(name));
76 }
77
78 // -- write the opening tag
79 QCString title = Config_getString(PROJECT_NAME);
80 if (title.isEmpty())
81 {
82 title = "Doxygen generated documentation";
83 }
84 p->tocstream << "<toc label=\"" << convertToXML(title)
85 << "\" topic=\"" << convertToXML(p->pathprefix)
86 << "index" << Doxygen::htmlFileExtension << "\">\n";
87 ++ p->depth;
88}
89
90/*!
91 * \brief Finish generation of the Eclipse specific help files
92 *
93 * This method writes footers of the files and closes them.
94 * \sa initialize()
95 */
97{
98 p->closedTag(); // -- close previous tag
99
100 // -- write ending tag
101 --p->depth;
102 p->tocstream << "</toc>\n";
103
104 // -- close the content file
105 p->tocstream.close();
106
107 QCString name = Config_getString(HTML_OUTPUT) + "/plugin.xml";
108 std::ofstream t = Portable::openOutputStream(name);
109 if (t.is_open())
110 {
111 QCString docId = Config_getString(ECLIPSE_DOC_ID);
112 t << "<plugin name=\"" << docId << "\" id=\"" << docId << "\"\n";
113 t << " version=\"1.0.0\" provider-name=\"Doxygen\">\n";
114 t << " <extension point=\"org.eclipse.help.toc\">\n";
115 t << " <toc file=\"toc.xml\" primary=\"true\" />\n";
116 t << " </extension>\n";
117 t << "</plugin>\n";
118 }
119}
120
121/*!
122 * \brief Increase the level of content hierarchy
123 */
125{
126 p->openedTag();
127 ++p->depth;
128}
129
130/*!
131 * \brief Decrease the level of content hierarchy
132 *
133 * It closes currently opened topic tag.
134 */
136{
137 // -- end of the opened topic
138 p->closedTag();
139 --p->depth;
140
141 if (p->openTags==p->depth)
142 {
143 --p->openTags;
144 p->indent();
145 p->tocstream << "</topic>\n";
146 }
147}
148
149/*!
150 * \brief Add an item to the content
151 *
152 * @param isDir Flag whether the argument \a file is a directory or a file entry
153 * @param name Name of the item
154 * @param ref URL of the item
155 * @param file Name of a file which the item is defined in (without extension)
156 * @param anchor Name of an anchor of the item.
157 * @param separateIndex not used.
158 * @param addToNavIndex not used.
159 * @param def not used.
160 */
162 bool /* isDir */,
163 const QCString &name,
164 const QCString & /* ref */,
165 const QCString &file,
166 const QCString &anchor,
167 bool /* separateIndex */,
168 bool /* addToNavIndex */,
169 const Definition * /*def*/)
170{
171 // -- write the topic tag
172 p->closedTag();
173 if (!file.isEmpty())
174 {
175 QCString fn = file;
177 switch (file[0]) // check for special markers (user defined URLs)
178 {
179 case '^':
180 // URL not supported by eclipse toc.xml
181 break;
182
183 case '!':
184 p->indent();
185 p->tocstream << "<topic label=\"" << convertToXML(name) << "\"";
186 p->tocstream << " href=\"" << convertToXML(p->pathprefix) << &file[1] << "\"";
187 p->endtag = TRUE;
188 break;
189
190 default:
191 p->indent();
192 p->tocstream << "<topic label=\"" << convertToXML(name) << "\"";
193 p->tocstream << " href=\"" << convertToXML(p->pathprefix) << fn;
194 if (!anchor.isEmpty())
195 {
196 p->tocstream << "#" << anchor;
197 }
198 p->tocstream << "\"";
199 p->endtag = TRUE;
200 break;
201 }
202 }
203 else
204 {
205 p->indent();
206 p->tocstream << "<topic label=\"" << convertToXML(name) << "\"";
207 p->endtag = TRUE;
208 }
209}
210
212 const Definition * /* context */,
213 const MemberDef * /* md */,
214 const QCString & /* sectionAnchor */,
215 const QCString & /* title */)
216{
217}
218
219void EclipseHelp::addIndexFile(const QCString & /* name */)
220{
221}
222
223void EclipseHelp::addImageFile(const QCString & /* name */)
224{
225}
226
228{
229}
230
The common base class of all entity definitions found in the sources.
Definition definition.h:76
static QCString htmlFileExtension
Definition doxygen.h:122
virtual ~EclipseHelp()
virtual void addIndexFile(const QCString &name)
virtual void addStyleSheetFile(const QCString &name)
virtual void decContentsDepth()
Decrease the level of content hierarchy.
std::unique_ptr< Private > p
Definition eclipsehelp.h:66
virtual void finalize()
Finish generation of the Eclipse specific help files.
virtual void incContentsDepth()
Increase the level of content hierarchy.
virtual void addIndexItem(const Definition *context, const MemberDef *md, const QCString &sectionAnchor, const QCString &title)
virtual void addImageFile(const QCString &name)
virtual void addContentsItem(bool isDir, const QCString &name, const QCString &ref, const QCString &file, const QCString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def)
Add an item to the content.
virtual void initialize()
Initialize the Eclipse generator.
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
This is an alternative implementation of QCString.
Definition qcstring.h:101
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
#define Config_getString(name)
Definition config.h:32
#define term(fmt,...)
Definition message.h:94
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:665
Portable versions of functions that are platform dependent.
const char * qPrint(const char *s)
Definition qcstring.h:661
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
std::ofstream tocstream
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4266
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5243
A bunch of utility functions.