yard-rustdoc 0.3.2 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/yard-rustdoc/parser.rb +13 -4
- data/lib/yard-rustdoc/statements.rb +8 -2
- data/lib/yard-rustdoc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78e74a92126b3580032529eaa4f17361eb6d4dd885b1dcb42ce1ccae71afa130
|
4
|
+
data.tar.gz: c978d783880150a402baf41aca076ca0a736c988b32e6283ac953ca0b86c0377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50e53c9f30f82fd56bfa040176b127ac72cb5015463a5d738a01a73814fba8ba984862b3ac0b81968063654d0031237a390878073edd50a1978505df911f30b8
|
7
|
+
data.tar.gz: 53743f0a93ada894d5532d7d86d57cd88a6e68446f8c065582012cae96c02431f995c4146049c36e893b4912691ce9d5635bf89ab7d5c2d46ec2f8e469028e0b
|
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
|
-
/// @
|
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
|
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
|
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)]
|
data/lib/yard-rustdoc/parser.rb
CHANGED
@@ -30,11 +30,17 @@ 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
|
-
|
36
|
-
|
37
|
-
|
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 { |impl_id| @rustdoc_json.dig(impl_id, "inner", "impl", "items") }
|
38
44
|
.filter_map do |method_id|
|
39
45
|
method_entry = @rustdoc_json.fetch(method_id)
|
40
46
|
next unless relevant_entry?(method_entry)
|
@@ -45,6 +51,9 @@ module YARD::Parser::Rustdoc
|
|
45
51
|
@entries << Statements::Struct.new(entry, methods)
|
46
52
|
end
|
47
53
|
|
54
|
+
# Ensure Foo comes before Foo::Bar
|
55
|
+
@entries.sort! { |a, b| a.name <=> b.name }
|
56
|
+
|
48
57
|
self
|
49
58
|
end
|
50
59
|
|
@@ -101,9 +101,15 @@ 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
|
-
|
106
|
-
|
107
|
+
arg_names = @rustdoc
|
108
|
+
.dig("inner", "function", "decl", "inputs")
|
109
|
+
.map(&:first)
|
110
|
+
.slice(0, 2) # Magnus may inject a Ruby handle as arg0, hence we check 2 args
|
111
|
+
|
112
|
+
if arg_names.include?("self") || arg_names.include?("rb_self")
|
107
113
|
:instance
|
108
114
|
else
|
109
115
|
:class
|
data/lib/yard-rustdoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-rustdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Bourassa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.3
|
118
|
+
rubygems_version: 3.5.3
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Generate YARD documentation for Magnus-based Rust gems.
|