Jira (PDOC-226) Support for Type Aliases

1 view
Skip to first unread message

Eric Putnam (JIRA)

unread,
Mar 2, 2018, 4:46:03 PM3/2/18
to puppe...@googlegroups.com
Eric Putnam created an issue
 
Puppet Strings / Task PDOC-226
Support for Type Aliases
Issue Type: Task Task
Assignee: Unassigned
Created: 2018/03/02 1:45 PM
Priority: Normal Normal
Reporter: Eric Putnam

Support for these would be great:
https://puppet.com/docs/puppet/5.3/lang_type_aliases.html

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

Henrik Lindberg (JIRA)

unread,
Mar 4, 2018, 6:18:04 AM3/4/18
to puppe...@googlegroups.com
Henrik Lindberg commented on Task PDOC-226
 
Re: Support for Type Aliases

There are type aliases as the ones described in the linked documentation - i.e. an autoloaded data type alias like:

type MyModule::MyType = SomeOtherType

For those it would be great if an adjacent comment is taken as documentation of the aliased type.

Note that for some such declarations - it is not as much an alias as a type definition - for example:

type MyModule::MyType = Object[{ attributes => { name => String, birthdate => Timestamp}}]

There are also local type aliases in 4.x ruby functions. More complex functions use those to define aliases that are only in effect for a single function. Here is an example from the lookup() function:

  local_types do
    type 'NameType         = Variant[String, Array[String]]'
    type 'ValueType        = Type'
    type 'DefaultValueType = Any'
    type 'MergeType        = Variant[String[1], Hash[String, Scalar]]'
    type 'BlockType        = Callable[NameType]'
    type "OptionsWithName  = Struct[{\
      name                => NameType,\
      value_type          => Optional[ValueType],\
      default_value       => Optional[DefaultValueType],\
      override            => Optional[Hash[String,Any]],\
      default_values_hash => Optional[Hash[String,Any]],\
      merge               => Optional[MergeType]\
    }]"
    type "OptionsWithoutName = Struct[{\
      value_type          => Optional[ValueType],\
      default_value       => Optional[DefaultValueType],\
      override            => Optional[Hash[String,Any]],\
      default_values_hash => Optional[Hash[String,Any]],\
      merge               => Optional[MergeType]\
    }]"
 
  end
 
  dispatch :lookup_1 do
    scope_param
    param           'NameType',       :name
    optional_param  'ValueType',      :value_type
    optional_param  'MergeType',      :merge
  end

Documenting those are a bit more difficult - should the signature of the function show the aliases only - for example NameType (then you have to guess, or read the general description what a NameType is (requires author of function doc to write that), should it use an expanded NameType instead of just the alias (more difficult to read), or should it present the list of local aliases?

I think it would be great if we could show a list of aliases and then use those aliases in the multiple signatures.
It may be that 4.x local aliases is complex enough to warrant a separate ticket.

LeLutin (JIRA)

unread,
Jun 26, 2018, 2:56:03 PM6/26/18
to puppe...@googlegroups.com
LeLutin commented on Task PDOC-226

I'd like to back that request up. I just found out that the documentation pages generated by puppet strings shows the types for class and defined type params, but their definitions are nowhere to be found when you want to know what they stand for.

 

They could be listed as pages in the same section as ruby custom types which are already supported, or if this confuses things too much, they could also have their own section named "Type aliases". The very least would be to see what the type is an alias of (e.g. show the definition in the html page). then, like Henrik suggested, it would be great if all uses of this type in class and defined type params would link to the corresponding page

Chris Tessmer (Jira)

unread,
Aug 23, 2021, 7:38:03 PM8/23/21
to puppe...@googlegroups.com
Chris Tessmer commented on Task PDOC-226

Just passing through and noticed this ticket―documentation for Type aliases have been implemented for a while:

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages