3 * Copyright (C) 2011 Florian Brosch
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Florian Brosch <flo.brosch@gmail.com>
27 * Code visitor generating .gir file for the public interface.
29 public class Valadoc
.Drivers
.GirWriter
: Vala
.GIRWriter
{
30 private GtkdocRenderer renderer
;
31 private SymbolResolver resolver
;
33 public GirWriter (SymbolResolver resolver
) {
34 this
.renderer
= new
GtkdocRenderer ();
35 this
.resolver
= resolver
;
38 private string?
translate (Content
.Comment? documentation
) {
39 if (documentation
== null) {
43 renderer
.render_symbol (documentation
);
45 return MarkupWriter
.escape (renderer
.content
);
48 private string?
translate_taglet (Content
.Taglet? taglet
) {
53 renderer
.render_children (taglet
);
55 return MarkupWriter
.escape (renderer
.content
);
58 protected override string?
get_interface_comment (Vala
.Interface viface
) {
59 Interface iface
= resolver
.resolve (viface
) as Interface
;
60 return translate (iface
.documentation
);
63 protected override string?
get_struct_comment (Vala
.Struct vst
) {
64 Struct st
= resolver
.resolve (vst
) as Struct
;
65 return translate (st
.documentation
);
68 protected override string?
get_enum_comment (Vala
.Enum ven
) {
69 Enum en
= resolver
.resolve (ven
) as Enum
;
70 return translate (en
.documentation
);
73 protected override string?
get_class_comment (Vala
.Class vc
) {
74 Class c
= resolver
.resolve (vc
) as Class
;
75 return translate (c
.documentation
);
78 protected override string?
get_error_code_comment (Vala
.ErrorCode vecode
) {
79 ErrorCode ecode
= resolver
.resolve (vecode
) as ErrorCode
;
80 return translate (ecode
.documentation
);
83 protected override string?
get_enum_value_comment (Vala
.EnumValue vev
) {
84 Api
.EnumValue ev
= resolver
.resolve (vev
) as Api
.EnumValue
;
85 return translate (ev
.documentation
);
88 protected override string?
get_constant_comment (Vala
.Constant vc
) {
89 Constant c
= resolver
.resolve (vc
) as Constant
;
90 return translate (c
.documentation
);
93 protected override string?
get_error_domain_comment (Vala
.ErrorDomain vedomain
) {
94 ErrorDomain edomain
= resolver
.resolve (vedomain
) as ErrorDomain
;
95 return translate (edomain
.documentation
);
98 protected override string?
get_field_comment (Vala
.Field vf
) {
99 Field f
= resolver
.resolve (vf
) as Field
;
100 return translate (f
.documentation
);
103 protected override string?
get_delegate_comment (Vala
.Delegate vcb
) {
104 Delegate cb
= resolver
.resolve (vcb
) as Delegate
;
105 return translate (cb
.documentation
);
108 protected override string?
get_method_comment (Vala
.Method vm
) {
109 Method m
= resolver
.resolve (vm
) as Method
;
110 return translate (m
.documentation
);
113 protected override string?
get_property_comment (Vala
.Property vprop
) {
114 Property prop
= resolver
.resolve (vprop
) as Property
;
115 return translate (prop
.documentation
);
118 protected override string?
get_delegate_return_comment (Vala
.Delegate vcb
) {
119 Delegate cb
= resolver
.resolve (vcb
) as Delegate
;
120 if (cb
.documentation
== null) {
124 Content
.Comment? documentation
= cb
.documentation
;
125 if (documentation
== null) {
129 Vala
.List
<Content
.Taglet
> taglets
= documentation
.find_taglets (cb
, typeof(Taglets
.Return
));
130 foreach (Content
.Taglet taglet
in taglets
) {
131 return translate_taglet (taglet
);
137 protected override string?
get_signal_return_comment (Vala
.Signal vsig
) {
138 Api
.Signal sig
= resolver
.resolve (vsig
) as Api
.Signal
;
139 if (sig
.documentation
== null) {
143 Content
.Comment? documentation
= sig
.documentation
;
144 if (documentation
== null) {
148 Vala
.List
<Content
.Taglet
> taglets
= documentation
.find_taglets (sig
, typeof(Taglets
.Return
));
149 foreach (Content
.Taglet taglet
in taglets
) {
150 return translate_taglet (taglet
);
156 protected override string?
get_method_return_comment (Vala
.Method vm
) {
157 Method m
= resolver
.resolve (vm
) as Method
;
158 if (m
.documentation
== null) {
162 Content
.Comment? documentation
= m
.documentation
;
163 if (documentation
== null) {
167 Vala
.List
<Content
.Taglet
> taglets
= documentation
.find_taglets (m
, typeof(Taglets
.Return
));
168 foreach (Content
.Taglet taglet
in taglets
) {
169 return translate_taglet (taglet
);
175 protected override string?
get_signal_comment (Vala
.Signal vsig
) {
176 Api
.Signal sig
= resolver
.resolve (vsig
) as Api
.Signal
;
177 return translate (sig
.documentation
);
180 protected override string?
get_parameter_comment (Vala
.Parameter param
) {
181 Api
.Symbol symbol
= resolver
.resolve (((Vala
.Symbol
) param
.parent_symbol
));
182 if (symbol
== null) {
186 Content
.Comment? documentation
= symbol
.documentation
;
187 if (documentation
== null) {
191 Vala
.List
<Content
.Taglet
> taglets
= documentation
.find_taglets (symbol
, typeof(Taglets
.Param
));
192 foreach (Content
.Taglet _taglet
in taglets
) {
193 Taglets
.Param taglet
= (Taglets
.Param
) _taglet
;
194 if (taglet
.parameter_name
== param
.name
) {
195 return translate_taglet (taglet
);