1
/*
2
 * This file is part of the API Extractor project.
3
 *
4
 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
5
 *
6
 * Contact: PySide team <contact@pyside.org>
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * version 2 as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful, but
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
 * 02110-1301 USA
21
 *
22
 */
23
#ifndef DOCPARSER_H
24
#define DOCPARSER_H
25
26
#include <QString>
27
#include <QDir>
28
29
#include "abstractmetalang.h"
30
31
class QDomDocument;
32
class QDomNode;
33
class QXmlQuery;
34
35
class APIEXTRACTOR_API DocParser
36
{
37
public:
38
    DocParser();
39
    virtual ~DocParser();
40
    virtual void fillDocumentation(AbstractMetaClass* metaClass) = 0;
41
42
    /**
43
     *   Process and retrieves documentation concerning the entire
44
     *   module or library.
45
     *   \return object containing module/library documentation information
46
     */
47
    virtual Documentation retrieveModuleDocumentation() = 0;
48
49
    void setDocumentationDataDirectory(const QString& dir)
50
    {
51
        m_docDataDir = dir;
52
    }
53
54
    /**
55
     *   Informs the location of the XML data generated by the tool
56
     *   (e.g.: DoxyGen, qdoc) used to extract the library's documentation
57
     *   comment.
58
     *   \return the path for the directory containing the XML data created
59
     *   from the library's documentation beign parsed.
60
     */
61
    QString documentationDataDirectory() const
62
    {
63
        return m_docDataDir;
64
    }
65
66
    void setLibrarySourceDirectory(const QString& dir)
67
    {
68
        m_libSourceDir = dir;
69
    }
70
    /**
71
     *   Informs the location of the library being parsed. The library
72
     *   source code is parsed for the documentation comments.
73
     *   \return the path for the directory containing the source code of
74
     *   the library beign parsed.
75
     */
76
    QString librarySourceDirectory() const
77
    {
78
        return m_libSourceDir;
79
    }
80
81
    void setPackageName(const QString& packageName)
82
    {
83
        m_packageName = packageName;
84
    }
85
    /**
86
     *   Retrieves the name of the package (or module or library) being parsed.
87
     *   \return the name of the package (module/library) being parsed
88
     */
89
    QString packageName() const
90
    {
91
        return m_packageName;
92
    }
93
94
    /**
95
    *   Process and retrieves documentation concerning the entire
96
    *   module or library.
97
    *   \param name module name
98
    *   \return object containing module/library documentation information
99
    *   \todo Merge with retrieveModuleDocumentation() on next ABI change.
100
    */
101
    virtual Documentation retrieveModuleDocumentation(const QString& name) = 0;
102
103
protected:
104
    QString getDocumentation(QXmlQuery& xquery, const QString& query,
105
                             const DocModificationList& mods) const;
106
107
private:
108
    QString m_packageName;
109
    QString m_docDataDir;
110
    QString m_libSourceDir;
111
112
    QString execXQuery(QXmlQuery& xquery, const QString& query) const;
113
    QString applyDocModifications(const DocModificationList& mods, const QString& xml) const;
114
};
115
116
#endif // DOCPARSER_H