0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
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 |
** 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
|
|
14 |
** this package.
|
|
15 |
**
|
|
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.
|
|
23 |
**
|
|
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.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
/*
|
|
43 |
mangenerator.cpp
|
|
44 |
*/
|
|
45 |
|
|
46 |
#include <qdatetime.h>
|
|
47 |
#include <qregexp.h>
|
|
48 |
|
|
49 |
#include "mangenerator.h"
|
|
50 |
#include "node.h"
|
|
51 |
#include "tree.h"
|
|
52 |
|
|
53 |
QT_BEGIN_NAMESPACE
|
|
54 |
|
|
55 |
ManGenerator::ManGenerator()
|
|
56 |
{
|
|
57 |
date = QDate::currentDate().toString( "d MMMM yyyy" );
|
|
58 |
}
|
|
59 |
|
|
60 |
ManGenerator::~ManGenerator()
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
QString ManGenerator::format()
|
|
65 |
{
|
|
66 |
return "man";
|
|
67 |
}
|
|
68 |
|
|
69 |
int ManGenerator::generateAtom( const Atom *atom, const Node * /* relative */,
|
|
70 |
CodeMarker * /* marker */ )
|
|
71 |
{
|
|
72 |
#if 0
|
|
73 |
switch ( atom->type() ) {
|
|
74 |
case Atom::AbstractBegin:
|
|
75 |
break;
|
|
76 |
case Atom::AbstractEnd:
|
|
77 |
break;
|
|
78 |
case Atom::Alias:
|
|
79 |
break;
|
|
80 |
case Atom::AliasArg:
|
|
81 |
break;
|
|
82 |
case Atom::BaseName:
|
|
83 |
break;
|
|
84 |
case Atom::BriefBegin:
|
|
85 |
break;
|
|
86 |
case Atom::BriefEnd:
|
|
87 |
break;
|
|
88 |
case Atom::C:
|
|
89 |
break;
|
|
90 |
case Atom::CaptionBegin:
|
|
91 |
break;
|
|
92 |
case Atom::CaptionEnd:
|
|
93 |
break;
|
|
94 |
case Atom::CitationBegin:
|
|
95 |
break;
|
|
96 |
case Atom::CitationEnd:
|
|
97 |
break;
|
|
98 |
case Atom::Code:
|
|
99 |
break;
|
|
100 |
case Atom::FootnoteBegin:
|
|
101 |
break;
|
|
102 |
case Atom::FootnoteEnd:
|
|
103 |
break;
|
|
104 |
case Atom::FormatBegin:
|
|
105 |
break;
|
|
106 |
case Atom::FormatEnd:
|
|
107 |
break;
|
|
108 |
case Atom::GeneratedList:
|
|
109 |
break;
|
|
110 |
case Atom::Image:
|
|
111 |
break;
|
|
112 |
case Atom::ImageText:
|
|
113 |
break;
|
|
114 |
case Atom::Link:
|
|
115 |
break;
|
|
116 |
case Atom::LinkNode:
|
|
117 |
break;
|
|
118 |
case Atom::ListBegin:
|
|
119 |
break;
|
|
120 |
case Atom::ListItemNumber:
|
|
121 |
break;
|
|
122 |
case Atom::ListItemBegin:
|
|
123 |
out() << ".IP " << atom->string() << ".\n";
|
|
124 |
break;
|
|
125 |
case Atom::ListItemEnd:
|
|
126 |
break;
|
|
127 |
case Atom::ListEnd:
|
|
128 |
break;
|
|
129 |
case Atom::Nop:
|
|
130 |
break;
|
|
131 |
case Atom::ParaBegin:
|
|
132 |
out() << ".PP\n";
|
|
133 |
break;
|
|
134 |
case Atom::ParaEnd:
|
|
135 |
out() << "\n";
|
|
136 |
break;
|
|
137 |
case Atom::RawFormat:
|
|
138 |
break;
|
|
139 |
case Atom::RawString:
|
|
140 |
break;
|
|
141 |
case Atom::SectionBegin:
|
|
142 |
break;
|
|
143 |
case Atom::SectionEnd:
|
|
144 |
break;
|
|
145 |
case Atom::SectionHeadingBegin:
|
|
146 |
break;
|
|
147 |
case Atom::SectionHeadingEnd:
|
|
148 |
break;
|
|
149 |
case Atom::SidebarBegin:
|
|
150 |
break;
|
|
151 |
case Atom::SidebarEnd:
|
|
152 |
break;
|
|
153 |
case Atom::String:
|
|
154 |
out() << protectTextLine( atom->string() );
|
|
155 |
break;
|
|
156 |
case Atom::TableBegin:
|
|
157 |
break;
|
|
158 |
case Atom::TableEnd:
|
|
159 |
break;
|
|
160 |
case Atom::TableOfContents:
|
|
161 |
break;
|
|
162 |
case Atom::Target:
|
|
163 |
break;
|
|
164 |
case Atom::UnknownCommand:
|
|
165 |
;
|
|
166 |
}
|
|
167 |
#endif
|
|
168 |
unknownAtom( atom );
|
|
169 |
return 0;
|
|
170 |
}
|
|
171 |
|
|
172 |
void ManGenerator::generateClassLikeNode( const InnerNode *classe,
|
|
173 |
CodeMarker *marker )
|
|
174 |
{
|
|
175 |
generateHeader( classe->name() );
|
|
176 |
out() << ".SH NAME\n"
|
|
177 |
<< classe->name() << "\n"
|
|
178 |
<< ".SH SYNOPSYS\n";
|
|
179 |
generateBody( classe, marker );
|
|
180 |
generateFooter();
|
|
181 |
}
|
|
182 |
|
|
183 |
void ManGenerator::generateFakeNode( const FakeNode *fake, CodeMarker *marker )
|
|
184 |
{
|
|
185 |
generateHeader( "foo" );
|
|
186 |
generateBody( fake, marker );
|
|
187 |
generateFooter();
|
|
188 |
}
|
|
189 |
|
|
190 |
QString ManGenerator::fileExtension(const Node * /* node */)
|
|
191 |
{
|
|
192 |
return "3qt";
|
|
193 |
}
|
|
194 |
|
|
195 |
void ManGenerator::generateHeader( const QString& name )
|
|
196 |
{
|
|
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";
|
|
202 |
}
|
|
203 |
|
|
204 |
void ManGenerator::generateFooter()
|
|
205 |
{
|
|
206 |
}
|
|
207 |
|
|
208 |
QString ManGenerator::protectArg( const QString& str )
|
|
209 |
{
|
|
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 + "\"";
|
|
215 |
}
|
|
216 |
}
|
|
217 |
return str;
|
|
218 |
}
|
|
219 |
|
|
220 |
QString ManGenerator::protectTextLine( const QString& str )
|
|
221 |
{
|
|
222 |
QString t = str;
|
|
223 |
if ( t.startsWith(".") || t.startsWith("'") )
|
|
224 |
t.prepend( "\\&" );
|
|
225 |
return t;
|
|
226 |
}
|
|
227 |
|
|
228 |
QT_END_NAMESPACE
|