source: trunk/tools/qdoc3/mangenerator.cpp@ 500

Last change on this file since 500 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
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.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
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
26** package.
27**
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.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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
53QT_BEGIN_NAMESPACE
54
55ManGenerator::ManGenerator()
56{
57 date = QDate::currentDate().toString( "d MMMM yyyy" );
58}
59
60ManGenerator::~ManGenerator()
61{
62}
63
64QString ManGenerator::format()
65{
66 return "man";
67}
68
69int 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
172void 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
183void ManGenerator::generateFakeNode( const FakeNode *fake, CodeMarker *marker )
184{
185 generateHeader( "foo" );
186 generateBody( fake, marker );
187 generateFooter();
188}
189
190QString ManGenerator::fileExtension(const Node * /* node */)
191{
192 return "3qt";
193}
194
195void 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
204void ManGenerator::generateFooter()
205{
206}
207
208QString 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
220QString ManGenerator::protectTextLine( const QString& str )
221{
222 QString t = str;
223 if ( t.startsWith(".") || t.startsWith("'") )
224 t.prepend( "\\&" );
225 return t;
226}
227
228QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.