yard-rustdoc 0.3.2 → 0.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4967b9c11e8b1ae8ee17256f03033e05312d501c80c0d7b064b406be63b5855d
4
- data.tar.gz: 43b2bd77f9fc7c99ec64ae6d499c55fbf9882cbe65a9d550b08cf03ea2c7bf55
3
+ metadata.gz: 2865669c4e16cefc604ce146b03c11130e44986ef1a6360cf6ab56dd38c98743
4
+ data.tar.gz: f79735602e4918682e65414fba5385481bac96c458a3b457d2c19ce9d6944baf
5
5
  SHA512:
6
- metadata.gz: 0433a034cdf09fe3187b4d206bc857353ee79e56177908157c9c894b5149dc9433f1676ab06dbd7b524fb7a803c4ec5e4072a9f4846e7c995600382f29253fc8
7
- data.tar.gz: 258f273a75c1ed52c12a8718641e6ae459acf0d45edba16826d7903d39072e55f4b23bf6fa27fd9f6920a19c9728a1d4f7383c013e7571b45a95d3ff59ac42b6
6
+ metadata.gz: f81d966d9cf1282bda8958b23be4a9ffa9d99011ac9d0935f1128cdcfb2921bc558a7d4b047703de8b8a179519c63a40c12710cde93938fc5386a5ae3ec2131c
7
+ data.tar.gz: f20846eba5aed1f53aa05818a5ad573b2cbd1088b1c2575038cd6f5ff01d74bcd034e2c7178f9e5c702b3ed1250772b65412b9438c9179201168025f9353bdf2
data/README.md CHANGED
@@ -58,7 +58,7 @@ The `@rename` tag renames the class to `Foo::Baz`.
58
58
 
59
59
  ```rust
60
60
  /// @yard
61
- /// @remame Foo::Baz
61
+ /// @rename Foo::Baz
62
62
  pub struct InnerName { }
63
63
  ```
64
64
 
@@ -68,7 +68,7 @@ Defines `Foo::Bar.new` -- class method because the first argument isn't `self`.
68
68
  impl Bar {
69
69
  /// @yard
70
70
  /// @return [Foo::Bar]
71
- fn build() -> Self {}
71
+ fn new() -> Self {}
72
72
  }
73
73
  ```
74
74
 
@@ -109,7 +109,7 @@ impl Bar {
109
109
 
110
110
  #### Tips
111
111
 
112
- YARD's syntax differs from what Rustdoc expects. Linters you man want to disable:
112
+ YARD's syntax differs from what Rustdoc expects. Linters you might want to disable:
113
113
 
114
114
  ```rust
115
115
  #![allow(rustdoc::broken_intra_doc_links)]
@@ -30,13 +30,21 @@ module YARD::Parser::Rustdoc
30
30
 
31
31
  @rustdoc_json.each do |id, entry|
32
32
  next unless relevant_entry?(entry)
33
- next unless TOP_LEVEL_KINDS.include?(entry["kind"])
34
33
 
35
- methods = entry
36
- .dig("inner", "impls")
37
- .flat_map { |impl_id| @rustdoc_json.dig(impl_id, "inner", "items") }
34
+ # "inner" is a Rust enum serialized with serde, resulting in a
35
+ # { "variant": { ...variant fields... } } structure.
36
+ # See https://github.com/rust-lang/rust/blob/f79a912d9edc3ad4db910c0e93672ed5c65133fa/src/rustdoc-json-types/lib.rs#L104
37
+ kind, inner = entry["inner"].first
38
+
39
+ next unless TOP_LEVEL_KINDS.include?(kind)
40
+
41
+ methods = inner
42
+ .fetch("impls")
43
+ .flat_map do |impl_id|
44
+ @rustdoc_json.dig(impl_id.to_s, "inner", "impl", "items")
45
+ end
38
46
  .filter_map do |method_id|
39
- method_entry = @rustdoc_json.fetch(method_id)
47
+ method_entry = @rustdoc_json.fetch(method_id.to_s)
40
48
  next unless relevant_entry?(method_entry)
41
49
 
42
50
  Statements::Method.new(method_entry)
@@ -45,6 +53,9 @@ module YARD::Parser::Rustdoc
45
53
  @entries << Statements::Struct.new(entry, methods)
46
54
  end
47
55
 
56
+ # Ensure Foo comes before Foo::Bar
57
+ @entries.sort_by!(&:name)
58
+
48
59
  self
49
60
  end
50
61
 
@@ -101,9 +101,20 @@ module YARD::Parser::Rustdoc
101
101
  @name || @rustdoc.fetch("name")
102
102
  end
103
103
 
104
+ # Infers the scope (instance vs class) based on the usage of "self" or
105
+ # "rb_self" as an arg name.
104
106
  def scope
105
- first_arg = @rustdoc.dig("inner", "decl", "inputs", 0, 0)
106
- if first_arg == "self" || first_arg == "rb_self"
107
+ inputs =
108
+ # JSON rustdoc FORMAT_VERSION < 34
109
+ @rustdoc.dig("inner", "function", "decl", "inputs") ||
110
+ # >= 34
111
+ @rustdoc.dig("inner", "function", "sig", "inputs")
112
+
113
+ arg_names = inputs
114
+ .map(&:first)
115
+ .slice(0, 2) # Magnus may inject a Ruby handle as arg0, hence we check 2 args
116
+
117
+ if arg_names.include?("self") || arg_names.include?("rb_self")
107
118
  :instance
108
119
  else
109
120
  :class
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YARD
4
4
  module Rustdoc
5
- VERSION = "0.3.2"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-rustdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Bourassa
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-12-01 00:00:00.000000000 Z
10
+ date: 2025-02-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: yard
@@ -30,14 +29,14 @@ dependencies:
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '5.0'
32
+ version: '6.0'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '5.0'
39
+ version: '6.0'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: rake
43
42
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +79,6 @@ dependencies:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
81
  version: '1.9'
83
- description:
84
82
  email:
85
83
  - jbourassa@gmail.com
86
84
  executables: []
@@ -100,7 +98,6 @@ licenses:
100
98
  metadata:
101
99
  homepage_uri: https://github.com/oxidize-rb/yard-rustdoc
102
100
  source_code_uri: https://github.com/oxidize-rb/yard-rustdoc
103
- post_install_message:
104
101
  rdoc_options: []
105
102
  require_paths:
106
103
  - lib
@@ -115,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
112
  - !ruby/object:Gem::Version
116
113
  version: '0'
117
114
  requirements: []
118
- rubygems_version: 3.3.24
119
- signing_key:
115
+ rubygems_version: 3.6.2
120
116
  specification_version: 4
121
117
  summary: Generate YARD documentation for Magnus-based Rust gems.
122
118
  test_files: []