1 /******************************************************************************
3 * Copyright (C) 1997-2012 by Dimitri van Heesch.
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.
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
15 #include "eclipsehelp.h"
21 EclipseHelp::EclipseHelp() : m_depth(0), m_endtag(FALSE), m_tocfile(0)
25 EclipseHelp::~EclipseHelp()
29 void EclipseHelp::indent()
32 for (i=0; i<m_depth; i++)
38 void EclipseHelp::closedTag()
42 m_tocstream << "/>" << endl;
47 void EclipseHelp::openedTag()
51 m_tocstream << ">" << endl;
57 * \brief Initialize the Eclipse generator
59 * This method opens the XML TOC file and writes headers of the files.
62 void EclipseHelp::initialize()
64 // -- read path prefix from the configuration
65 //m_pathprefix = Config_getString("ECLIPSE_PATHPREFIX");
66 //if (m_pathprefix.isEmpty()) m_pathprefix = "html/";
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))
73 err("Could not open file %s for writing\n", name.data());
77 // -- initialize its text stream
78 m_tocstream.setDevice(m_tocfile);
79 //m_tocstream.setEncoding(FTextStream::UnicodeUTF8);
81 // -- write the opening tag
82 QCString title = Config_getString("PROJECT_NAME");
85 title = "Doxygen generated documentation";
87 m_tocstream << "<toc label=\"" << convertToXML(title)
88 << "\" topic=\"" << convertToXML(m_pathprefix)
89 << "index" << Doxygen::htmlFileExtension << "\">" << endl;
94 * \brief Finish generation of the Eclipse specific help files
96 * This method writes footers of the files and closes them.
99 void EclipseHelp::finalize()
101 closedTag(); // -- close previous tag
103 // -- write ending tag
105 m_tocstream << "</toc>" << endl;
107 // -- close the content file
108 m_tocstream.unsetDevice();
110 delete m_tocfile; m_tocfile = 0;
112 QCString name = Config_getString("HTML_OUTPUT") + "/plugin.xml";
113 QFile pluginFile(name);
114 if (pluginFile.open(IO_WriteOnly))
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;
128 * \brief Increase the level of content hierarchy
130 void EclipseHelp::incContentsDepth()
137 * \brief Decrease the level of content hierarchy
139 * It closes currently opened topic tag.
141 void EclipseHelp::decContentsDepth()
143 // -- end of the opened topic
147 m_tocstream << "</topic>" << endl;
151 * \brief Add an item to the content
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 * @param separateIndex not used.
159 * @param addToNavIndex not used.
160 * @param def not used.
162 void EclipseHelp::addContentsItem(
165 const char * /* ref */,
168 bool /* separateIndex */,
169 bool /* addToNavIndex */,
170 Definition * /*def*/)
172 // -- write the topic tag
175 m_tocstream << "<topic label=\"" << convertToXML(name) << "\"";
178 m_tocstream << " href=\"" << convertToXML(m_pathprefix)
179 << file << Doxygen::htmlFileExtension;
182 m_tocstream << "#" << anchor;
189 void EclipseHelp::addIndexItem(
190 Definition * /* context */,
191 MemberDef * /* md */,
192 const char * /* title */)
196 void EclipseHelp::addIndexFile(const char * /* name */)
200 void EclipseHelp::addImageFile(const char * /* name */)
204 void EclipseHelp::addStyleSheetFile(const char * /* name */)