Skip to content

Commit 1ebf953

Browse files
committed
Add noDoc option to Vocabulary writer to eliminate the Yard documentation.
1 parent 0b9904f commit 1ebf953

2 files changed

Lines changed: 35 additions & 19 deletions

File tree

lib/rdf/vocab/rdfs.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module RDF
66
# @!parse
77
# # Vocabulary for <http://www.w3.org/2000/01/rdf-schema#>
88
# #
9+
# # The RDF Schema vocabulary (RDFS)
910
# class RDFS < RDF::StrictVocabulary
1011
# # The class of classes.
1112
# # @return [RDF::Vocabulary::Term]

lib/rdf/vocab/writer.rb

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,37 @@ def self.options
6565
on: ["--class-name NAME"],
6666
use: :required,
6767
description: "Name of created Ruby class (vocabulary format)."),
68+
RDF::CLI::Option.new(
69+
symbol: :extra,
70+
datatype: String,
71+
control: :none,
72+
on: ["--extra URIEncodedJSON"],
73+
description: "URI Encoded JSON representation of extra data"
74+
) do |arg|
75+
::JSON.parse(::CGI.unescape(arg)).inject({}) do |m1, (term, defs)|
76+
d1 = defs.inject({}) {|m, (k,v)| m.merge(k.to_sym => v)}
77+
m1.merge(term.to_sym => d1)
78+
end
79+
end,
6880
RDF::CLI::Option.new(
6981
symbol: :module_name,
7082
datatype: String,
7183
control: :text,
7284
on: ["--module-name NAME"],
7385
description: "Name of Ruby module containing class-name (vocabulary format)."),
86+
RDF::CLI::Option.new(
87+
symbol: :noDoc,
88+
datatype: TrueClass,
89+
control: :checkbox,
90+
on: ["--noDoc"],
91+
description: "Do not output Yard documentation."),
7492
RDF::CLI::Option.new(
7593
symbol: :strict,
7694
datatype: TrueClass,
7795
control: :checkbox,
7896
on: ["--strict"],
7997
description: "Make strict vocabulary"
8098
) {true},
81-
RDF::CLI::Option.new(
82-
symbol: :extra,
83-
datatype: String,
84-
control: :none,
85-
on: ["--extra URIEncodedJSON"],
86-
description: "URI Encoded JSON representation of extra data"
87-
) do |arg|
88-
::JSON.parse(::CGI.unescape(arg)).inject({}) do |m1, (term, defs)|
89-
d1 = defs.inject({}) {|m, (k,v)| m.merge(k.to_sym => v)}
90-
m1.merge(term.to_sym => d1)
91-
end
92-
end,
9399
]
94100
end
95101

@@ -144,14 +150,23 @@ def write_epilogue
144150
# This file generated automatically using rdf vocabulary format from #{source}
145151
require 'rdf'
146152
module #{module_name}
147-
# @!parse
153+
).gsub(/^ /, '')
154+
155+
@output.print %( # @!parse
148156
# # Vocabulary for <#{base_uri}>
149157
# #
150-
).gsub(/^ /, '')
158+
).gsub(/^ /, '') unless @options[:noDoc]
151159

152-
if vocab.ontology
160+
if vocab.ontology && !@options[:noDoc]
153161
ont_doc = []
154-
[:"dc:title", :"dc11:title", :label, :comment, :"dc:description", :"dc11:description"].each do |attr|
162+
%i(
163+
http://purl.org/dc/terms/title
164+
http://purl.org/dc/elements/1.1/title
165+
label
166+
comment
167+
http://purl.org/dc/terms/description
168+
http://purl.org/dc/elements/1.1/description
169+
).each do |attr|
155170
next unless vocab.ontology.attributes[attr]
156171
Array(vocab.ontology.attributes[attr]).each do |v|
157172
ont_doc << " # # " + v.to_s.gsub(/\n/, ' ')
@@ -167,7 +182,7 @@ module #{module_name}
167182
@output.puts " # # @see #{see}"
168183
end
169184
end
170-
@output.puts %( # class #{class_name} < RDF::#{"Strict" if strict}Vocabulary)
185+
@output.puts %( # class #{class_name} < RDF::#{"Strict" if strict}Vocabulary) unless @options[:noDoc]
171186

172187
# Split nodes into Class/Property/Datatype/Other
173188
term_nodes = {
@@ -213,10 +228,10 @@ module #{module_name}
213228
@output.puts " # attr_reader :#{name}"
214229
@output.puts " #"
215230
end
216-
end
231+
end unless @options[:noDoc]
217232

218233
# End of yard preamble
219-
@output.puts " # end"
234+
@output.puts " # end" unless @options[:noDoc]
220235
@output.puts %( #{class_name} = Class.new(RDF::#{"Strict" if strict}Vocabulary("#{base_uri}")) do)
221236

222237
# Output term definitions

0 commit comments

Comments
 (0)