yard-xml 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in couchbase.gemspec
4
+ gemspec
data/README.markdown ADDED
@@ -0,0 +1,20 @@
1
+ # YardXML: an YARD extension for XML output
2
+
3
+ YardXML is an YARD extension which allows to produce XML output from
4
+ YARD registry.
5
+
6
+ ## Usage
7
+
8
+ Install the gem:
9
+
10
+ gem install yard-xml
11
+
12
+ Edit ~/.yard/config and insert the following line:
13
+
14
+ load_plugins: true
15
+
16
+ Run yardoc with `-f xml` switch to specify XML format.
17
+
18
+ yard -f xml
19
+
20
+ It will generate `doc/index.xml` file for you.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'bundler/gem_tasks'
19
+
20
+ Dir['tasks/*.rake'].sort.each { |f| load f }
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ def init
20
+ xml = options[:xml_builder]
21
+ xml.class(:name => object.name, :superclass => object.superclass.name) do
22
+ xml.summary(docstring_summary(object))
23
+ xml.description do
24
+ xml.cdata!(html_markup_rdoc(object.docstring))
25
+ end
26
+ if object.respond_to?(:children)
27
+ object.children.sort_by do |child|
28
+ [
29
+ child.type.to_s,
30
+ child.respond_to?(:scope) ? child.scope.to_s : "",
31
+ child.name.to_s
32
+ ]
33
+ end.each do |child|
34
+ child.format(options.merge(:type => child.type))
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ def init
20
+ xml = options[:xml_builder]
21
+ xml.constant(:name => object.name, :value => object.value) do
22
+ xml.description do
23
+ xml.cdata!(html_markup_rdoc(object.docstring))
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ def init
20
+ Templates::Engine.with_serializer('index.xml', options[:serializer]) do
21
+ xml = Builder::XmlMarkup.new(:indent => 4)
22
+ xml.documetation do
23
+ YARD::Registry.root.children.sort_by do |child|
24
+ [
25
+ child.type.to_s,
26
+ child.respond_to?(:scope) ? child.scope.to_s : "",
27
+ child.name.to_s
28
+ ]
29
+ end.each do |child|
30
+ child.format(options.merge(:xml_builder => xml))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,185 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ def init
20
+ xml = options[:xml_builder]
21
+ info = {:name => object.name, :scope => object.scope}
22
+ if object.is_attribute?
23
+ if object.name:default_format
24
+ end
25
+ info[:attribute] = true
26
+ info[:name] = object.name.to_s.sub(/=$/, '')
27
+ if rw = object.attr_info
28
+ if rw[:read]
29
+ info[:reader] = true
30
+ object.parent.children.delete(rw[:read])
31
+ if object.docstring.start_with?("rb_define")
32
+ object.docstring = rw[:read].docstring
33
+ end
34
+ end
35
+ if rw[:write]
36
+ info[:writer] = true
37
+ object.parent.children.delete(rw[:write])
38
+ if object.docstring.start_with?("rb_define")
39
+ object.docstring = rw[:write].docstring
40
+ end
41
+ end
42
+ end
43
+ end
44
+ if object.has_tag?(:since)
45
+ info[:since] = object.tag(:since).text
46
+ end
47
+ xml.method(info) do
48
+ xml.summary(docstring_summary(object))
49
+ if object.tags(:overload).size > 0
50
+ xml.description(docstring_description(object, object.docstring.summary))
51
+ xml.notes do
52
+ object.tags(:note).each do |note|
53
+ xml.note do
54
+ xml.cdata!(html_markup_rdoc(note.text || ""))
55
+ end
56
+ end
57
+ end if object.has_tag?(:note)
58
+ end
59
+ object.aliases.each do |aa|
60
+ xml.alias(:name => aa.name)
61
+ end
62
+ xml.overloads do
63
+ if object.tags(:overload).size > 0
64
+ object.tags(:overload).each do |overload|
65
+ describe_method(xml, object, overload)
66
+ end
67
+ else
68
+ describe_method(xml, object, object)
69
+ end
70
+ end
71
+ end unless object.is_alias?
72
+ end
73
+
74
+ def describe_method(xml, object, method)
75
+ xml.overload do
76
+ xml.signature(text_signature(method))
77
+ xml.description(docstring_description(method, object.docstring.summary))
78
+
79
+ option_tags = method.tags(:option)
80
+ [:param, :yieldparam].each do |tag_name|
81
+ xml.tag!("#{tag_name}s") do
82
+ method.tags(tag_name).each do |param|
83
+ info = {:name => param.name}
84
+ default = method.parameters.assoc(param.name)
85
+ if default && default[1]
86
+ info[:default] = default[1]
87
+ end
88
+ xml.tag!(param.tag_name, info) do
89
+ xml.types do
90
+ if param.types
91
+ param.types.each do |type|
92
+ xml.type(type)
93
+ end
94
+ else
95
+ xml.type("Object")
96
+ end
97
+ end
98
+ options = option_tags.select{|x| x.name.to_s == param.name}
99
+ unless options.empty?
100
+ xml.options do
101
+ options.each do |option|
102
+ info = {:name => option.pair.name}
103
+ if option.pair.defaults
104
+ info[:default] = option.pair.defaults.first
105
+ end
106
+ xml.option(info) do
107
+ xml.types do
108
+ if option.pair.types
109
+ option.pair.types.each do |type|
110
+ xml.type(type)
111
+ end
112
+ else
113
+ xml.type("Object")
114
+ end
115
+ end
116
+ xml.description do
117
+ xml.cdata!(html_markup_rdoc(option.pair.text || ""))
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+ xml.description do
124
+ xml.cdata!(html_markup_rdoc(param.text || ""))
125
+ end
126
+ end
127
+ end
128
+ end if method.has_tag?(tag_name)
129
+ end
130
+
131
+ [:yieldreturn, :return].each do |tag_name|
132
+ xml.tag!("#{tag_name}s") do
133
+ ret = method.tag(tag_name)
134
+ xml.types do
135
+ if ret.types
136
+ ret.types.each do |type|
137
+ xml.type(type)
138
+ end
139
+ else
140
+ xml.type("Object")
141
+ end
142
+ end
143
+ xml.description do
144
+ xml.cdata!(html_markup_rdoc(ret.text || ""))
145
+ end
146
+ end if method.has_tag?(tag_name)
147
+ end
148
+
149
+ xml.exceptions do
150
+ method.tags(:raise).each do |exc|
151
+ xml.exception do
152
+ xml.types do
153
+ if exc.types
154
+ exc.types.each do |type|
155
+ xml.type(type)
156
+ end
157
+ end
158
+ end
159
+ xml.description do
160
+ xml.cdata!(html_markup_rdoc(exc.text || ""))
161
+ end
162
+ end
163
+ end
164
+ end if method.has_tag?(:raise)
165
+
166
+ xml.notes do
167
+ method.tags(:note).each do |note|
168
+ xml.note do
169
+ xml.cdata!(html_markup_rdoc(note.text || ""))
170
+ end
171
+ end
172
+ end if method.has_tag?(:note)
173
+
174
+ xml.examples do
175
+ method.tags(:example).each do |example|
176
+ xml.example do
177
+ xml.description do
178
+ xml.cdata!(html_markup_rdoc(example.name || ""))
179
+ end
180
+ xml.code(example.text)
181
+ end
182
+ end
183
+ end if method.has_tag?(:example)
184
+ end
185
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ def init
20
+ xml = options[:xml_builder]
21
+ xml.module(:name => object.name) do
22
+ if object.respond_to?(:children)
23
+ object.children.sort_by do |child|
24
+ [
25
+ child.type.to_s,
26
+ child.respond_to?(:scope) ? child.scope.to_s : "",
27
+ child.name.to_s
28
+ ]
29
+ end.each do |child|
30
+ child.format(options.merge(:type => child.type))
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/yard-xml.rb ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require File.dirname(__FILE__) + '/yard-xml/helper'
20
+ YARD::Templates::Template.extra_includes = [YardXML::Helper]
21
+ YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/templates')
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'builder'
20
+
21
+ module YardXML
22
+ module Helper
23
+
24
+ include YARD::Templates::Helpers::TextHelper
25
+ alias :text_signature :signature
26
+
27
+ include YARD::Templates::Helpers::HtmlHelper
28
+ alias :html_signature :signature
29
+
30
+ def docstring_summary(object)
31
+ object.docstring.summary.gsub(/\n\s*/m, ' ')
32
+ end
33
+
34
+ def docstring_description(object, summary)
35
+ body = object.docstring.to_s.dup
36
+ if body.start_with?(summary)
37
+ body[0..summary.size] = ''
38
+ end
39
+ html_markup_rdoc(body)
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module YardXML
19
+ VERSION = "0.1.0"
20
+ end
@@ -0,0 +1,28 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'rubygems/package_task'
19
+
20
+ def gemspec
21
+ @clean_gemspec ||= eval(File.read(File.expand_path('../../yard-xml.gemspec', __FILE__)))
22
+ end
23
+
24
+ Gem::PackageTask.new(gemspec) do |pkg|
25
+ pkg.need_zip = true
26
+ pkg.need_tar = true
27
+ end
28
+
data/yard-xml.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ $:.push File.expand_path('../lib', __FILE__)
20
+ require 'yard'
21
+ require 'yard-xml/version'
22
+
23
+ Gem::Specification.new do |s|
24
+ s.name = 'yard-xml'
25
+ s.version = YardXML::VERSION
26
+ s.author = 'Couchbase'
27
+ s.email = 'support@couchbase.com'
28
+ s.license = 'ASL-2'
29
+ s.homepage = 'http://couchbase.org'
30
+ s.summary = %q{XML plugin for YARD tool}
31
+ s.description = %q{This plugin allows to render YARD documentation into the single XML file for further processing.}
32
+
33
+ s.files = `git ls-files`.split("\n")
34
+ s.add_dependency 'yard'
35
+ s.require_paths = ['lib']
36
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-xml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Couchbase
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: This plugin allows to render YARD documentation into the single XML file
31
+ for further processing.
32
+ email: support@couchbase.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - README.markdown
40
+ - Rakefile
41
+ - lib/templates/default/class/xml/setup.rb
42
+ - lib/templates/default/constant/xml/setup.rb
43
+ - lib/templates/default/fulldoc/xml/setup.rb
44
+ - lib/templates/default/method/xml/setup.rb
45
+ - lib/templates/default/module/xml/setup.rb
46
+ - lib/yard-xml.rb
47
+ - lib/yard-xml/helper.rb
48
+ - lib/yard-xml/version.rb
49
+ - tasks/package.rake
50
+ - yard-xml.gemspec
51
+ homepage: http://couchbase.org
52
+ licenses:
53
+ - ASL-2
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.18
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: XML plugin for YARD tool
76
+ test_files: []