1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
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
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
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.
40 ****************************************************************************/
46 #include <qdatetime.h>
49 #include "mangenerator.h"
55 ManGenerator::ManGenerator()
57 date
= QDate::currentDate().toString( "d MMMM yyyy" );
60 ManGenerator::~ManGenerator()
64 QString
ManGenerator::format()
69 int ManGenerator::generateAtom( const Atom
*atom
, const Node
* /* relative */,
70 CodeMarker
* /* marker */ )
73 switch ( atom
->type() ) {
74 case Atom::AbstractBegin
:
76 case Atom::AbstractEnd
:
84 case Atom::BriefBegin
:
90 case Atom::CaptionBegin
:
92 case Atom::CaptionEnd
:
94 case Atom::CitationBegin
:
96 case Atom::CitationEnd
:
100 case Atom::FootnoteBegin
:
102 case Atom::FootnoteEnd
:
104 case Atom::FormatBegin
:
106 case Atom::FormatEnd
:
108 case Atom::GeneratedList
:
112 case Atom::ImageText
:
118 case Atom::ListBegin
:
120 case Atom::ListItemNumber
:
122 case Atom::ListItemBegin
:
123 out() << ".IP " << atom
->string() << ".\n";
125 case Atom::ListItemEnd
:
131 case Atom::ParaBegin
:
137 case Atom::RawFormat
:
139 case Atom::RawString
:
141 case Atom::SectionBegin
:
143 case Atom::SectionEnd
:
145 case Atom::SectionHeadingBegin
:
147 case Atom::SectionHeadingEnd
:
149 case Atom::SidebarBegin
:
151 case Atom::SidebarEnd
:
154 out() << protectTextLine( atom
->string() );
156 case Atom::TableBegin
:
160 case Atom::TableOfContents
:
164 case Atom::UnknownCommand
:
172 void ManGenerator::generateClassLikeNode( const InnerNode
*classe
,
175 generateHeader( classe
->name() );
176 out() << ".SH NAME\n"
177 << classe
->name() << "\n"
179 generateBody( classe
, marker
);
183 void ManGenerator::generateFakeNode( const FakeNode
*fake
, CodeMarker
*marker
)
185 generateHeader( "foo" );
186 generateBody( fake
, marker
);
190 QString
ManGenerator::fileExtension(const Node
* /* node */)
195 void ManGenerator::generateHeader( const QString
& name
)
197 out() << ".TH " << protectArg( name
)
198 << " " << protectArg( "3qt" )
199 << " " << protectArg( date
)
200 << " " << protectArg( "Nokia Corporation and/or its subsidiary(-ies)" )
201 << " " << protectArg( "Qt Toolkit" ) << "\n";
204 void ManGenerator::generateFooter()
208 QString
ManGenerator::protectArg( const QString
& str
)
210 for ( int i
= 0; i
< (int) str
.length(); i
++ ) {
211 if ( str
[i
] == ' ' || str
[i
].isSpace() ) {
212 QString quoted
= str
;
213 quoted
.replace( "\"", "\"\"" );
214 return "\"" + quoted
+ "\"";
220 QString
ManGenerator::protectTextLine( const QString
& str
)
223 if ( t
.startsWith(".") || t
.startsWith("'") )