(PDOC-17) Clean up code and update README
Do a bit of renaming and add some comments to make the processing of parameter details a bit more clear. Additionally, update the example in the README so that it will actually be parsed properly by YARD (since YARD does not expect the one line title before the description).
This commit is contained in:
parent
d15269458e
commit
1f2d9a2d8a
|
@ -76,8 +76,6 @@ Here's an example of how you might document a 4x function:
|
||||||
|
|
||||||
And here's an example of how you might document a class:
|
And here's an example of how you might document a class:
|
||||||
|
|
||||||
# Class: Example
|
|
||||||
#
|
|
||||||
# This class is meant to serve as an example of how one might
|
# This class is meant to serve as an example of how one might
|
||||||
# want to document a manifest in a way that is compatible.
|
# want to document a manifest in a way that is compatible.
|
||||||
# with the strings module
|
# with the strings module
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
<tt>(TBD)</tt>
|
<tt>(TBD)</tt>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
<% unless param[:module].nil? %>
|
<% unless param[:fq_name].nil? %>
|
||||||
<tt><%= "=> #{param[:module]}" %></tt>
|
<tt><%= "=> #{param[:fq_name]}" %></tt>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if param[:desc]%>
|
<% if param[:desc]%>
|
||||||
—
|
—
|
||||||
|
|
|
@ -37,8 +37,20 @@ def docstring
|
||||||
erb(:docstring)
|
erb(:docstring)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Given the parameter information and YARD param tags, extracts the
|
||||||
|
# useful information and returns it as an array of hashes which can
|
||||||
|
# be printed and formatted in the paramters_details erb file
|
||||||
|
#
|
||||||
|
# @param params_hash [Array] parameter details obtained programmatically
|
||||||
|
# @param tags_hash [Array] parameter details obtained from comments
|
||||||
|
#
|
||||||
|
# @return [Hash] The relevant information about each parameter
|
||||||
|
# @option opts [String] :name The name of the parameter
|
||||||
|
# @option opts [String] :fq_name The fully qualified parameter name
|
||||||
|
# @option opts [String] :desc The description provided in the comment
|
||||||
|
# @options opts [Array] :types The parameter type(s) specified in the comment
|
||||||
|
# @options opts [Boolean] :exists? True only if the parameter actually exists and just not just defined in the comment
|
||||||
def extract_param_details(params_hash, tags_hash)
|
def extract_param_details(params_hash, tags_hash)
|
||||||
|
|
||||||
parameter_info = []
|
parameter_info = []
|
||||||
|
|
||||||
# Extract the information for parameters that actually exist
|
# Extract the information for parameters that actually exist
|
||||||
|
@ -48,7 +60,7 @@ def extract_param_details(params_hash, tags_hash)
|
||||||
description = param_tag.nil? ? nil : param_tag.text
|
description = param_tag.nil? ? nil : param_tag.text
|
||||||
param_types = param_tag.nil? ? nil : param_tag.types
|
param_types = param_tag.nil? ? nil : param_tag.types
|
||||||
|
|
||||||
parameter_info.push({:name => param[0], :module => param[1], :desc => description, :types => param_types, :exists? => true})
|
parameter_info.push({:name => param[0], :fq_name => param[1], :desc => description, :types => param_types, :exists? => true})
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if there were any comments for parameters that do not exist
|
# Check if there were any comments for parameters that do not exist
|
||||||
|
@ -60,7 +72,7 @@ def extract_param_details(params_hash, tags_hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !param_exists
|
if !param_exists
|
||||||
parameter_info.push({:name => tag.name, :module => nil, :desc => tag.text, :types => tag.types, :exists? => false})
|
parameter_info.push({:name => tag.name, :fq_name => nil, :desc => tag.text, :types => tag.types, :exists? => false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue