custom_elements_manifest_parser 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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/CODE_OF_CONDUCT.md +84 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +66 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +244 -0
  8. data/Rakefile +23 -0
  9. data/bin/console +15 -0
  10. data/bin/setup +8 -0
  11. data/custom_elements_manifest_parser.gemspec +43 -0
  12. data/lib/custom_elements_manifest_parser/base_struct.rb +10 -0
  13. data/lib/custom_elements_manifest_parser/data_types/attribute.rb +57 -0
  14. data/lib/custom_elements_manifest_parser/data_types/css_custom_property.rb +47 -0
  15. data/lib/custom_elements_manifest_parser/data_types/css_part.rb +32 -0
  16. data/lib/custom_elements_manifest_parser/data_types/demo.rb +29 -0
  17. data/lib/custom_elements_manifest_parser/data_types/event.rb +40 -0
  18. data/lib/custom_elements_manifest_parser/data_types/function_return_type.rb +25 -0
  19. data/lib/custom_elements_manifest_parser/data_types/parameter.rb +33 -0
  20. data/lib/custom_elements_manifest_parser/data_types/reference.rb +36 -0
  21. data/lib/custom_elements_manifest_parser/data_types/resolve_initializer.rb +16 -0
  22. data/lib/custom_elements_manifest_parser/data_types/slot.rb +31 -0
  23. data/lib/custom_elements_manifest_parser/data_types/source_reference.rb +17 -0
  24. data/lib/custom_elements_manifest_parser/data_types/type.rb +34 -0
  25. data/lib/custom_elements_manifest_parser/data_types/type_reference.rb +22 -0
  26. data/lib/custom_elements_manifest_parser/nodes/class_declaration.rb +39 -0
  27. data/lib/custom_elements_manifest_parser/nodes/class_field.rb +50 -0
  28. data/lib/custom_elements_manifest_parser/nodes/class_method.rb +55 -0
  29. data/lib/custom_elements_manifest_parser/nodes/custom_element_export.rb +52 -0
  30. data/lib/custom_elements_manifest_parser/nodes/custom_element_field.rb +23 -0
  31. data/lib/custom_elements_manifest_parser/nodes/function_declaration.rb +39 -0
  32. data/lib/custom_elements_manifest_parser/nodes/javascript_export.rb +59 -0
  33. data/lib/custom_elements_manifest_parser/nodes/javascript_module.rb +58 -0
  34. data/lib/custom_elements_manifest_parser/nodes/manifest.rb +36 -0
  35. data/lib/custom_elements_manifest_parser/nodes/mixin_declaration.rb +93 -0
  36. data/lib/custom_elements_manifest_parser/nodes/variable_declaration.rb +41 -0
  37. data/lib/custom_elements_manifest_parser/parser.rb +111 -0
  38. data/lib/custom_elements_manifest_parser/structs/class_like_struct.rb +92 -0
  39. data/lib/custom_elements_manifest_parser/structs/custom_element_like_struct.rb +64 -0
  40. data/lib/custom_elements_manifest_parser/structs/declarable_node_struct.rb +19 -0
  41. data/lib/custom_elements_manifest_parser/structs/function_like_struct.rb +40 -0
  42. data/lib/custom_elements_manifest_parser/structs/property_like_struct.rb +47 -0
  43. data/lib/custom_elements_manifest_parser/types.rb +13 -0
  44. data/lib/custom_elements_manifest_parser/version.rb +5 -0
  45. data/lib/custom_elements_manifest_parser.rb +12 -0
  46. data/sig/custom_elements_manifest_parser.rbs +4 -0
  47. metadata +133 -0
