yard-gobject 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -1
- data/templates/default/fulldoc/html/css/common.css +6 -0
- data/templates/default/tags/html/properties.erb +1 -0
- data/yard-gobject.gemspec +1 -1
- data/yard-gobject.rb +62 -3
- metadata +1 -1
data/README.md
CHANGED
@@ -15,11 +15,22 @@ For now, it supports only one tag: <code>@properties</code>. This tag can be app
|
|
15
15
|
|
16
16
|
**Syntax**
|
17
17
|
|
18
|
-
# @properties property-name [PropertyType] description,
|
18
|
+
# @properties property-name [PropertyType] :PropertyAccess description,
|
19
19
|
# another-property [PropertyType] description...
|
20
20
|
|
21
|
+
<code>:PropertyAccess</code> is used to represent the access to the properties. Only three access permissions are used. The order in which they appear is unimportant. The letters used for specifying the position are as follows:
|
22
|
+
|
23
|
+
+ **R** — for Read
|
24
|
+
+ **W** — for Write
|
25
|
+
+ **C** — for Construct
|
26
|
+
|
21
27
|
<code>PropertyType</code> is formatted the same way YARD formats types. <code>description</code> can be ommited.
|
22
28
|
|
29
|
+
|
30
|
+
***An example:***
|
31
|
+
##
|
32
|
+
# @properties uri [String] :RWC, visible [String] :RWC
|
33
|
+
|
23
34
|
License
|
24
35
|
-------
|
25
36
|
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<li>
|
7
7
|
<span class="name"><%= prop[:name] %></span>
|
8
8
|
<span class="type"><%= format_types prop[:type] %></span>
|
9
|
+
<span class="access"><%= format_gobject_property_access(prop) %>
|
9
10
|
<% if !prop[:description].nil? and !prop[:description].empty? %>
|
10
11
|
<span class="description"><%= htmlify_line prop[:description] %></span>
|
11
12
|
<% end %>
|
data/yard-gobject.gemspec
CHANGED
data/yard-gobject.rb
CHANGED
@@ -35,6 +35,29 @@ YARD::Templates::Engine.register_template_path(template_dir)
|
|
35
35
|
YARD::Tags::Library.define_tag("GObject Properties", :properties)
|
36
36
|
|
37
37
|
module YARD::Templates::Helpers::HtmlHelper
|
38
|
+
# extracts the GObject properties from a {YARD::Tags::Tag}
|
39
|
+
#
|
40
|
+
# The syntax of the +@properties+ tag is as follows:
|
41
|
+
#
|
42
|
+
# +property_name+ can be any name containing any letter, underscore
|
43
|
+
# or dash. Please note that dashes will be automatically converted
|
44
|
+
# to underscores.
|
45
|
+
#
|
46
|
+
# +PropertyType+ can be any Ruby Object that best fits the GType used
|
47
|
+
# in the GObject property.
|
48
|
+
#
|
49
|
+
# +:PropertyAccess+ represents the permissions associated with a
|
50
|
+
# property. They can be either *R*, for Read, *W*, for Write, and
|
51
|
+
# *C*, for Construct. Their order is unimportant. It is, however,
|
52
|
+
# important that they are preceeded by the column (:) character.
|
53
|
+
#
|
54
|
+
# desc is any description that you might want to add to this
|
55
|
+
# property. It can be ommited.
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# # @properties uri [String] :RW, visible [Boolean] :RWC
|
59
|
+
#
|
60
|
+
# @return YARD::Tags::Tag
|
38
61
|
def format_gobject_properties(tag)
|
39
62
|
text = tag.text
|
40
63
|
|
@@ -46,12 +69,28 @@ module YARD::Templates::Helpers::HtmlHelper
|
|
46
69
|
properties = []
|
47
70
|
|
48
71
|
unformatted_properties.each do |prop|
|
49
|
-
p = {:name => nil, :type => nil, :description => nil}
|
50
|
-
prop_regex = prop.match(/\A([\w\-]+) \[([\w\S ]+)\] *(.*)\z/)
|
72
|
+
p = {:name => nil, :type => nil, :access => nil, :description => nil}
|
73
|
+
prop_regex = prop.match(/\A([\w\-]+) \[([\w\S ]+)\] \:([RWC]+) *(.*)\z/)
|
51
74
|
|
52
75
|
unless prop_regex.nil?
|
53
|
-
p[:name], p[:type], p[:description] =
|
76
|
+
p[:name], p[:type], p[:access], p[:description] =
|
77
|
+
prop_regex.captures
|
54
78
|
p[:type] = p[:type].split /,\ */
|
79
|
+
|
80
|
+
access_split = p[:access].split ''
|
81
|
+
p[:access] = {:read => false, :write => false, :construct => false}
|
82
|
+
|
83
|
+
access_split.each do |a|
|
84
|
+
if a == 'R'
|
85
|
+
p[:access][:read] = true
|
86
|
+
elsif a == 'W'
|
87
|
+
p[:access][:write] = true
|
88
|
+
elsif a == 'C'
|
89
|
+
p[:access][:construct] = true
|
90
|
+
else
|
91
|
+
warn 'Only R, W, or C can be used as access permisions on a GObject Property.'
|
92
|
+
end
|
93
|
+
end
|
55
94
|
end
|
56
95
|
|
57
96
|
properties << p
|
@@ -59,5 +98,25 @@ module YARD::Templates::Helpers::HtmlHelper
|
|
59
98
|
|
60
99
|
return properties
|
61
100
|
end
|
101
|
+
|
102
|
+
# Formats the +:access+ key from a GObject Property.
|
103
|
+
#
|
104
|
+
# @see YARD::Templates::Helpers::HtmlHelper#format_gobject_properties
|
105
|
+
#
|
106
|
+
# @return [String] A string formatted as 'Read / Write / Construct'
|
107
|
+
def format_gobject_property_access(prop, separator=' / ')
|
108
|
+
access = prop[:access]
|
109
|
+
|
110
|
+
order = [:read, :write, :construct]
|
111
|
+
out = []
|
112
|
+
|
113
|
+
order.each do |o|
|
114
|
+
if access[o]
|
115
|
+
out << o.to_s.capitalize
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
out.join(separator)
|
120
|
+
end
|
62
121
|
end
|
63
122
|
|