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