@@ -0,0 +1,32 @@
1
+
2
+ require_relative "../base_struct.rb"
3
+ require_relative "../types.rb"
4
+
5
+ module CustomElementsManifestParser
6
+ module DataTypes
7
+ # The name + description of a CSS Part
8
+ class CssPart < BaseStruct
9
+ # @!attribute name
10
+ # @return [String] - Name of the CSS part
11
+ attribute :name, Types::Strict::String
12
+
13
+ # @!attribute summary
14
+ # @return [nil, String] - A markdown summary suitable for display in a listing.
15
+ attribute :summary, Types::Strict::String.optional.meta(required: false)
16
+
17
+ # @!attribute description
18
+ # @return [nil, String] - A markdown description.
19
+ attribute :description, Types::Strict::String.optional.meta(required: false)
20
+
21
+ # @!attribute deprecated
22
+ # @return [nil, Boolean, String] -
23
+ # Whether the CSS shadow part is deprecated.
24
+ # If the value is a string, it's the reason for the deprecation.
25
+ attribute :deprecated, Types::Strict::String.optional | Types::Strict::Bool.optional.meta(required: false)
26
+
27
+ def visit(parser:)
28
+ self
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # Links to a demo of the element
7
+ class Demo < BaseStruct
8
+ # @!attribute url
9
+ # @return [String] -
10
+ # Relative URL of the demo if it's published with the package. Absolute URL
11
+ # if it's hosted.
12
+ attribute :url, Types::Strict::String
13
+
14
+ # @!attribute description
15
+ # @return [String, nil] - A markdown description of the demo.
16
+ attribute :description, Types::Strict::String.optional.meta(required: false)
17
+
18
+ # @!attribute source
19
+ # @return [SourceReference, nil]
20
+ attribute :source, Types::Nominal::Any.optional.meta(required: false)
21
+
22
+ def visit(parser:)
23
+ hash = {}
24
+ hash[:source] = parser.data_types[:source].new(source).visit(parser: parser) if source
25
+ new(hash)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,40 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # Documents events on a custom element
7
+ class Event < BaseStruct
8
+ # @!attribute name
9
+ # @return [String] - Name of the event
10
+ attribute :name, Types::Strict::String
11
+
12
+ # @!attribute type
13
+ # @return [Type] - The type of the event object that's fired.
14
+ attribute :type, Types::Nominal::Any.optional.meta(required: false)
15
+
16
+ # @param summary [nil, String] - A markdown summary suitable for display in a listing.
17
+ attribute :summary, Types::Strict::String.optional.meta(required: false)
18
+
19
+ # @!attribute description
20
+ # @return [nil, String] - A markdown description.
21
+ attribute :description, Types::Strict::String.optional.meta(required: false)
22
+
23
+ # @!attribute inheritedFrom
24
+ # @return [nil, Reference]
25
+ attribute :inheritedFrom, Types::Nominal::Any.optional.meta(required: false)
26
+
27
+ # @!attribute deprecated
28
+ # @return [nil, Boolean, String]
29
+ # Whether the event is deprecated.
30
+ # If the value is a string, it's the reason for the deprecation.
31
+ attribute :deprecated, Types::Strict::String.optional | Types::Strict::Bool.optional.meta(required: false)
32
+
33
+ def visit(parser:)
34
+ hash = {}
35
+ hash[:type] = parser.data_types[:type].new(type).visit(parser: parser) if type
36
+ new(hash)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # Abstract class for documenting a FunctionReturnType
7
+ class FunctionReturnType < BaseStruct
8
+ # @!attribute type
9
+ # @return [Type, nil] - The type of the function return
10
+ attribute :type, Types::Strict::String | Types::Strict::Hash.optional.meta(required: false)
11
+
12
+ # @!attribute summary
13
+ # @return [String, nil] Summary of the function return
14
+ attribute :summary, Types::Strict::String.optional.meta(required: false)
15
+
16
+ # @!attribute description
17
+ # @return [String, nil] Description of the function return
18
+ attribute :description, Types::Strict::String.optional.meta(required: false)
19
+
20
+ def visit(parser:)
21
+ self
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ require_relative "../structs/property_like_struct.rb"
2
+
3
+ require_relative "../base_struct.rb"
4
+ require_relative "../types.rb"
5
+
6
+ module CustomElementsManifestParser
7
+ module DataTypes
8
+ # Documents a parameter on a function
9
+ class Parameter < BaseStruct
10
+ # @!parse include Structs::PropertyLikeStruct
11
+ attributes_from Structs::PropertyLikeStruct
12
+
13
+ # @!attribute optional
14
+ # @return [Boolean, nil] - Whether the parameter is optional. Undefined implies non-optional.
15
+ attribute :optional, Types::Strict::Bool.optional.meta(required: false)
16
+
17
+ # @!attribute rest
18
+ # @return [Boolean, nil] -
19
+ # Whether the parameter is a rest parameter. Only the last parameter may be a rest parameter.
20
+ # Undefined implies single parameter.
21
+ attribute :rest, Types::Strict::Bool.optional.meta(required: false)
22
+
23
+ def visit(parser:)
24
+ hash = {}
25
+
26
+ hash = hash.merge(
27
+ Structs::PropertyLikeStruct.build_hash(parser: parser, struct: self)
28
+ )
29
+ new(hash)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # A reference to an export of a module.
7
+ #
8
+ # All references are required to be publically accessible, so the canonical
9
+ # representation of a reference is the export it's available from.
10
+ #
11
+ # `package` should generally refer to an npm package name. If `package` is
12
+ # undefined then the reference is local to this package. If `module` is
13
+ # undefined the reference is local to the containing module.
14
+ #
15
+ # References to global symbols like `Array`, `HTMLElement`, or `Event` should
16
+ # use a `package` name of `"global:"`.
17
+ #
18
+ class Reference < BaseStruct
19
+ # @!attribute name
20
+ # @return [String] - Name of the reference
21
+ attribute :name, Types::Strict::String
22
+
23
+ # @!attribute package
24
+ # @return [String, nil] - Name of the package
25
+ attribute :package, Types::Strict::String.optional.meta(required: false)
26
+
27
+ # @!attribute module
28
+ # @return [String, nil]
29
+ attribute :module, Types::Strict::String.optional.meta(required: false)
30
+
31
+ def visit(parser:)
32
+ self
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # This shouldn't be here, but was thrown up by CEM.
7
+ class ResolveInitializer < BaseStruct
8
+ # @return [String, nil]
9
+ attribute :module, Types::Strict::String.optional.meta(required: false)
10
+
11
+ def visit(parser:)
12
+ self
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # Documents slots for a custom element
7
+ class Slot < BaseStruct
8
+ # @!attribute name
9
+ # @return [String] - The slot name, or the empty string for an unnamed slot.
10
+ attribute :name, Types::Strict::String
11
+
12
+ # @!attribute summary
13
+ # @return [String, nil] - A markdown summary suitable for display in a listing.
14
+ attribute :summary, Types::Strict::String.optional.meta(required: false)
15
+
16
+ # @!attribute description
17
+ # @return [String, nil] - A markdown description.
18
+ attribute :description, Types::Strict::String.optional.meta(required: false)
19
+
20
+ # @!attribute deprecated
21
+ # @return [nil, Boolean, String] -
22
+ # Whether the slot is deprecated.
23
+ # If the value is a string, it's the reason for the deprecation.
24
+ attribute :deprecated, Types::Strict::String.optional | Types::Strict::Bool.optional.meta(required: false)
25
+
26
+ def visit(parser:)
27
+ self
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "../base_struct.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # Gets passed an href to an absolute URL to the source.
7
+ class SourceReference < BaseStruct
8
+ # @!attribute href
9
+ # @return [String] - An absolute URL to the source (ie. a GitHub URL).
10
+ attribute :href, Types::Strict::String
11
+
12
+ def visit(parser:)
13
+ self
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "../types.rb"
2
+ require_relative "../base_struct.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # Documents a JSDoc, Closure, or TypeScript type.
7
+ class Type < BaseStruct
8
+ # @param text [String] -
9
+ # The full string representation of the type, in whatever type syntax is
10
+ # used, such as JSDoc, Closure, or TypeScript.
11
+ attribute :text, Types::Strict::String
12
+
13
+ # @!attribute references
14
+ # @return [nil, Array<TypeReference> -
15
+ # An array of references to the types in the type string.
16
+ # These references have optional indices into the type string so that tools
17
+ # can understand the references in the type string independently of the type
18
+ # system and syntax. For example, a documentation viewer could display the
19
+ # type `Array<FooElement | BarElement>` with cross-references to `FooElement`
20
+ # and `BarElement` without understanding arrays, generics, or union types.
21
+ attribute :references, Types::Strict::Array.optional.meta(required: false)
22
+
23
+ # @!attribute source
24
+ # @return [nil, SourceReference]
25
+ attribute :source, Types::Nominal::Any.optional.meta(required: false)
26
+
27
+ def visit(parser:)
28
+ hash = {}
29
+ hash[:references] = references.map { |reference| parser.data_types[:type_reference].new(reference).visit(parser: parser) } unless references.nil?
30
+ new(hash)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ require_relative "./reference.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module DataTypes
6
+ # A reference that is associated with a type string and optionally a range
7
+ # within the string.
8
+ #
9
+ # Start and end must both be present or not present. If they're present, they
10
+ # are indices into the associated type string. If they are missing, the entire
11
+ # type string is the symbol referenced and the name should match the type
12
+ # string.
13
+ class TypeReference < Reference
14
+ # @param start [Integer, nil]
15
+ attribute :start, Types::Strict::Integer.optional.meta(required: false)
16
+
17
+ # @!attribute end
18
+ # @return [Integer, nil]
19
+ attribute :end, Types::Strict::Integer.optional.meta(required: false)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ require_relative "../structs/declarable_node_struct.rb"
2
+ require_relative "../structs/custom_element_like_struct.rb"
3
+
4
+ require_relative "../base_struct.rb"
5
+ require_relative "../types.rb"
6
+
7
+ module CustomElementsManifestParser
8
+ module Nodes
9
+ # This is equivalent to CustomElementDeclaration.
10
+ class ClassDeclaration < BaseStruct
11
+ # @return ["class"]
12
+ def self.kind; 'class'; end
13
+
14
+
15
+ # @!parse include Structs::DeclarableNodeStruct
16
+ attributes_from Structs::DeclarableNodeStruct
17
+
18
+ # @!parse include Structs::CustomElementLikeStruct
19
+ attributes_from Structs::CustomElementLikeStruct
20
+
21
+ # @!attribute kind
22
+ # @return ["class"]
23
+ attribute :kind, Types.Value("class")
24
+
25
+ # @param parser [Parser] - Gets passed a parser
26
+ # @return [ClassDeclaration]
27
+ def visit(parser:)
28
+ hash = {}
29
+
30
+ hash = hash.merge(
31
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: self),
32
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: self)
33
+ )
34
+
35
+ new(hash)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ require_relative "../structs/property_like_struct.rb"
2
+ require_relative "../structs/declarable_node_struct.rb"
3
+
4
+ require_relative "../base_struct.rb"
5
+ require_relative "../types.rb"
6
+
7
+ module CustomElementsManifestParser
8
+ module Nodes
9
+ # Documents a class property. This does not get used directly. Instead, it gets extended by CustomElementField.
10
+ class ClassField < BaseStruct
11
+ # @return ["field"]
12
+ def self.kind; "field"; end
13
+
14
+ # @!attribute kind
15
+ # @return ['field']
16
+ attribute :kind, Types.Value("field")
17
+
18
+ # @!attribute privacy
19
+ # @return ["protected", "public", "private", nil]
20
+ attribute :static, Types.privacy.optional.meta(required: false)
21
+
22
+ # @!attribute inheritedFrom
23
+ # @return [Reference, nil]
24
+ attribute :inheritedFrom, Types::Nominal::Any.optional.meta(required: false)
25
+
26
+ # @!attribute source
27
+ # @return [SourceReference, nil]
28
+ attribute :source, Types::Nominal::Any.optional.meta(required: false)
29
+
30
+ # @!parse include Structs::DeclarableNodeStruct
31
+ attributes_from Structs::DeclarableNodeStruct
32
+
33
+ # @!parse include Structs::PropertyLikeStruct
34
+ attributes_from Structs::PropertyLikeStruct
35
+
36
+ def visit(parser:)
37
+ hash = {}
38
+ hash[:inheritedFrom] = parser.data_types[:inherited_from].new(inheritedFrom).visit(parser: parser) unless inheritedFrom.nil?
39
+ hash[:source] = parser.data_types[:source].new(source).visit(parser: parser) unless source.nil?
40
+
41
+ hash = hash.merge(
42
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: struct),
43
+ Structs::PropertyLikeStruct.build_hash(parser: parser, struct: struct)
44
+ )
45
+
46
+ new(hash)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,55 @@
1
+ require_relative "../structs/declarable_node_struct.rb"
2
+ require_relative "../structs/function_like_struct.rb"
3
+
4
+ require_relative "../base_struct.rb"
5
+ require_relative "../types.rb"
6
+
7
+ module CustomElementsManifestParser
8
+ module Nodes
9
+ # Documents a method attached to a class
10
+ class ClassMethod < BaseStruct
11
+
12
+ # @!parse Structs::FunctionLikeStruct
13
+ attributes_from Structs::FunctionLikeStruct
14
+
15
+ # @!parse Structs::DeclarableNodeStruct
16
+ attributes_from Structs::DeclarableNodeStruct
17
+
18
+ # @return ["method"]
19
+ def self.kind; 'method'; end
20
+
21
+ # @!attribute kind
22
+ # @return ["method"]
23
+ attribute :kind, Types.Value("method")
24
+
25
+ # @!attribute static
26
+ # @return [Boolean, nil]
27
+ attribute :static, Types::Strict::Bool.optional.meta(required: false)
28
+
29
+ # @!attribute privacy
30
+ # @return [Types.privacy, nil]
31
+ attribute :privacy, Types.privacy.optional.meta(required: false)
32
+
33
+ # @!attribute inheritedFrom
34
+ # @return [Reference, nil]
35
+ attribute :inheritedFrom, Types::Nominal::Any.optional.meta(required: false)
36
+
37
+ # @!attribute source
38
+ # @return [SourceReference, nil]
39
+ attribute :source, Types::Nominal::Any.optional.meta(required: false)
40
+
41
+ def visit(parser:)
42
+ hash = {}
43
+ hash[:inheritedFrom] = parser.data_types[:inherited_from].new(inheritedFrom).visit(parser: parser) unless inheritedFrom.nil?
44
+ hash[:source] = parser.data_types[:source].new(source).visit(parser: parser) unless source.nil?
45
+
46
+ hash = hash.merge(
47
+ Structs::FunctionLikeStruct.build_hash(parser: parser, struct: struct),
48
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: struct)
49
+ )
50
+
51
+ new(hash)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,52 @@
1
+ require_relative "../structs/declarable_node_struct.rb"
2
+
3
+ require_relative "../base_struct.rb"
4
+ require_relative "../types.rb"
5
+
6
+ module CustomElementsManifestParser
7
+ module Nodes
8
+ #
9
+ # A global custom element defintion, ie the result of a
10
+ # `customElements.define()` call.
11
+ #
12
+ # This is represented as an export because a definition makes the element
13
+ # available outside of the module it's defined it.
14
+ #
15
+ class CustomElementExport < BaseStruct
16
+ # @return ["custom-element-definition"]
17
+ def self.kind; "custom-element-definition"; end
18
+
19
+ # @!attribute kind
20
+ # @return ["custom-element-definition"]
21
+ attribute :kind, Types.Value("custom-element-definition")
22
+
23
+ # @!parse Structs::DeclarableNodeStruct
24
+ attributes_from Structs::DeclarableNodeStruct
25
+
26
+ # @!attribute name
27
+ # @return [String] - The tag name of the custom element
28
+ attribute :name, Types::Strict::String
29
+
30
+ # @!attribute declaration
31
+ # @return [Reference]
32
+ # A reference to the class or other declaration that implements the
33
+ # custom element.
34
+ attribute :declaration, Types::Nominal::Any
35
+
36
+ # @param deprecated [boolean, string, nil]
37
+ # Whether the custom-element export is deprecated.
38
+ # For example, a future version will not register the custom element in this file.
39
+ # If the value is a string, it's the reason for the deprecation.
40
+ attribute :deprecated, Types::Strict::Bool.optional | Types::Strict::String.optional.meta(required: false)
41
+
42
+ def visit(parser:)
43
+ hash = {}
44
+ hash[:declaration] = parser.data_types[:declaration].new(declaration).visit(parser: parser)
45
+ hash = hash.merge(
46
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: self)
47
+ )
48
+ new(hash)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "./class_field.rb"
2
+ require_relative "../types.rb"
3
+
4
+ module CustomElementsManifestParser
5
+ module Nodes
6
+ # Additional metadata for fields on custom elements.
7
+ # This is equivalent to "ClassField"
8
+ class CustomElementField < ClassField
9
+ # @!attribute attribute
10
+ # @return [String, nil] -
11
+ # The corresponding attribute name if there is one.
12
+ # If this property is defined, the attribute must be listed in the classes'
13
+ # `attributes` array.
14
+ attribute :attribute, Types::Strict::String.optional.meta(required: false)
15
+
16
+ # @!attribute reflects
17
+ # @return [Boolean, nil] -
18
+ # If the property reflects to an attribute.
19
+ # If this is true, the `attribute` property must be defined.
20
+ attribute :reflects, Types::Strict::Bool.optional.meta(required: false)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ require_relative "../structs/declarable_node_struct.rb"
2
+ require_relative "../structs/function_like_struct.rb"
3
+
4
+ require_relative "../base_struct.rb"
5
+
6
+ module CustomElementsManifestParser
7
+ module Nodes
8
+ # Documents a function
9
+ class FunctionDeclaration < BaseStruct
10
+ # @!parse include Structs::DeclarableNodeStruct
11
+ attributes_from Structs::DeclarableNodeStruct
12
+
13
+ # @!parse include Structs::FunctionLikeStruct
14
+ attributes_from Structs::FunctionLikeStruct
15
+
16
+ # @return ["function"]
17
+ def self.kind; "function"; end
18
+
19
+ # @!attribute kind
20
+ # @return ["function"]
21
+ attribute :kind, Types.Value("function")
22
+
23
+ # @!attribute source
24
+ # @return [SourceReference, nil]
25
+ attribute :source, Types::Strict::String.optional.meta(required: false)
26
+
27
+ def visit(parser:)
28
+ hash = {}
29
+ hash[:source] = parser.data_types[:source].new(source).visit(parser: parser) unless source.nil?
30
+
31
+ hash = hash.merge(
32
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: self),
33
+ Structs::FunctionLikeStruct.build_hash(parser: parser, struct: self)
34
+ )
35
+ new(hash)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,59 @@
1
+ require_relative "../structs/declarable_node_struct.rb"
2
+
3
+ require_relative "../base_struct.rb"
4
+ require_relative "../types.rb"
5
+
6
+ module CustomElementsManifestParser
7
+ module Nodes
8
+ # A JavaScript export!
9
+ class JavaScriptExport < BaseStruct
10
+ # @!parse include Structs::DeclarableNodeStruct
11
+ attributes_from Structs::DeclarableNodeStruct
12
+
13
+ # @!attribute kind
14
+ # @return ["js"]
15
+ attribute :kind, Types.Value("js")
16
+
17
+ # @return ["js"]
18
+ def self.kind; "js"; end
19
+
20
+ # @!attribute name
21
+ # @return [String] -
22
+ # The name of the exported symbol.
23
+ #
24
+ # JavaScript has a number of ways to export objects which determine the
25
+ # correct name to use.
26
+ #
27
+ # - Default exports must use the name "default".
28
+ # - Named exports use the name that is exported. If the export is renamed
29
+ # with the "as" clause, use the exported name.
30
+ # - Aggregating exports (`* from`) should use the name `*`
31
+ attribute :name, Types::Strict::String
32
+
33
+ # @!attribute declaration
34
+ # @return [Reference] -
35
+ # A reference to the exported declaration.
36
+ #
37
+ # In the case of aggregating exports, the reference's `module` field must be
38
+ # defined and the `name` field must be `"*"`.
39
+ attribute :declaration, Types::Nominal::Any.optional.meta(required: false)
40
+
41
+ # @!attribute deprecated
42
+ # @return [nil, boolean, string] -
43
+ # Whether the export is deprecated. For example, the name of the export was changed.
44
+ # If the value is a string, it's the reason for the deprecation.
45
+ attribute :deprecated, Types::Strict::String.optional | Types::Strict::Bool.optional.meta(required: false)
46
+
47
+ def visit(parser:)
48
+ hash = {}
49
+ hash[:declaration] = parser.data_types[:declaration].new(declaration).visit(parser: parser) if declaration
50
+
51
+ hash = hash.merge(
52
+ Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: self)
53
+ )
54
+
55
+ new(hash)
56
+ end
57
+ end
58
+ end
59
+ end