Skip to content

Commit 7dffa2a

Browse files
Add yard documentation
1 parent 332d2d6 commit 7dffa2a

File tree

8 files changed

+70
-0
lines changed

8 files changed

+70
-0
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
run: bundle exec ci-helper RunSpecs
3131
- name: Audit
3232
run: bundle exec ci-helper BundlerAudit
33+
- name: Documentation coverage
34+
run: bundle exec rake doc:coverage
3335
- name: Coveralls
3436
uses: coverallsapp/github-action@master
3537
with:

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ gem "rspec-json_matcher"
1616
gem "rubocop-config-umbrellio"
1717
gem "simplecov"
1818
gem "simplecov-lcov"
19+
gem "yard"

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ GEM
154154
sequel
155155
symbiont-ruby
156156
unicode-display_width (2.1.0)
157+
webrick (1.7.0)
158+
yard (0.9.27)
159+
webrick (~> 1.7.0)
157160
zeitwerk (2.5.1)
158161

159162
PLATFORMS
@@ -172,6 +175,7 @@ DEPENDENCIES
172175
sentry-gruf!
173176
simplecov
174177
simplecov-lcov
178+
yard
175179

176180
BUNDLED WITH
177181
2.3.0

Rakefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,33 @@
33
require "bundler/gem_tasks"
44
require "rspec/core/rake_task"
55
require "rubocop/rake_task"
6+
require "yard"
7+
8+
ROOT = Pathname.new(__FILE__).join("..")
69

710
RSpec::Core::RakeTask.new(:spec)
811
RuboCop::RakeTask.new(:lint)
912

13+
YARD::Rake::YardocTask.new(:doc) do |t|
14+
t.files = Dir[ROOT.join("lib/**/*.rb")]
15+
t.options = %w[--private]
16+
end
17+
18+
namespace :doc do
19+
desc "Check documentation coverage"
20+
task coverage: :doc do
21+
YARD::Registry.load
22+
objs = YARD::Registry.select do |o|
23+
puts "pending #{o}" if /TODO|FIXME|@pending/.match?(o.docstring)
24+
o.docstring.blank?
25+
end
26+
27+
next if objs.empty?
28+
puts "No documentation found for:"
29+
objs.each { |x| puts "\t#{x}" }
30+
31+
raise "100% document coverage required"
32+
end
33+
end
34+
1035
task default: %i[lint spec]

lib/sentry/gruf.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
require "sentry-ruby"
66
require "sentry/integrable"
77

8+
# Namespace, used by the `sentry-ruby-core` gem.
9+
# @see https://rubydoc.info/gems/sentry-ruby-core Sentry documentation
810
module Sentry
11+
# gruf-sentry is a library that provides both client-side and server-side interceptors
12+
# that send uncaught error data to Sentry.
913
module Gruf
1014
extend Integrable
1115
register_integration name: "gruf", version: Sentry::Gruf::VERSION

lib/sentry/gruf/client_interceptor.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
module Sentry
44
module Gruf
5+
# Interceptor for the Gruf client.
6+
# Please note that the interceptor itself does not send errors to Sentry.
7+
# It simply tags some information about the last request made through the client.
8+
# Just add this interceptor to the array of used interceptors as the first element.
9+
# @example Use client interceptor
10+
# client = ::Gruf::Client.new(
11+
# service: Some::Service,
12+
# client_options: {
13+
# interceptors: [Sentry::Gruf::ClientInterceptor.new, OtherInterceptors.new]
14+
# }
15+
# )
516
class ClientInterceptor < ::Gruf::Interceptors::ClientInterceptor
17+
# @param request_context [Gruf::Outbound::RequestContext]
618
def call(request_context:)
719
::Sentry.configure_scope do |scope|
820
scope.set_tags(

lib/sentry/gruf/server_interceptor.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
module Sentry
44
module Gruf
5+
# Interceptor for Gruf wrapper of gRPC server.
6+
# It handles all uncaught exceptions and sent them to the Sentry.
7+
# Add this interceptor to the begining of interceptors stack.
8+
# @example Use server interceptor
9+
# Gruf.configure do |config|
10+
# config.interceptors.clear
11+
# config.interceptors.use(Sentry::Gruf::ServerInterceptor)
12+
# end
513
class ServerInterceptor < ::Gruf::Interceptors::ServerInterceptor
14+
# Required method by Gruf interceptor specification.
15+
# @see https://rubydoc.info/gems/gruf/Gruf/Interceptors/ServerInterceptor Gruf documentation
16+
# @yield Perform request logic
617
def call
718
yield
819
rescue Exception => e

lib/sentry/gruf/version.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
module Sentry
44
module Gruf
5+
# Current gruf-sentry version
6+
#
7+
# format: 'a.b.c' with possible suffixes such as alpha
8+
# * a is for major version, it is guaranteed to be changed
9+
# if back-compatibility of public API is broken
10+
# * b is for minor version, it is guaranteed to be changed
11+
# on public API changes and also if private API
12+
# back-compatibility is broken
13+
# * c is for incremental version, it is updated in other cases
14+
# According to this, it is enough to specify '~> a.b'
15+
# if private API was not used and to specify '~> a.b.c' if it was
516
VERSION = "1.0.0"
617
end
718
end

0 commit comments

Comments
 (0)