/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Script Generator project on Qt Labs. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "docgenerator.h" #include "fileout.h" DocGenerator::DocGenerator() { } QString DocGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const { return QString::fromLatin1("%0.html").arg(meta_class->name().toLower()); } QString DocGenerator::subDirectoryForClass(const AbstractMetaClass *) const { return QString::fromLatin1("doc"); } static void writeDocumentHeader(QTextStream &s, const QString &title) { s << "" << endl << "" << endl << "" << endl << "
" << endl << "" << cls->name() << " |
---|
" << cls->name() << " |
---|
Using the Qt API in Qt Script is very similar to C++." << endl << "
var f = new QFile(\"foo.txt\");" << endl << "C++ enum values are mapped to properties of the script constructor function; e.g. " << endl << "QIODevice::ReadOnly becomes QIODevice.ReadOnly." << endl << "
f.open(new QIODevice.OpenMode(QIODevice.ReadOnly));" << endl << "
Each C++ flag type is mapped to a property of the script constructor function; e.g. " << endl << "QIODevice::OpenMode becomes QIODevice.OpenMode. Such a property is a constructor function " << endl << "that takes one or more enum values and constructs a flags instance by OR'ing the arguments " << endl << "together.
" << endl << "var ts = new QTextStream(f);" << endl << "ts.writeString(\"Boo\");" << endl << "
C++ streaming operators are normally mapped to readT() and writeT() functions.
" << endl << "f.close();" << endl << "
In Qt Script, all objects are allocated on the heap; objects that are no longer " << endl << "referenced are garbage collected sometime in the future; therefore, make sure to " << endl << "explicitly free up resources if you can. (Without the call to close(), the underlying " << endl << "file would remain open until the file object is garbage collected.)
" << endl ; file.stream << "Inherits baseClass()) << "\">" << meta_class->baseClass()->name() << ".
" << endl; } else if (!meta_class->interfaces().isEmpty()) { AbstractMetaClass *iface = meta_class->interfaces().first(); AbstractMetaClass *impl = iface->primaryInterfaceImplementor(); if (impl != meta_class) { s << "Inherits " << impl->name() << ".
" << endl; } } AbstractMetaFunctionList ctors; ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors | AbstractMetaClass::WasPublic | AbstractMetaClass::NotRemovedFromTargetLang); QMapThis class has no public constructors. Calling the constructor function will cause a TypeError.
"; } s << "The " << meta_class->name() << " prototype object inherits properties from the " << "baseClass()) << "\">" << meta_class->baseClass()->name() << " prototype object and " << "also has the following properties.
" << endl; } s << "" << meta_class->name() << " objects inherit properties from the " << meta_class->name() << " prototype object and also have the following properties.
" << endl; s << "" << meta_class->name() << " objects have no special properties beyond those " << "inherited from the " << meta_class->name() << " prototype object.
" << endl; } } } writeDocumentFooter(s); }