yard-rustdoc 0.3.0 → 0.3.2

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: 19da90b28963c2ad60120d5e2922e78420742b86877e25dc3c97ca65f593b4de
4
- data.tar.gz: df6a069c8ccd528a89b6107def280d861ad17e6339d515fc67ab0ac7c397173b
3
+ metadata.gz: 4967b9c11e8b1ae8ee17256f03033e05312d501c80c0d7b064b406be63b5855d
4
+ data.tar.gz: 43b2bd77f9fc7c99ec64ae6d499c55fbf9882cbe65a9d550b08cf03ea2c7bf55
5
5
  SHA512:
6
- metadata.gz: 5452d4c276d7c373621020ae0d9055debdfa9c70c1e2137b1cdff156633a11755d550501e66f8bf16914306c05ac50080991a48f7ae842c7f6367b8456f47716
7
- data.tar.gz: ac56ea8762ba940ed2b5e83f1da77013585b80fb9e59e448eaee7ebf043c9d6037f0a74509a1b8d417f3fd2949b6f94a80edc22a19b9e75bffe0fe324adb4638
6
+ metadata.gz: 0433a034cdf09fe3187b4d206bc857353ee79e56177908157c9c894b5149dc9433f1676ab06dbd7b524fb7a803c4ec5e4072a9f4846e7c995600382f29253fc8
7
+ data.tar.gz: 258f273a75c1ed52c12a8718641e6ae459acf0d45edba16826d7903d39072e55f4b23bf6fa27fd9f6920a19c9728a1d4f7383c013e7571b45a95d3ff59ac42b6
@@ -34,7 +34,7 @@ module YARD::Handlers
34
34
  statement_class(Statements::Struct)
35
35
 
36
36
  process do
37
- obj = YARD::CodeObjects::ClassObject.new(:root, statement.name)
37
+ obj = statement.code_object_class.new(:root, statement.name)
38
38
  register(obj)
39
39
 
40
40
  push_state(namespace: obj) do
@@ -10,8 +10,7 @@ module YARD::Parser::Rustdoc
10
10
  end
11
11
 
12
12
  def docstring
13
- @docstring ||= @rustdoc
14
- .fetch("docs")
13
+ @docstring ||= rust_docstring
15
14
  .gsub(/^\s*@yard\s*\n/m, "") # remove @yard line
16
15
  end
17
16
 
@@ -56,6 +55,10 @@ module YARD::Parser::Rustdoc
56
55
  def line_index_range
57
56
  (@rustdoc.dig("span", "begin", 0) - 1)..@rustdoc.dig("span", "end", 0)
58
57
  end
58
+
59
+ def rust_docstring
60
+ @rustdoc.fetch("docs")
61
+ end
59
62
  end
60
63
 
61
64
  class Struct < Base
@@ -81,6 +84,14 @@ module YARD::Parser::Rustdoc
81
84
  # Fallback to the struct's name
82
85
  @rustdoc.fetch("name")
83
86
  end
87
+
88
+ def code_object_class
89
+ if rust_docstring.match?(/^@module\b/)
90
+ YARD::CodeObjects::ModuleObject
91
+ else
92
+ YARD::CodeObjects::ClassObject
93
+ end
94
+ end
84
95
  end
85
96
 
86
97
  class Method < Base
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YARD
4
4
  module Rustdoc
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.2"
6
6
  end
7
7
  end
data/lib/yard-rustdoc.rb CHANGED
@@ -15,4 +15,5 @@ module YARD
15
15
  Tags::Library.define_tag("Tagging docblock for yard", :yard)
16
16
  Tags::Library.define_tag("Renaming class & methods", :rename)
17
17
  Tags::Library.define_tag("Specify a method name and args", :def)
18
+ Tags::Library.define_tag("Specify that a Struct should be a module (instead of class)", :module)
18
19
  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.3.0
4
+ version: 0.3.2
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-11-29 00:00:00.000000000 Z
11
+ date: 2022-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '5.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement