yard-rustdoc 0.1.0 → 0.3.0

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: 79bdb3aec8e1f714e0171aa730ac8f7ae76a2c03a833469e881c509965b2e570
4
- data.tar.gz: 3b9c82a3687ac3dd58f94932e63f1a71ef390314f7a1940dd2b1f2618aec8845
3
+ metadata.gz: 19da90b28963c2ad60120d5e2922e78420742b86877e25dc3c97ca65f593b4de
4
+ data.tar.gz: df6a069c8ccd528a89b6107def280d861ad17e6339d515fc67ab0ac7c397173b
5
5
  SHA512:
6
- metadata.gz: eff3df27844e46ad1ff348af7149e7e87758249f0478afbd88b68692ba84338a9b1a970091b14f703491b6cf78738ebb61b16dc3eae2bc8c49c450ea9f1a2d7d
7
- data.tar.gz: be52e56f4bb91b3047b57b8fd1518b9c094e74b0601fdc32349c3e425beac0a6914589997955a9fc37f2a0673c35336cf77dd77b269284578d53092d4f7d26a2
6
+ metadata.gz: 5452d4c276d7c373621020ae0d9055debdfa9c70c1e2137b1cdff156633a11755d550501e66f8bf16914306c05ac50080991a48f7ae842c7f6367b8456f47716
7
+ data.tar.gz: ac56ea8762ba940ed2b5e83f1da77013585b80fb9e59e448eaee7ebf043c9d6037f0a74509a1b8d417f3fd2949b6f94a80edc22a19b9e75bffe0fe324adb4638
data/README.md CHANGED
@@ -1,16 +1,15 @@
1
1
  # YARD::Rustdoc
2
2
 
3
3
  YARD plugin for documenting Magnus-based Rust gems. Supports writing class
4
- documentation on Struct and method documentation on Struct methods.
5
-
6
- **Note**: WIP, not released.
4
+ documentation on Struct and Enums, and method documentation on Struct and Enum
5
+ methods.
7
6
 
8
7
  ## Installation
9
8
 
10
9
  Add this line to your application's Gemfile:
11
10
 
12
11
  ```ruby
13
- gem 'yard-rustdoc'
12
+ gem "yard-rustdoc"
14
13
  ```
15
14
 
16
15
  Load the plugin through `--plugin rustdoc` (e.g. in your project's `.yardopts`).
@@ -73,12 +72,16 @@ impl Bar {
73
72
  }
74
73
  ```
75
74
 
76
- Defines `Foo::Bar#baz`:
75
+ Defines `Foo::Bar#baz` and `#qux` -- instance method because the method's first
76
+ argument is either `&self` or `rb_self`.
77
77
 
78
78
  ```rust
79
79
  impl Bar {
80
80
  /// @yard
81
81
  fn baz(&self) {}
82
+
83
+ /// @yard
84
+ fn qux(rb_self: Value) {}
82
85
  }
83
86
  ```
84
87
 
@@ -111,6 +114,7 @@ YARD's syntax differs from what Rustdoc expects. Linters you man want to disable
111
114
  ```rust
112
115
  #![allow(rustdoc::broken_intra_doc_links)]
113
116
  #![allow(rustdoc::invalid_html_tags)]
117
+ #![allow(rustdoc::bare_urls)]
114
118
  ```
115
119
 
116
120
  ## Development
@@ -2,6 +2,8 @@
2
2
 
3
3
  module YARD::Parser::Rustdoc
4
4
  class Parser < YARD::Parser::Base
5
+ TOP_LEVEL_KINDS = ["struct", "enum"].freeze
6
+
5
7
  # This default constructor does nothing. The subclass is responsible for
6
8
  # storing the source contents and filename if they are required.
7
9
  # @param [String] source the source contents
@@ -28,7 +30,7 @@ module YARD::Parser::Rustdoc
28
30
 
29
31
  @rustdoc_json.each do |id, entry|
30
32
  next unless relevant_entry?(entry)
31
- next unless entry["kind"] == "struct"
33
+ next unless TOP_LEVEL_KINDS.include?(entry["kind"])
32
34
 
33
35
  methods = entry
34
36
  .dig("inner", "impls")
@@ -10,7 +10,9 @@ module YARD::Parser::Rustdoc
10
10
  end
11
11
 
12
12
  def docstring
13
- @rustdoc.fetch("docs")
13
+ @docstring ||= @rustdoc
14
+ .fetch("docs")
15
+ .gsub(/^\s*@yard\s*\n/m, "") # remove @yard line
14
16
  end
15
17
 
16
18
  def source
@@ -90,7 +92,7 @@ module YARD::Parser::Rustdoc
90
92
 
91
93
  def scope
92
94
  first_arg = @rustdoc.dig("inner", "decl", "inputs", 0, 0)
93
- if first_arg == "self"
95
+ if first_arg == "self" || first_arg == "rb_self"
94
96
  :instance
95
97
  else
96
98
  :class
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YARD
4
4
  module Rustdoc
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
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.1.0
4
+ version: 0.3.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: 2022-10-25 00:00:00.000000000 Z
11
+ date: 2022-11-29 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.7
118
+ rubygems_version: 3.3.24
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Generate YARD documentation for Magnus-based Rust gems.