Jira (PDOC-287) Ruby 4.x function with single dispatch gets docs generated twice

12 views
Skip to first unread message

Henrik Lindberg (JIRA)

unread,
Aug 18, 2019, 5:10:03 AM8/18/19
to puppe...@googlegroups.com
Henrik Lindberg created an issue
 
Puppet Strings / Bug PDOC-287
Ruby 4.x function with single dispatch gets docs generated twice
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2019/08/18 2:09 AM
Priority: Normal Normal
Reporter: Henrik Lindberg

For a 4.x function with a single dispatch and where there is documentation for the entire function, then the entire documentation is output twice - once for the function and once for the single dispatch signature.

Adding a second dispatch results in the function level documentation to be output only once.
Tested with markdown format output.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Aug 18, 2019, 5:20:02 AM8/18/19
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PDOC-287
 
Re: Ruby 4.x function with single dispatch gets docs generated twice

Example that results in bad output:

# Converts a value from a `RichData` compliant data structure to the actual runtime values.
#
# This function is useful as deserialization of a rich data structure - for example something read from
# a yaml file. This is the reverse of `tahu::convert_to_rich_data()`.
#
# See
# * `tahu::convert_to_rich_data` for how to serialize.
# * [Pcore Data Representation Specification](https://github.com/puppetlabs/puppet-specifications/blob/master/language/data-types/pcore-data-representation.md)
#
#
# @example Deserializing a value
#   $r = /this is a regexp/
#   $serialized = tahu::convert_to_rich_data($r)
#   $deserialized = tahu::convert_from_rich_data($serialized)
#   notice( $deserialized == $r)
#   # would notice: true
#
Puppet::Functions.create_function(:'tahu::convert_from_rich_data', Puppet::Functions::InternalFunction) do
 
  # @param value - The rich data value to convert from
  dispatch :from_rich_data do
    scope_param
    required_param 'RichData', :value
    return_type 'Any'
  end
 
  def from_rich_data(scope, val)
    Puppet::Pops::Serialization::FromDataConverter.convert(val)
  end
end

Jean Bond (JIRA)

unread,
Aug 19, 2019, 12:27:04 PM8/19/19
to puppe...@googlegroups.com
Jean Bond commented on Bug PDOC-287

Hi Henrik Lindberg! I'm wondering if this is a formatting issue. For a Ruby function, tags should go before the dispatch call. Also, I believe that there should be no lines between the `Puppet::Function...` and the following Strings tags. Can you please check to see if that fixes the issue, and let us know here?

So:

# Converts a value from a `RichData` compliant data structure to the actual runtime values.
# This function is useful as deserialization of a rich data structure - for example something read from
# a yaml file. This is the reverse of `tahu::convert_to_rich_data()`.
#
# See
# * `tahu::convert_to_rich_data` for how to serialize.
# * [Pcore Data Representation Specification](https://github.com/puppetlabs/puppet-specifications/blob/master/language/data-types/pcore-data-representation.md)
Puppet::Functions.create_function(:'tahu::convert_from_rich_data', Puppet::Functions::InternalFunction) do
  # @example Deserializing a value
  #    $r = /this is a regexp/
  #    $serialized = tahu::convert_to_rich_data($r)
  #    $deserialized = tahu::convert_from_rich_data($serialized)
  #    notice( $deserialized == $r)
  #    # would notice: true
  # @param value - The rich data value to convert from
  dispatch :from_rich_data do
    scope_param
    required_param 'RichData', :value
    return_type 'Any'
  end
 
  def from_rich_data(scope, val)
    Puppet::Pops::Serialization::FromDataConverter.convert(val)
  end
end

Henrik Lindberg (JIRA)

unread,
Aug 19, 2019, 12:51:03 PM8/19/19
to puppe...@googlegroups.com

Jean Bond None of the suggested changes make any difference - the output is identical.

Jean Bond (JIRA)

unread,
Aug 19, 2019, 1:04:03 PM8/19/19
to puppe...@googlegroups.com

Jean Bond (JIRA)

unread,
Aug 20, 2019, 7:44:02 PM8/20/19
to puppe...@googlegroups.com

Jesse Scott (JIRA)

unread,
Aug 20, 2019, 7:44:03 PM8/20/19
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages