Doxygen
Toggle main menu visibility
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
23
struct
EclipseHelp::Private
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
59
EclipseHelp::EclipseHelp
() :
p
(std::make_unique<
Private
>()) {}
60
EclipseHelp::~EclipseHelp
() =
default
;
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
*/
68
void
EclipseHelp::initialize
()
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 {} for writing\n"
, 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
*/
96
void
EclipseHelp::finalize
()
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
*/
124
void
EclipseHelp::incContentsDepth
()
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
*/
135
void
EclipseHelp::decContentsDepth
()
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
* @param nameAsHtml name parameter in HTML format
161
*/
162
void
EclipseHelp::addContentsItem
(
163
bool
/* isDir */
,
164
const
QCString
&name,
165
const
QCString
&
/* ref */
,
166
const
QCString
&file,
167
const
QCString
&anchor,
168
bool
/* separateIndex */
,
169
bool
/* addToNavIndex */
,
170
const
Definition
*
/*def*/
,
171
const
QCString
&
/* nameAsHtml */
)
172
{
173
// -- write the topic tag
174
p
->closedTag();
175
if
(!file.
isEmpty
())
176
{
177
QCString
fn = file;
178
addHtmlExtensionIfMissing
(fn);
179
switch
(file[0])
// check for special markers (user defined URLs)
180
{
181
case
'^'
:
182
// URL not supported by eclipse toc.xml
183
break
;
184
185
case
'!'
:
186
p
->indent();
187
p
->tocstream <<
"<topic label=\""
<<
convertToXML
(name) <<
"\""
;
188
p
->tocstream <<
" href=\""
<<
convertToXML
(
p
->pathprefix) << &file[1] <<
"\""
;
189
p
->endtag =
TRUE
;
190
break
;
191
192
default
:
193
p
->indent();
194
p
->tocstream <<
"<topic label=\""
<<
convertToXML
(name) <<
"\""
;
195
p
->tocstream <<
" href=\""
<<
convertToXML
(
p
->pathprefix) << fn;
196
if
(!anchor.
isEmpty
())
197
{
198
p
->tocstream <<
"#"
<< anchor;
199
}
200
p
->tocstream <<
"\""
;
201
p
->endtag =
TRUE
;
202
break
;
203
}
204
}
205
else
206
{
207
p
->indent();
208
p
->tocstream <<
"<topic label=\""
<<
convertToXML
(name) <<
"\""
;
209
p
->endtag =
TRUE
;
210
}
211
}
212
213
void
EclipseHelp::addIndexItem
(
214
const
Definition
*
/* context */
,
215
const
MemberDef
*
/* md */
,
216
const
QCString
&
/* sectionAnchor */
,
217
const
QCString
&
/* title */
)
218
{
219
}
220
221
void
EclipseHelp::addIndexFile
(
const
QCString
&
/* name */
)
222
{
223
}
224
225
void
EclipseHelp::addImageFile
(
const
QCString
&
/* name */
)
226
{
227
}
228
229
void
EclipseHelp::addStyleSheetFile
(
const
QCString
&
/* name */
)
230
{
231
}
232
Definition
The common base class of all entity definitions found in the sources.
Definition
definition.h:77
Doxygen::htmlFileExtension
static QCString htmlFileExtension
Definition
doxygen.h:121
EclipseHelp::~EclipseHelp
virtual ~EclipseHelp()
EclipseHelp::addIndexFile
virtual void addIndexFile(const QCString &name)
Definition
eclipsehelp.cpp:221
EclipseHelp::addStyleSheetFile
virtual void addStyleSheetFile(const QCString &name)
Definition
eclipsehelp.cpp:229
EclipseHelp::decContentsDepth
virtual void decContentsDepth()
Decrease the level of content hierarchy.
Definition
eclipsehelp.cpp:135
EclipseHelp::p
std::unique_ptr< Private > p
Definition
eclipsehelp.h:66
EclipseHelp::EclipseHelp
EclipseHelp()
Definition
eclipsehelp.cpp:59
EclipseHelp::finalize
virtual void finalize()
Finish generation of the Eclipse specific help files.
Definition
eclipsehelp.cpp:96
EclipseHelp::incContentsDepth
virtual void incContentsDepth()
Increase the level of content hierarchy.
Definition
eclipsehelp.cpp:124
EclipseHelp::addIndexItem
virtual void addIndexItem(const Definition *context, const MemberDef *md, const QCString §ionAnchor, const QCString &title)
Definition
eclipsehelp.cpp:213
EclipseHelp::addContentsItem
virtual void addContentsItem(bool isDir, const QCString &name, const QCString &ref, const QCString &file, const QCString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def, const QCString &nameAsHtml)
Add an item to the content.
Definition
eclipsehelp.cpp:162
EclipseHelp::addImageFile
virtual void addImageFile(const QCString &name)
Definition
eclipsehelp.cpp:225
EclipseHelp::initialize
virtual void initialize()
Initialize the Eclipse generator.
Definition
eclipsehelp.cpp:68
MemberDef
A model of a class/file/namespace member symbol.
Definition
memberdef.h:48
QCString
This is an alternative implementation of QCString.
Definition
qcstring.h:101
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition
qcstring.h:163
config.h
Config_getString
#define Config_getString(name)
Definition
config.h:32
doxygen.h
eclipsehelp.h
message.h
term
#define term(fmt,...)
Definition
message.h:137
Portable::openOutputStream
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition
portable.cpp:649
portable.h
Portable versions of functions that are platform dependent.
TRUE
#define TRUE
Definition
qcstring.h:37
FALSE
#define FALSE
Definition
qcstring.h:34
EclipseHelp::Private
Definition
eclipsehelp.cpp:24
EclipseHelp::Private::closedTag
void closedTag()
Definition
eclipsehelp.cpp:40
EclipseHelp::Private::indent
void indent()
Definition
eclipsehelp.cpp:33
EclipseHelp::Private::depth
int depth
Definition
eclipsehelp.cpp:25
EclipseHelp::Private::openTags
int openTags
Definition
eclipsehelp.cpp:27
EclipseHelp::Private::endtag
bool endtag
Definition
eclipsehelp.cpp:26
EclipseHelp::Private::tocstream
std::ofstream tocstream
Definition
eclipsehelp.cpp:29
EclipseHelp::Private::pathprefix
QCString pathprefix
Definition
eclipsehelp.cpp:30
EclipseHelp::Private::openedTag
void openedTag()
Definition
eclipsehelp.cpp:48
convertToXML
QCString convertToXML(const QCString &s, bool keepEntities)
Definition
util.cpp:3893
addHtmlExtensionIfMissing
void addHtmlExtensionIfMissing(QCString &fName)
Definition
util.cpp:4902
util.h
A bunch of utility functions.
src
eclipsehelp.cpp
Generated by
1.17.0