decode 0.19.0 → 0.20.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2f65c84b60030a9ea35d172094ef5e5dade644f5b3c5182272e561e4888ca39
4
- data.tar.gz: c33ef119078aa7f63162dae206f15db5ae0ba8a04487f8d56f57142205cb71fa
3
+ metadata.gz: cad37ec3456d7b6edc9bcfa36c28b4f05c83ba978fed9a1989d0c0daba8b12c9
4
+ data.tar.gz: 559c5b61c73b58f420591361502c76f81e168c74e1c425dfcb2a89bf4766c9d9
5
5
  SHA512:
6
- metadata.gz: 509ee339eaf27970f49e9aad9ca1771878e5d4999ea8f37703a62bc7c73c7eff6a1d1ff9afd5a699068763b4251d0037f454bc99fa12f3df19a59da6d867979f
7
- data.tar.gz: fdea851ce3257fe97362935d1b08f6cf704a69478444c7dcef9367ac486724dd5a66595b6dddd1a44b7df98de09c7b18a7b719efa8d04ebd0b1be126cecf349b
6
+ metadata.gz: b1e7915cb517d46bc9372734244045bffe3bd32acaae6bd7cb3f4dd7eaef9240faf74b63bff4249a7d7fc7a7ab2623aff4178d41eb0a4875f735fcd724ff6fd2
7
+ data.tar.gz: a79d14e85375ecf5a7aa3a961ee42033bb3381b9f057472a7126b2dbde8be2cf2fd3d2eab0bd55a371e03f3085f2ed6bf3525c0b047284dd996a6b68c8756a20
checksums.yaml.gz.sig CHANGED
Binary file
data/bake/decode/index.rb CHANGED
@@ -29,3 +29,49 @@ def coverage(root)
29
29
 
30
30
  $stderr.puts "#{documented}/#{total} definitions have documentation."
31
31
  end
32
+
33
+ # Process the given source root and report on symbols.
34
+ # @parameter root [String] The root path to index.
35
+ def symbols(root)
36
+ require 'build/files/glob'
37
+ require 'decode/index'
38
+
39
+ paths = Build::Files::Path.expand(root).glob("**/*")
40
+
41
+ index = Decode::Index.new
42
+ index.update(paths)
43
+
44
+ index.trie.traverse do |path, node, descend|
45
+ level = path.size
46
+ puts "#{" " * level}#{path.inspect} -> #{node.values.inspect}"
47
+
48
+ if path.any?
49
+ puts "#{" " * level}#{path.join("::")}"
50
+ end
51
+
52
+ descend.call
53
+ end
54
+ end
55
+
56
+ # Print documentation for all definitions.
57
+ # @parameter root [String] The root path to index.
58
+ def documentation(root)
59
+ require 'build/files/glob'
60
+ require 'decode/index'
61
+
62
+ paths = Build::Files::Path.expand(root).glob("**/*")
63
+
64
+ index = Decode::Index.new
65
+ index.update(paths)
66
+
67
+ index.definitions.each do |name, definition|
68
+ comments = definition.comments
69
+
70
+ if comments
71
+ puts "## `#{name}`"
72
+ puts
73
+ puts comments
74
+ puts
75
+ end
76
+ end
77
+ end
@@ -47,7 +47,7 @@ module Decode
47
47
  end
48
48
  end
49
49
 
50
- # Any lines of text associated wtih this node.
50
+ # Any lines of text associated with this node.
51
51
  # @returns [Array(String) | Nil] The lines of text.
52
52
  def text
53
53
  if text = self.extract_text
@@ -55,8 +55,7 @@ module Decode
55
55
  end
56
56
  end
57
57
 
58
- # Traverse the tags from this node using {each}.
59
- # Invoke `descend.call(child)` to recursively traverse the specified child.
58
+ # Traverse the tags from this node using {each}. Invoke `descend.call(child)` to recursively traverse the specified child.
60
59
  #
61
60
  # @yields {|node, descend| descend.call}
62
61
  # @parameter node [Node] The current node which is being traversed.
@@ -74,10 +74,6 @@ module Decode
74
74
  # Walk over the syntax tree and extract relevant definitions with their associated comments.
75
75
  def walk_definitions(node, comments, parent = nil, &block)
76
76
  case node.type
77
- when :begin
78
- node.children.each do |child|
79
- walk_definitions(child, comments, parent, &block)
80
- end
81
77
  when :module
82
78
  definition = Module.new(
83
79
  node, nested_name_for(node.children[0]),
@@ -126,10 +122,13 @@ module Decode
126
122
 
127
123
  yield definition
128
124
  when :defs
125
+ extracted_comments = extract_comments_for(node, comments)
126
+
129
127
  definition = Function.new(
130
128
  node, node.children[1],
131
- comments: extract_comments_for(node, comments),
132
- parent: parent, language: @language
129
+ comments: extracted_comments,
130
+ parent: scope_for(extracted_comments, parent, &block),
131
+ language: @language
133
132
  )
134
133
 
135
134
  yield definition
@@ -186,6 +185,12 @@ module Decode
186
185
  walk_definitions(children, comments, definition, &block)
187
186
  end
188
187
  end
188
+ else
189
+ node.children.each do |child|
190
+ if child.is_a?(::Parser::AST::Node)
191
+ walk_definitions(child, comments, parent, &block) if child
192
+ end
193
+ end
189
194
  end
190
195
  end
191
196
 
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2020-2022, by Samuel Williams.
5
5
 
6
6
  module Decode
7
- VERSION = "0.19.0"
7
+ VERSION = "0.20.1"
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2023-05-26 00:00:00.000000000 Z
40
+ date: 2023-12-04 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: parser
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.4.7
128
+ rubygems_version: 3.4.22
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Code analysis for documentation generation.
metadata.gz.sig CHANGED
Binary file