1
1
/****************************************************************************
3
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
4
5
** Contact: Nokia Corporation (qt-info@nokia.com)
6
7
** This file is part of the tools applications of the Qt Toolkit.
8
9
** $QT_BEGIN_LICENSE:LGPL$
10
** Licensees holding valid Qt Commercial licenses may use this file in
11
** accordance with the Qt Commercial License Agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Nokia.
10
** No Commercial Usage
11
** This file contains pre-release code and may not be distributed.
12
** You may use this file in accordance with the terms and conditions
13
** contained in the Technology Preview License Agreement accompanying
15
16
** GNU Lesser General Public License Usage
16
17
** Alternatively, this file may be used under the terms of the GNU Lesser
20
21
** ensure the GNU Lesser General Public License version 2.1 requirements
21
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
** In addition, as a special exception, Nokia gives you certain
24
** additional rights. These rights are described in the Nokia Qt LGPL
25
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
28
** GNU General Public License Usage
29
** Alternatively, this file may be used under the terms of the GNU
30
** General Public License version 3.0 as published by the Free Software
31
** Foundation and appearing in the file LICENSE.GPL included in the
32
** packaging of this file. Please review the following information to
33
** ensure the GNU General Public License version 3.0 requirements will be
34
** met: http://www.gnu.org/copyleft/gpl.html.
36
** If you are unsure which license is appropriate for your use, please
37
** contact the sales department at http://www.qtsoftware.com/contact.
24
** In addition, as a special exception, Nokia gives you certain additional
25
** rights. These rights are described in the Nokia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
38
38
** $QT_END_LICENSE$
40
40
****************************************************************************/
131
138
while (g != generators.end()) {
132
139
if (outputFormats.contains((*g)->format())) {
133
140
(*g)->initializeGenerator(config);
134
QStringList extraImages = config.getStringList(CONFIG_EXTRAIMAGES + Config::dot
141
QStringList extraImages = config.getStringList(CONFIG_EXTRAIMAGES +
136
144
QStringList::ConstIterator e = extraImages.begin();
137
145
while (e != extraImages.end()) {
138
146
QString userFriendlyFilePath;
139
QString filePath = Config::findFile(config.lastLocation(), imageFiles, imageDirs, *e,
140
imgFileExts[(*g)->format()], userFriendlyFilePath);
147
QString filePath = Config::findFile(config.lastLocation(),
148
imageFiles, imageDirs, *e,
149
imgFileExts[(*g)->format()],
150
userFriendlyFilePath);
141
151
if (!filePath.isEmpty())
142
Config::copyFile(config.lastLocation(), filePath, userFriendlyFilePath,
143
(*g)->outputDir() + "/images");
152
Config::copyFile(config.lastLocation(),
154
userFriendlyFilePath,
256
272
endText(relative, marker);
261
void Generator::generateQmlText(const Text& text,
280
Extract sections of markup text surrounded by \e qmltext
281
and \e endqmltext and output them.
283
bool Generator::generateQmlText(const Text& text,
262
284
const Node *relative,
286
const QString& /* qmlName */ )
265
if (text.firstAtom() != 0) {
266
startText(relative, marker);
267
const Atom *atom = text.firstAtom();
269
if (atom->type() != Atom::QmlText)
273
while (atom && (atom->type() != Atom::EndQmlText)) {
274
int n = 1 + generateAtom(atom, relative, marker);
288
const Atom* atom = text.firstAtom();
292
startText(relative, marker);
294
if (atom->type() != Atom::QmlText)
298
while (atom && (atom->type() != Atom::EndQmlText)) {
299
int n = 1 + generateAtom(atom, relative, marker);
280
endText(relative, marker);
305
endText(relative, marker);
296
321
else if (node->type() == Node::Fake) {
297
322
const FakeNode *fake = static_cast<const FakeNode *>(node);
298
if (fake->subType() == FakeNode::Example)
323
if (fake->subType() == Node::Example)
299
324
generateExampleFiles(fake, marker);
300
else if (fake->subType() == FakeNode::File)
325
else if (fake->subType() == Node::File)
304
329
if (node->doc().isEmpty()) {
305
if (!quiet) // ### might be unnecessary
330
if (!quiet && !node->isReimp()) // ### might be unnecessary
306
331
node->location().warning(tr("No documentation for '%1'")
307
332
.arg(marker->plainFullName(node)));
310
generateText(node->doc().body(), node, marker);
335
if (node->type() == Node::Function) {
336
const FunctionNode *func = static_cast<const FunctionNode *>(node);
337
if (func->reimplementedFrom() != 0)
338
generateReimplementedFrom(func, marker);
341
if (!generateText(node->doc().body(), node, marker))
312
345
if (node->type() == Node::Enum) {
313
346
const EnumNode *enume = (const EnumNode *) node;
497
543
QString exampleFile = child->name();
498
544
openedList.next();
499
545
text << Atom(Atom::ListItemNumber, openedList.numberString())
500
<< Atom(Atom::ListItemLeft, openedList.styleString()) << Atom::ParaLeft
546
<< Atom(Atom::ListItemLeft, openedList.styleString())
501
548
<< Atom(Atom::Link, exampleFile)
502
549
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
504
551
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK)
505
<< Atom::ParaRight << Atom(Atom::ListItemRight, openedList.styleString());
553
<< Atom(Atom::ListItemRight, openedList.styleString());
507
555
text << Atom(Atom::ListRight, openedList.styleString());
508
556
generateText(text, fake, marker);
511
void Generator::generateModuleWarning(const ClassNode *classe, CodeMarker *marker)
559
void Generator::generateModuleWarning(const ClassNode *classe,
513
562
QString module = classe->moduleName();
514
563
if (!module.isEmpty()) {
516
if (Tokenizer::isTrue("defined(consoleedition)")
517
&& !editionModuleMap["Console"].contains(module)) {
518
text << Atom::ParaLeft
519
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
520
<< "This class is not part of the Qt Console Edition."
521
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
524
else if (Tokenizer::isTrue("defined(desktoplightedition)")
525
&& !editionModuleMap["DesktopLight"].contains(module)) {
526
text << Atom::ParaLeft
527
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
528
<< "This class is not part of the Qt Desktop Light Edition."
529
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
532
else if (module == "Qt3Support" && Tokenizer::isTrue("defined(opensourceedition)")) {
533
text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
534
<< "Note to Qt Desktop Light Edition users:"
565
if (!editionModuleMap["DesktopLight"].contains(module)) {
566
text << Atom::ParaLeft
567
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
568
<< "This class is not part of the Qt GUI Framework Edition."
569
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
572
else if (module == "Qt3Support") {
573
text << Atom::ParaLeft
574
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
575
<< "Note to Qt GUI Framework Edition users:"
535
576
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
536
577
<< " This class is only available in the "
537
<< Atom(Atom::AutoLink, "Qt Desktop Edition")
578
<< Atom(Atom::AutoLink, "Qt Full Framework Edition")
538
579
<< "." << Atom::ParaRight;
735
783
text << "This " << typeString(node) << " is obsolete.";
736
784
if (node->isInnerNode())
737
785
text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD);
738
text << " It is provided to keep old source code working. We strongly advise against "
786
text << " It is provided to keep old source code working. "
787
<< "We strongly advise against "
739
788
<< "using it in new code." << Atom::ParaRight;
741
790
case Node::Compat:
742
791
// reimplemented in HtmlGenerator subclass
743
792
if (node->isInnerNode()) {
744
text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) << "This "
745
<< typeString(node) << " is part of the Qt 3 compatibility layer."
793
text << Atom::ParaLeft
794
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
797
<< " is part of the Qt 3 compatibility layer."
746
798
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
747
<< " It is provided to keep old source code working. We strongly advise against "
799
<< " It is provided to keep old source code working. "
800
<< "We strongly advise against "
748
801
<< "using it in new code. See "
749
802
<< Atom(Atom::AutoLink, "Porting to Qt 4")
750
803
<< " for more information."
764
817
Text theStockLink;
765
Node::ThreadSafeness parent = node->parent()->inheritedThreadSafeness();
767
switch (node->threadSafeness()) {
818
Node::ThreadSafeness threadSafeness = node->threadSafeness();
821
rlink << Atom(Atom::Link,"reentrant")
822
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
824
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
827
tlink << Atom(Atom::Link,"thread-safe")
828
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
830
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
832
switch (threadSafeness) {
768
833
case Node::UnspecifiedSafeness:
770
835
case Node::NonReentrant:
771
text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) << "Warning:"
772
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) << " This "
773
<< typeString(node) << " is not " << stockLink("reentrant") << "." << Atom::ParaRight;
836
text << Atom::ParaLeft
837
<< Atom(Atom::FormattingLeft,ATOM_FORMATTING_BOLD)
839
<< Atom(Atom::FormattingRight,ATOM_FORMATTING_BOLD)
775
847
case Node::Reentrant:
776
848
case Node::ThreadSafe:
777
text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD);
778
if (parent == Node::ThreadSafe) {
783
text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) << " ";
785
if (node->threadSafeness() == Node::ThreadSafe)
786
theStockLink = stockLink("thread-safe");
788
theStockLink = stockLink("reentrant");
849
text << Atom::ParaLeft
850
<< Atom(Atom::FormattingLeft,ATOM_FORMATTING_BOLD)
852
<< Atom(Atom::FormattingRight,ATOM_FORMATTING_BOLD)
790
855
if (node->isInnerNode()) {
791
const InnerNode *innerNode = static_cast<const InnerNode *>(node);
792
text << "All the functions in this " << typeString(node) << " are "
856
const InnerNode* innerNode = static_cast<const InnerNode*>(node);
857
text << "All functions in this "
860
if (threadSafeness == Node::ThreadSafe)
865
bool exceptions = false;
868
NodeList nonreentrant;
796
869
NodeList::ConstIterator c = innerNode->childNodes().begin();
797
870
while (c != innerNode->childNodes().end()) {
798
if ((*c)->threadSafeness() != Node::UnspecifiedSafeness)
871
switch ((*c)->threadSafeness()) {
872
case Node::Reentrant:
873
reentrant.append(*c);
874
if (threadSafeness == Node::ThreadSafe)
877
case Node::ThreadSafe:
878
threadsafe.append(*c);
879
if (threadSafeness == Node::Reentrant)
882
case Node::NonReentrant:
883
nonreentrant.append(*c);
802
if (except.isEmpty()) {
893
else if (threadSafeness == Node::Reentrant) {
894
if (nonreentrant.isEmpty()) {
895
if (!threadsafe.isEmpty()) {
897
appendFullNames(text,threadsafe,innerNode,marker);
898
singularPlural(text,threadsafe);
899
text << " also " << tlink << ".";
905
text << ", except for ";
906
appendFullNames(text,nonreentrant,innerNode,marker);
908
singularPlural(text,nonreentrant);
909
text << " nonreentrant.";
910
if (!threadsafe.isEmpty()) {
912
appendFullNames(text,threadsafe,innerNode,marker);
913
singularPlural(text,threadsafe);
914
text << " " << tlink << ".";
808
NodeList::ConstIterator e = except.begin();
810
while (e != except.end()) {
811
appendFullName(text, *e, innerNode, marker);
812
text << separator(index++, except.count());
918
else { // thread-safe
919
if (!nonreentrant.isEmpty() || !reentrant.isEmpty()) {
920
text << ", except for ";
921
if (!reentrant.isEmpty()) {
922
appendFullNames(text,reentrant,innerNode,marker);
924
singularPlural(text,reentrant);
925
text << " only " << rlink;
926
if (!nonreentrant.isEmpty())
929
if (!nonreentrant.isEmpty()) {
930
appendFullNames(text,nonreentrant,innerNode,marker);
932
singularPlural(text,nonreentrant);
933
text << " nonreentrant.";
818
text << "This " << typeString(node) << " is " << theStockLink << ".";
940
text << "This " << typeString(node) << " is ";
941
if (threadSafeness == Node::ThreadSafe)
820
947
text << Atom::ParaRight;
822
generateText(text, node, marker);
949
generateText(text,node,marker);
825
952
void Generator::generateSince(const Node *node, CodeMarker *marker)
827
954
if (!node->since().isEmpty()) {
829
text << Atom::ParaLeft << "This " << typeString(node)
956
text << Atom::ParaLeft
830
959
<< " was introduced in ";
831
960
if (project.isEmpty())
832
961
text << "version";
857
986
if (func->reimplementedFrom() != 0) {
858
987
const FunctionNode *from = func->reimplementedFrom();
859
if (from->access() != Node::Private && from->parent()->access() != Node::Private) {
988
if (from->access() != Node::Private &&
989
from->parent()->access() != Node::Private) {
861
991
text << Atom::ParaLeft << "Reimplemented from ";
862
appendFullName(text, from->parent(), func, marker, from);
992
QString fullName = from->parent()->name() + "::" + from->name() + "()";
993
appendFullName(text, from->parent(), fullName, from);
863
994
text << "." << Atom::ParaRight;
864
995
generateText(text, func, marker);
939
1071
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
1074
void Generator::appendFullName(Text& text,
1075
const Node *apparentNode,
1076
const QString& fullName,
1077
const Node *actualNode)
1079
if (actualNode == 0)
1080
actualNode = apparentNode;
1081
text << Atom(Atom::LinkNode, CodeMarker::stringForNode(actualNode))
1082
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
1083
<< Atom(Atom::String, fullName)
1084
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
1087
void Generator::appendFullNames(Text& text,
1088
const NodeList& nodes,
1089
const Node* relative,
1092
NodeList::ConstIterator n = nodes.begin();
1094
while (n != nodes.end()) {
1095
appendFullName(text,*n,relative,marker);
1096
text << comma(index++,nodes.count());
942
1101
void Generator::appendSortedNames(Text& text,
943
1102
const ClassNode *classe,
944
1103
const QList<RelatedClass> &classes,