yard-rustdoc 0.2.0 → 0.3.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: b9e27bb76802a3dcf98f4c78e30ed98251aed81e4927e464f2da5989768d0328
4
- data.tar.gz: 8a96e1280b7bca47976e4d2b74da7a1be05f34428f6d6c1f65528079f2532e49
3
+ metadata.gz: 58b78b33712ec60e0a4489d201732d967599faf5dfc194cd370de1c2c4a556b2
4
+ data.tar.gz: bb346446018a4405f9778bac7d6c6d321e73d9b4b397e36d30f889574dfae9c0
5
5
  SHA512:
6
- metadata.gz: 765bf4cc6f745a9f4d91cbf6eaf17dbf5db45567979bf009d72c684ce6b0e67e6c22ffb2f0f2003b14ce75fef31dd7f4080f36af265d0aa45113d3d141af2689
7
- data.tar.gz: 89d3d49913d6ae12be8819472a7536a76b92074cf75828f84571d8125b45049b18ac41fe3cb8553c5e70851b183fdd2de6c083b0626fccfa304bc34f74ba5962
6
+ metadata.gz: 6ffe5bd2255f7ed7d6fa3e493760b2d7b347bf917398323b2a699b0197d3af123ecbc864161f3d6598ed2b3dc250ce2b3b64508f22782f66fa40f00f5fb44fe4
7
+ data.tar.gz: d0dd9782942934d8dbffbb195a149ddf346566f61189bb1fc59c40096270d3a5dab5a8ea12efb061c43ca6a57e119be45575758323826e69384b65cfeb59122e
@@ -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,7 +10,8 @@ module YARD::Parser::Rustdoc
10
10
  end
11
11
 
12
12
  def docstring
13
- @rustdoc.fetch("docs")
13
+ @docstring ||= rust_docstring
14
+ .gsub(/^\s*@yard\s*\n/m, "") # remove @yard line
14
15
  end
15
16
 
16
17
  def source
@@ -79,6 +80,18 @@ module YARD::Parser::Rustdoc
79
80
  # Fallback to the struct's name
80
81
  @rustdoc.fetch("name")
81
82
  end
83
+
84
+ def code_object_class
85
+ if rust_docstring.match?(/^@module\b/)
86
+ YARD::CodeObjects::ModuleObject
87
+ else
88
+ YARD::CodeObjects::ClassObject
89
+ end
90
+ end
91
+
92
+ def rust_docstring
93
+ @rustdoc.fetch("docs")
94
+ end
82
95
  end
83
96
 
84
97
  class Method < Base
@@ -2,6 +2,6 @@
2
2
 
3
3
  module YARD
4
4
  module Rustdoc
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.1"
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.2.0
4
+ version: 0.3.1
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-16 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