docscribe 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fcaceb217eab132e318a9ae95022d321006d530f4b7e19ebd9ee4107bc528ad
4
- data.tar.gz: bd0a32f653c96dac12f402ad9b64508fbb3d75b038074dc78153c9341f946705
3
+ metadata.gz: 6c6297143fe1919d600c8a423e05aa4fa8f6a092b85cc898b8b90307d0df176d
4
+ data.tar.gz: 735ad06a621ee1b3c872dfd58b7f99a8062b7b732f024c1a609f7d382a1a9577
5
5
  SHA512:
6
- metadata.gz: 28f776a28ccfe336ce3e608cba8335b2186f350336b5c97c3f79373b210adf850c64ec80416b8af97dbd33dc88edc8b8cd3bd087692775e1722da1f2e974e891
7
- data.tar.gz: 43771ce9ee8188b03b3d77aa3313227d2143a33e8fd4a08b67f441d6ea42ca338ee913e2bd46bfd1afb3fd87e5f1ebad08d9b0f282b0c91b22ab2d437b9aba68
6
+ metadata.gz: eccc8ca3af426075e79b5e62b86fa14e6205851542adb7013bc64103cbc8a48ceaae228cd18b2292e176bd5501192dac68efb41f998b349f791024240da365ab
7
+ data.tar.gz: d7eabbed3763335952d657fb68bd3aee67f62a06ebc4c94dc7c38852fae4fe1432eaaeba67ebc98fd8f21055b8d7990061058691df43f241b4bfda25ed0079d9
data/README.md CHANGED
@@ -4,16 +4,19 @@
4
4
  [![RubyGems Downloads](https://img.shields.io/gem/dt/docscribe.svg)](https://rubygems.org/gems/docscribe)
5
5
  [![CI](https://github.com/unurgunite/docscribe/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/unurgunite/docscribe/actions/workflows/ci.yml)
6
6
  [![License](https://img.shields.io/github/license/unurgunite/docscribe.svg)](https://github.com/unurgunite/docscribe/blob/master/LICENSE.txt)
7
- [![Ruby](https://img.shields.io/badge/ruby-%3E%3D%203.0-blue.svg)](#installation)
7
+ [![Ruby](https://img.shields.io/badge/ruby-%3E%3D%202.7-blue.svg)](#installation)
8
8
 
9
- Generate inline, YARD-style documentation comments for Ruby methods by analyzing your code's AST. Docscribe inserts doc
10
- headers before method definitions, infers parameter and return types (including rescue-aware returns), and respects Ruby
11
- visibility semantics — without using YARD to parse.
9
+ Generate inline, YARD-style documentation comments for Ruby methods by analyzing your code's AST.
12
10
 
13
- - No AST reprinting. Your original code, formatting, and constructs (like `class << self`, `heredocs`, `%i[]`) are preserved.
14
- - Inline-first. Comments are inserted surgically at the start of each `def`/`defs` line.
11
+ Docscribe inserts doc headers before method definitions, infers parameter and return types (including rescue-aware
12
+ returns), and respects Ruby visibility semantics without using YARD to parse.
13
+
14
+ - No AST reprinting. Your original code, formatting, and constructs (like `class << self`, `heredocs`, `%i[]`) are
15
+ preserved.
16
+ - Inline-first. Comments are inserted at the start of each `def`/`defs` line.
15
17
  - Heuristic type inference for params and return values, including conditional returns in rescue branches.
16
18
  - Optional rewrite mode for regenerating existing method docs.
19
+ - Ruby 3.4+ syntax supported using Prism translation (see "Parser backend" below).
17
20
 
18
21
  Why not YARD? We started with YARD's parser, but switched to an AST-based in-place rewriter for maximum preservation of
19
22
  source structure and exact control over Ruby semantics.
@@ -57,7 +60,7 @@ Or install globally:
57
60
  gem install docscribe
58
61
  ```
59
62
 
60
- Requires Ruby 3.0+.
63
+ Requires Ruby 2.7+.
61
64
 
62
65
  ## Quick start
63
66
 
@@ -184,6 +187,10 @@ Examples:
184
187
  ```shell
185
188
  docscribe --rewrite --write lib/**/*.rb
186
189
  ```
190
+ - Check a directory (Docscribe expands directories to `**/*.rb`):
191
+ ```bash
192
+ docscribe --check lib
193
+ ```
187
194
 
188
195
  ## Inline behavior
189
196
 
@@ -200,6 +207,36 @@ Examples:
200
207
  - This is useful to refresh docs across a codebase after improving inference or rules.
201
208
  - Use with caution (prefer a clean working tree and review diffs).
202
209
 
210
+ ### Output markers in CI
211
+
212
+ When using `--check`, Docscribe prints one character per file:
213
+
214
+ - `.` = file is up-to-date
215
+ - `F` = file would change (missing/stale docs)
216
+
217
+ When using `--write`:
218
+
219
+ - `.` = file already OK
220
+ - `C` = file was corrected and rewritten
221
+
222
+ Docscribe prints a summary at the end and exits non-zero in `--check` mode if any file would change.
223
+
224
+ ## Parser backend (Parser gem vs Prism)
225
+
226
+ Docscribe internally works with `parser`-gem-compatible AST nodes and `Parser::Source::*` objects (so it can use
227
+ `Parser::Source::TreeRewriter` without changing your formatting).
228
+
229
+ - On Ruby **<= 3.3**, Docscribe parses using the `parser` gem.
230
+ - On Ruby **>= 3.4**, Docscribe parses using **Prism** and translates the tree into the `parser` gem’s AST (so tooling
231
+ stays compatible).
232
+
233
+ You can force a backend with an environment variable:
234
+
235
+ ```bash
236
+ DOCSCRIBE_PARSER_BACKEND=parser bundle exec docscribe --check lib
237
+ DOCSCRIBE_PARSER_BACKEND=prism bundle exec docscribe --check lib
238
+ ```
239
+
203
240
  ## Type inference
204
241
 
205
242
  Heuristics (best-effort):
@@ -297,8 +334,8 @@ We match Ruby's behavior:
297
334
 
298
335
  - A bare `private`/`protected`/`public` in a class/module body affects instance methods only.
299
336
  - Inside `class << self`, a bare visibility keyword affects class methods only.
300
- - `def self.x` in a class body remains `public` unless `private_class_method` is used or it's inside `class << self` under
301
- `private`.
337
+ - `def self.x` in a class body remains `public` unless `private_class_method` is used, or it's inside `class << self`
338
+ under `private`.
302
339
 
303
340
  Inline tags:
304
341
 
@@ -425,7 +462,7 @@ Docscribe and YARD solve different parts of the documentation problem:
425
462
  - Does not merge into existing comments; in normal mode, a method with a comment directly above it is skipped. Use
426
463
  `--rewrite` to regenerate.
427
464
  - Type inference is heuristic. Complex flows and meta-programming will fall back to Object or best-effort types.
428
- - Only Ruby 3.0+ is officially supported.
465
+ - Ruby 2.7+ supported.
429
466
  - Inline rewrite is textual; ensure a clean working tree before using `--write` or `--rewrite`.
430
467
 
431
468
  ## Roadmap
data/exe/docscribe CHANGED
@@ -43,6 +43,22 @@ def rewrite(code, replace:)
43
43
  Docscribe::InlineRewriter.insert_comments(code, rewrite: replace)
44
44
  end
45
45
 
46
+ def expand_paths(args)
47
+ files = []
48
+
49
+ args.each do |path|
50
+ if File.directory?(path)
51
+ files.concat(Dir.glob(File.join(path, '**', '*.rb')))
52
+ elsif File.file?(path)
53
+ files << path
54
+ else
55
+ warn "Skipping missing path: #{path}"
56
+ end
57
+ end
58
+
59
+ files.uniq.sort
60
+ end
61
+
46
62
  if options[:stdin]
47
63
  code = $stdin.read
48
64
  puts rewrite(code, replace: options[:rewrite])
@@ -54,24 +70,60 @@ if ARGV.empty?
54
70
  exit 1
55
71
  end
56
72
 
73
+ $stdout.sync = true
74
+
75
+ paths = expand_paths(ARGV)
76
+ if paths.empty?
77
+ warn 'No files found. Pass files or directories (e.g. `docscribe --check lib`).'
78
+ exit 1
79
+ end
80
+
57
81
  changed = false
82
+ checked_ok = 0
83
+ checked_fail = 0
84
+ corrected = 0
85
+ fail_paths = []
58
86
 
59
- ARGV.each do |path|
87
+ paths.each do |path|
60
88
  src = File.read(path)
61
89
  out = transform(src, replace: options[:rewrite], config: conf)
90
+
62
91
  if options[:check]
63
- if out != src
64
- warn "Would change: #{path}"
92
+ if out == src
93
+ print '.'
94
+ checked_ok += 1
95
+ else
96
+ print 'F'
97
+ checked_fail += 1
65
98
  changed = true
99
+ fail_paths << path
66
100
  end
101
+
67
102
  elsif options[:write]
68
- if out != src
103
+ if out == src
104
+ print '.'
105
+ else
69
106
  File.write(path, out)
70
- puts "Updated: #{path}"
107
+ print 'C'
108
+ corrected += 1
71
109
  end
110
+
72
111
  else
73
112
  puts out
74
113
  end
75
114
  end
76
115
 
116
+ if options[:check]
117
+ puts
118
+ if checked_fail.zero?
119
+ puts "Docscribe: OK (#{checked_ok} files checked)"
120
+ else
121
+ puts "Docscribe: FAILED (#{checked_fail} failing, #{checked_ok} ok)"
122
+ fail_paths.each { |p| warn "Missing docs: #{p}" }
123
+ end
124
+ elsif options[:write]
125
+ puts
126
+ puts "Docscribe: updated #{corrected} file(s)" if corrected.positive?
127
+ end
128
+
77
129
  exit(options[:check] && changed ? 1 : 0)
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'parser/current'
3
+ require 'racc/parser'
4
+ require 'ast'
5
+ require 'parser/ast/node'
6
+ require 'parser/source/buffer'
7
+ require 'parser/base'
8
+ require 'docscribe/parsing'
4
9
 
5
10
  module Docscribe
6
11
  module Infer
@@ -91,7 +96,7 @@ module Docscribe
91
96
 
92
97
  buffer = Parser::Source::Buffer.new('(param)')
93
98
  buffer.source = src
94
- Parser::CurrentRuby.new.parse(buffer)
99
+ Docscribe::Parsing.parse_buffer(buffer)
95
100
  rescue Parser::SyntaxError
96
101
  nil
97
102
  end
@@ -109,7 +114,7 @@ module Docscribe
109
114
 
110
115
  buffer = Parser::Source::Buffer.new('(method)')
111
116
  buffer.source = method_source
112
- root = Parser::CurrentRuby.new.parse(buffer)
117
+ root = Docscribe::Parsing.parse_buffer(buffer)
113
118
  return 'Object' unless root && %i[def defs].include?(root.type)
114
119
 
115
120
  body = root.children.last # method body node
@@ -1,7 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'parser/current'
3
+ require 'racc/parser'
4
+ require 'ast'
5
+ require 'parser/deprecation'
6
+ require 'parser/source/buffer'
7
+ require 'parser/source/range'
8
+ require 'parser/source/tree_rewriter'
9
+ require 'parser/ast/processor'
10
+
11
+ require 'docscribe/config'
4
12
  require 'docscribe/infer'
13
+ require 'docscribe/parsing'
5
14
 
6
15
  module Docscribe
7
16
  module InlineRewriter
@@ -16,8 +25,7 @@ module Docscribe
16
25
  def self.insert_comments(code, rewrite: false, config: nil)
17
26
  buffer = Parser::Source::Buffer.new('(inline)')
18
27
  buffer.source = code
19
- parser = Parser::CurrentRuby.new
20
- ast = parser.parse(buffer)
28
+ ast = Docscribe::Parsing.parse_buffer(buffer)
21
29
  return code unless ast
22
30
 
23
31
  config ||= Docscribe::Config.load
@@ -30,22 +38,22 @@ module Docscribe
30
38
  collector.insertions
31
39
  .sort_by { |ins| ins.node.loc.expression.begin_pos }
32
40
  .reverse_each do |ins|
33
- bol_range = line_start_range(buffer, ins.node)
34
-
35
- if rewrite
36
- # If there is a comment block immediately above, remove it (and its trailing blank lines)
37
- if (range = comment_block_removal_range(buffer, bol_range.begin_pos))
38
- rewriter.remove(range)
39
- end
40
- elsif already_has_doc_immediately_above?(buffer, bol_range.begin_pos)
41
- # Skip if a doc already exists immediately above
42
- next
43
- end
44
-
45
- doc = build_doc_for_node(buffer, ins, config)
46
- next unless doc && !doc.empty?
47
-
48
- rewriter.insert_before(bol_range, doc)
41
+ bol_range = line_start_range(buffer, ins.node)
42
+
43
+ if rewrite
44
+ # If there is a comment block immediately above, remove it (and its trailing blank lines)
45
+ if (range = comment_block_removal_range(buffer, bol_range.begin_pos))
46
+ rewriter.remove(range)
47
+ end
48
+ elsif already_has_doc_immediately_above?(buffer, bol_range.begin_pos)
49
+ # Skip if a doc already exists immediately above
50
+ next
51
+ end
52
+
53
+ doc = build_doc_for_node(buffer, ins, config)
54
+ next unless doc && !doc.empty?
55
+
56
+ rewriter.insert_before(bol_range, doc)
49
57
  end
50
58
 
51
59
  rewriter.process
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'parser/source/buffer'
4
+
5
+ module Docscribe
6
+ # Picks the correct Ruby parser backend and returns a `parser`-gem-compatible AST.
7
+ #
8
+ # Docscribe internally works with `parser` AST nodes (e.g. `Parser::AST::Node`) and
9
+ # `Parser::Source::*` location objects so it can use `Parser::Source::TreeRewriter`
10
+ # without reformatting the source.
11
+ #
12
+ # Ruby 3.4+ syntax can outpace the `parser` gem. To keep parsing working on Ruby 3.4+
13
+ # (and Ruby 4.0), Docscribe can parse with Prism and translate Prism’s AST into the
14
+ # `parser` AST via `Prism::Translation`.
15
+ #
16
+ # You can force a backend via the `DOCSCRIBE_PARSER_BACKEND` environment variable
17
+ # (`parser` or `prism`).
18
+ module Parsing
19
+ class << self
20
+ # Parse a Ruby source string into an AST.
21
+ #
22
+ # @param code [String] Ruby source code.
23
+ # @param file [String] A virtual filename used in locations (e.g. for errors and ranges).
24
+ # @param backend [Symbol] :auto (default), :parser, or :prism.
25
+ # @return [Parser::AST::Node, nil] Root node (or nil for empty/whitespace-only source).
26
+ def parse(code, file: '(docscribe)', backend: :auto)
27
+ buffer = Parser::Source::Buffer.new(file, source: code)
28
+ parse_buffer(buffer, backend: backend)
29
+ end
30
+
31
+ # Parse using an already-created {Parser::Source::Buffer}.
32
+ #
33
+ # This is important when callers later use {Parser::Source::TreeRewriter} with the
34
+ # same buffer instance (to keep ranges/offsets consistent).
35
+ #
36
+ # @param buffer [Parser::Source::Buffer] Source buffer (must have `.source` set).
37
+ # @param backend [Symbol] :auto (default), :parser, or :prism.
38
+ # @return [Parser::AST::Node, nil] Root node (or nil for empty/whitespace-only source).
39
+ def parse_buffer(buffer, backend: :auto)
40
+ parser = parser_for(backend: backend)
41
+ parser.parse(buffer)
42
+ end
43
+
44
+ # Parse a Ruby source string into AST + comments.
45
+ #
46
+ # @param code [String] Ruby source code.
47
+ # @param file [String] A virtual filename used in locations (e.g. for errors and ranges).
48
+ # @param backend [Symbol] :auto (default), :parser, or :prism.
49
+ # @return [Array<(Parser::AST::Node, Array<Parser::Source::Comment>)>]
50
+ # The AST root node (or nil) and an array of comments.
51
+ def parse_with_comments(code, file: '(docscribe)', backend: :auto)
52
+ buffer = Parser::Source::Buffer.new(file, source: code)
53
+ parse_with_comments_buffer(buffer, backend: backend)
54
+ end
55
+
56
+ # Parse AST + comments using an existing {Parser::Source::Buffer}.
57
+ #
58
+ # @param buffer [Parser::Source::Buffer] Source buffer (must have `.source` set).
59
+ # @param backend [Symbol] :auto (default), :parser, or :prism.
60
+ # @return [Array<(Parser::AST::Node, Array<Parser::Source::Comment>)>]
61
+ # The AST root node (or nil) and an array of comments.
62
+ def parse_with_comments_buffer(buffer, backend: :auto)
63
+ parser = parser_for(backend: backend)
64
+ parser.parse_with_comments(buffer)
65
+ end
66
+
67
+ # @api private
68
+ # Build the underlying parser instance for the selected backend.
69
+ #
70
+ # @param backend [Symbol] :auto, :parser, or :prism.
71
+ # @return [Object] An object responding to `parse` and `parse_with_comments`.
72
+ def parser_for(backend: :auto)
73
+ case self.backend(backend)
74
+ when :parser
75
+ require 'parser/current'
76
+ Parser::CurrentRuby.new
77
+ when :prism
78
+ require 'prism'
79
+ Prism::Translation::ParserCurrent.new
80
+ end
81
+ end
82
+
83
+ # Select the backend (:parser or :prism).
84
+ #
85
+ # @param backend [Symbol] :auto (default), :parser, or :prism.
86
+ # @return [Symbol] :parser or :prism.
87
+ # @raise [ArgumentError] if an unknown backend is requested.
88
+ def backend(backend = :auto)
89
+ env = ENV.fetch('DOCSCRIBE_PARSER_BACKEND', nil)
90
+ backend = env.to_sym if env && !env.empty?
91
+
92
+ case backend
93
+ when :auto
94
+ ruby_gte_34? ? :prism : :parser
95
+ when :parser, :prism
96
+ backend
97
+ else
98
+ raise ArgumentError, "Unknown backend: #{backend.inspect}"
99
+ end
100
+ end
101
+
102
+ # @api private
103
+ # @return [Boolean] true if running on Ruby 3.4+.
104
+ def ruby_gte_34?
105
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4')
106
+ end
107
+ end
108
+ end
109
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Docscribe
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
data/lib/docscribe.rb CHANGED
@@ -4,6 +4,7 @@ module Docscribe
4
4
  class Error < StandardError; end
5
5
  end
6
6
 
7
+ require 'docscribe/parsing'
7
8
  require_relative 'docscribe/version'
8
9
  require_relative 'docscribe/config'
9
10
  require_relative 'docscribe/infer'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docscribe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - unurgunite
@@ -15,14 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '3.0'
18
+ version: '3.3'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '3.0'
25
+ version: '3.3'
26
+ - !ruby/object:Gem::Dependency
27
+ name: prism
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.8'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.8'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: rake
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -65,6 +79,34 @@ dependencies:
65
79
  - - ">="
66
80
  - !ruby/object:Gem::Version
67
81
  version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rubocop-rake
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop-rspec
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
68
110
  - !ruby/object:Gem::Dependency
69
111
  name: rubocop-sorted_methods_by_call
70
112
  requirement: !ruby/object:Gem::Requirement
@@ -85,14 +127,14 @@ dependencies:
85
127
  requirements:
86
128
  - - ">="
87
129
  - !ruby/object:Gem::Version
88
- version: 0.9.34
130
+ version: 0.9.38
89
131
  type: :development
90
132
  prerelease: false
91
133
  version_requirements: !ruby/object:Gem::Requirement
92
134
  requirements:
93
135
  - - ">="
94
136
  - !ruby/object:Gem::Version
95
- version: 0.9.34
137
+ version: 0.9.38
96
138
  email:
97
139
  - senpaiguru1488@gmail.com
98
140
  executables:
@@ -100,23 +142,15 @@ executables:
100
142
  extensions: []
101
143
  extra_rdoc_files: []
102
144
  files:
103
- - ".rspec"
104
- - ".rubocop.yml"
105
- - ".rubocop_todo.yml"
106
- - CODE_OF_CONDUCT.md
107
- - Gemfile
108
- - Gemfile.lock
109
145
  - LICENSE.txt
110
146
  - README.md
111
- - Rakefile
112
147
  - exe/docscribe
113
148
  - lib/docscribe.rb
114
149
  - lib/docscribe/config.rb
115
150
  - lib/docscribe/infer.rb
116
151
  - lib/docscribe/inline_rewriter.rb
152
+ - lib/docscribe/parsing.rb
117
153
  - lib/docscribe/version.rb
118
- - rakelib/docs.rake
119
- - stingray_docs_internal.gemspec
120
154
  homepage: https://github.com/unurgunite/docscribe
121
155
  licenses: []
122
156
  metadata:
@@ -131,14 +165,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
165
  requirements:
132
166
  - - ">="
133
167
  - !ruby/object:Gem::Version
134
- version: '3.0'
168
+ version: '2.7'
135
169
  required_rubygems_version: !ruby/object:Gem::Requirement
136
170
  requirements:
137
171
  - - ">="
138
172
  - !ruby/object:Gem::Version
139
173
  version: '0'
140
174
  requirements: []
141
- rubygems_version: 3.7.2
175
+ rubygems_version: 4.0.2
142
176
  specification_version: 4
143
177
  summary: Autogenerate documentation for Ruby code with YARD syntax.
144
178
  test_files: []
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,11 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- plugins:
4
- - rubocop-sorted_methods_by_call
5
-
6
- AllCops:
7
- NewCops: enable
8
- TargetRubyVersion: 3.0
9
-
10
- Layout/LineLength:
11
- Max: 120
data/.rubocop_todo.yml DELETED
@@ -1,73 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2025-11-12 20:29:05 UTC using RuboCop version 1.81.7.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 5
10
- # Configuration parameters: EnforcedStyle, AllowedGems.
11
- # SupportedStyles: Gemfile, gems.rb, gemspec
12
- Gemspec/DevelopmentDependencies:
13
- Exclude:
14
- - 'stingray_docs_internal.gemspec'
15
-
16
- # Offense count: 10
17
- # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
18
- Metrics/AbcSize:
19
- Max: 62
20
-
21
- # Offense count: 7
22
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
23
- # AllowedMethods: refine
24
- Metrics/BlockLength:
25
- Max: 49
26
-
27
- # Offense count: 3
28
- # Configuration parameters: CountComments, CountAsOne.
29
- Metrics/ClassLength:
30
- Max: 187
31
-
32
- # Offense count: 11
33
- # Configuration parameters: AllowedMethods, AllowedPatterns.
34
- Metrics/CyclomaticComplexity:
35
- Max: 23
36
-
37
- # Offense count: 13
38
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
39
- Metrics/MethodLength:
40
- Max: 47
41
-
42
- # Offense count: 2
43
- # Configuration parameters: CountComments, CountAsOne.
44
- Metrics/ModuleLength:
45
- Max: 189
46
-
47
- # Offense count: 10
48
- # Configuration parameters: AllowedMethods, AllowedPatterns.
49
- Metrics/PerceivedComplexity:
50
- Max: 22
51
-
52
- # Offense count: 3
53
- # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
54
- # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
55
- Naming/MethodParameterName:
56
- Exclude:
57
- - 'lib/docscribe/infer.rb'
58
-
59
- # Offense count: 4
60
- # Configuration parameters: AllowedConstants.
61
- Style/Documentation:
62
- Exclude:
63
- - 'spec/**/*'
64
- - 'test/**/*'
65
- - 'lib/docscribe/config.rb'
66
- - 'lib/docscribe/infer.rb'
67
- - 'lib/docscribe/inline_rewriter.rb'
68
-
69
- # Offense count: 2
70
- # Configuration parameters: Max.
71
- Style/SafeNavigationChainLength:
72
- Exclude:
73
- - 'lib/docscribe/inline_rewriter.rb'
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at senpaiguru1488@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in docscribe.gemspec
6
- gemspec
data/Gemfile.lock DELETED
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- docscribe (1.0.0)
5
- parser (>= 3.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.3)
11
- diff-lcs (1.6.2)
12
- json (2.16.0)
13
- language_server-protocol (3.17.0.5)
14
- lint_roller (1.1.0)
15
- parallel (1.27.0)
16
- parser (3.3.10.0)
17
- ast (~> 2.4.1)
18
- racc
19
- prism (1.6.0)
20
- racc (1.8.1)
21
- rainbow (3.1.1)
22
- rake (13.3.1)
23
- regexp_parser (2.11.3)
24
- rspec (3.13.2)
25
- rspec-core (~> 3.13.0)
26
- rspec-expectations (~> 3.13.0)
27
- rspec-mocks (~> 3.13.0)
28
- rspec-core (3.13.6)
29
- rspec-support (~> 3.13.0)
30
- rspec-expectations (3.13.5)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.13.0)
33
- rspec-mocks (3.13.7)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.13.0)
36
- rspec-support (3.13.6)
37
- rubocop (1.81.7)
38
- json (~> 2.3)
39
- language_server-protocol (~> 3.17.0.2)
40
- lint_roller (~> 1.1.0)
41
- parallel (~> 1.10)
42
- parser (>= 3.3.0.2)
43
- rainbow (>= 2.2.2, < 4.0)
44
- regexp_parser (>= 2.9.3, < 3.0)
45
- rubocop-ast (>= 1.47.1, < 2.0)
46
- ruby-progressbar (~> 1.7)
47
- unicode-display_width (>= 2.4.0, < 4.0)
48
- rubocop-ast (1.48.0)
49
- parser (>= 3.3.7.2)
50
- prism (~> 1.4)
51
- rubocop-sorted_methods_by_call (1.1.2)
52
- lint_roller
53
- rubocop (>= 1.72.0)
54
- ruby-progressbar (1.13.0)
55
- unicode-display_width (3.2.0)
56
- unicode-emoji (~> 4.1)
57
- unicode-emoji (4.1.0)
58
- yard (0.9.37)
59
-
60
- PLATFORMS
61
- ruby
62
- x86_64-linux
63
-
64
- DEPENDENCIES
65
- docscribe!
66
- rake
67
- rspec (~> 3.0)
68
- rubocop
69
- rubocop-sorted_methods_by_call
70
- yard (>= 0.9.34)
71
-
72
- BUNDLED WITH
73
- 2.5.9
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require 'rubocop/rake_task'
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
data/rakelib/docs.rake DELETED
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'English'
4
- require 'yard'
5
- require 'fileutils'
6
-
7
- GEM_NAME = Bundler.load_gemspec(Dir.glob('*.gemspec').first).name
8
- DOCS_REPO_NAME = "#{GEM_NAME}_docs".freeze
9
- DOCS_REPO_PATH = "../#{DOCS_REPO_NAME}".freeze
10
-
11
- namespace :docs do # rubocop:disable Metrics/BlockLength
12
- desc 'Generate new docs and push them to repo'
13
- task generate: :clean do
14
- puts 'Generating docs...'
15
- YARD::CLI::Yardoc.run
16
- puts 'OK!'
17
- end
18
-
19
- desc 'Clean existing docs'
20
- task :clean do
21
- if File.directory?('doc')
22
- FileUtils.rm_rf('doc')
23
- puts 'Cleaned existing docs directory'
24
- end
25
- end
26
-
27
- desc 'Pushes docs to github'
28
- task push: :generate do
29
- unless File.directory?(DOCS_REPO_PATH)
30
- puts "Error: Docs repo not found at #{DOCS_REPO_PATH}"
31
- puts 'Please clone the docs repo first:'
32
- puts " git clone git@github.com:unurgunite/#{DOCS_REPO_NAME}.git #{DOCS_REPO_PATH}"
33
- exit 1
34
- end
35
-
36
- puts "Copying docs to #{DOCS_REPO_PATH}..."
37
- FileUtils.mkdir_p('doc') unless File.directory?('doc')
38
- FileUtils.cp_r('doc/.', DOCS_REPO_PATH)
39
-
40
- puts 'Changing dir...'
41
- Dir.chdir(DOCS_REPO_PATH) do
42
- puts 'Checking git status...'
43
- status_output = `git status --porcelain`
44
-
45
- if status_output.strip.empty?
46
- puts 'No changes to commit'
47
- else
48
- puts 'Committing git changes...'
49
- puts `git add .`
50
- commit_result = `git commit -m "Update docs for #{GEM_NAME} #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S UTC')}"`
51
- puts commit_result
52
-
53
- if $CHILD_STATUS.success?
54
- puts 'Pushing to GitHub...'
55
- push_result = `git push origin master 2>&1`
56
- puts push_result
57
- if $CHILD_STATUS.success?
58
- puts 'Docs successfully pushed!'
59
- else
60
- puts 'Push failed!'
61
- exit 1
62
- end
63
- else
64
- puts 'Commit failed!'
65
- exit 1
66
- end
67
- end
68
- end
69
- end
70
-
71
- desc 'Generate and push docs in one command'
72
- task deploy: :push
73
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/docscribe/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'docscribe'
7
- spec.version = Docscribe::VERSION
8
- spec.authors = ['unurgunite']
9
- spec.email = ['senpaiguru1488@gmail.com']
10
-
11
- spec.summary = 'Autogenerate documentation for Ruby code with YARD syntax.'
12
- spec.homepage = 'https://github.com/unurgunite/docscribe'
13
- spec.required_ruby_version = '>= 3.0'
14
-
15
- spec.metadata['homepage_uri'] = spec.homepage
16
- spec.metadata['source_code_uri'] = 'https://github.com/unurgunite/docscribe'
17
- spec.metadata['changelog_uri'] = 'https://github.com/unurgunite/docscribe/blob/master/CHANGELOG.md'
18
- spec.metadata['rubygems_mfa_required'] = 'true'
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(__dir__) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
25
- end
26
- end
27
- spec.bindir = 'exe'
28
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
30
-
31
- # Uncomment to register a new dependency of your gem
32
- spec.add_dependency 'parser', '>= 3.0'
33
- spec.add_development_dependency 'rake'
34
- spec.add_development_dependency 'rspec', '~> 3.0'
35
- spec.add_development_dependency 'rubocop'
36
- spec.add_development_dependency 'rubocop-sorted_methods_by_call'
37
- spec.add_development_dependency 'yard', '>= 0.9.34'
38
-
39
- # For more information and examples about making a new gem, check out our
40
- # guide at: https://bundler.io/guides/creating_gem.html
41
- end