1
/***************************************************************************
2
* Copyright (C) 2003 by Jonas B. Jacobi *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
***************************************************************************/
15
#include <qstringlist.h>
21
void DoxyDoc::formatType( QString& str )
23
str.replace( QRegExp( " " ), "" );
26
DoxyDoc::DoxyDoc( const QStringList& dir )
28
for ( uint i = 0; i < dir.count(); ++i )
29
m_dirs.push_back( QDir( *( dir.at( i ) ) ) );
32
//crappy implementation, change later
33
QString DoxyDoc::functionDescription( const QString& tmpscope, const QString& name,
34
const QString& tmptype, const QString& tmparguments )
36
QString scope = tmpscope;
37
bool foundfile = false;
38
//produce doxygen conform filenames
39
QString filename = "/class" + scope.replace( QRegExp( "_" ), "__" ).replace( QRegExp( "::" ), "_1_1" ) + ".xml";
41
//search for file in all directories
42
for ( std::list<QDir>::const_iterator ci = m_dirs.begin(); !foundfile && ci != m_dirs.end(); ++ci )
44
if ( QFile::exists( ci->path() + filename ) )
46
if ( m_file.name() != ci->path() + filename )
49
m_file.setName( ci->path() + filename );
50
if ( !m_file.open( IO_ReadOnly ) )
56
m_doc.setContent( m_file.readAll() );
58
m_list = m_doc.elementsByTagName( "memberdef" );
62
else //file is already opened
69
QString type = tmptype;
72
for ( uint i = 0; i < m_list.count(); ++i )
74
QDomElement elem = m_list.item( i ).toElement();
75
if ( elem.elementsByTagName( "name" ).item( 0 ).toElement().text() == name &&
76
elem.elementsByTagName( "type" ).item( 0 ).toElement().text() == tmptype )
78
QDomNodeList paramnodes = elem.elementsByTagName( "param" );
79
QString nodearguments = "", arguments = tmparguments;
80
for ( unsigned int j = 0; j < paramnodes.count(); ++j )
81
nodearguments += paramnodes.item( j ).childNodes().item( 0 ).toElement().text() + ",";
82
if ( nodearguments != "" )
84
nodearguments = nodearguments.left( nodearguments.length() - 1 );
85
formatType( nodearguments );
87
formatType( arguments );
88
if ( arguments == nodearguments )
91
QDomNode briefnode = elem.elementsByTagName( "briefdescription" ).item( 0 );
92
if ( briefnode.hasChildNodes() )
93
brief = briefnode.firstChild().toElement().text();
95
QString detailstr = "", paramstr = "";
96
QDomNode detail = elem.elementsByTagName( "detaileddescription" ).item( 0 );
97
if ( detail.hasChildNodes() )
98
detail = detail.firstChild();
100
QDomNode descnode = detail.firstChild();
101
while ( !descnode.isNull() )
103
if ( descnode.nodeName() == "parameterlist" )
105
int tmpcount = descnode.childNodes().count();
106
for ( int k = 0; k < tmpcount; ++k )
109
paramstr += "<li><i>" + descnode.childNodes().item( k++ ).toElement().text() + "</i>\t";
110
//add parameterdescription
111
paramstr += descnode.childNodes().item( k ).toElement().text() + "</li>";
115
if ( descnode.nodeName() == "simplesect" )
119
if ( descnode.isText() )
120
detailstr += descnode.toText().data();
122
detailstr += descnode.toElement().text();
124
descnode = descnode.nextSibling();
128
QString description = "";
130
description += brief + "<p>";
131
if ( detailstr != "" )
132
description += detailstr + "<p>";
133
if ( paramstr != "" )
134
description += "<b>Parameterlist:</b><p>" + paramstr;
136
if ( description == "" )
137
return QString::null;
145
return QString::null;
148
//kate: indent-mode csands; tab-width 4; space-indent off;