Skip to content

Commit 64c2815

Browse files
committed
Fix pronto complaints
1 parent 14c7e0f commit 64c2815

File tree

10 files changed

+48
-8
lines changed

10 files changed

+48
-8
lines changed

.rubocop.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
# This gist contains the config for rubocop-performance >1.11 / rubocop >1.22, for ruby 3.0: https://gist.github.com/apptweak-ci/2aca83afffbcbe0c0bca2beaab1500c0
22
inherit_from: https://gist.githubusercontent.com/apptweak-ci/2aca83afffbcbe0c0bca2beaab1500c0/raw/.rubocop.yml
33

4-
require:
4+
plugins:
5+
- rubocop-performance
56
- rubocop-rake
7+
8+
require:
69
- rubocop-yard
710

811
Gemspec/RequireMFA:
912
Enabled: false
13+
14+
Naming/FileName:
15+
Exclude:
16+
- "lib/yard-apptweak-template.rb"
17+
18+
Style/DocumentationMethod:
19+
Exclude:
20+
- "lib/yard-apptweak-template/stubs/**/*"
21+
- "lib/yard-apptweak-template/templates/**/*"

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ group :development do
1515
gem "lefthook", "~> 1.8", require: false
1616
gem "pronto", "~> 0.11.1", require: false
1717
gem "pronto-rubocop", require: false
18-
gem "webrick", require: false
1918
gem "rubocop", "~> 1.68", require: false
2019
gem "rubocop-performance", "~> 1.22", require: false
2120
gem "rubocop-rake", "~> 0.6", require: false
2221
gem "rubocop-yard", "~> 0.9", require: false
23-
22+
gem "webrick", require: false
2423
gem "yard-junk", require: false
2524
gem "yard-markdown", require: false
2625
end

bin/new_release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ReleaseManager
8989
# Store initial state for potential rollback
9090
@initial_state = {
9191
branch: current_branch,
92-
commit_sha: get_current_commit_sha
92+
commit_sha: current_commit_sha
9393
}
9494
@current_phase = PHASES[:init]
9595

@@ -162,7 +162,7 @@ class ReleaseManager
162162

163163
# Get current commit SHA for potential rollback
164164
# @return [String] current commit SHA
165-
def get_current_commit_sha
165+
def current_commit_sha
166166
sha, _err = silent_runner.run("git rev-parse HEAD")
167167
sha.strip
168168
end

lib/yard-apptweak-template.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
require_relative "yard-apptweak-template/yard/html_helper"
1010
require_relative "yard-apptweak-template/patches/c_base_handler"
1111

12+
# Module for Yard-related code.
1213
module ApptweakTemplateYARD
14+
# Initialize the Yard-related code.
1315
def self.init
1416
# https://github.com/burtlo/yard-cucumber/blob/master/lib/yard-cucumber.rb
1517
# This registered template works for yardoc
@@ -28,6 +30,7 @@ def self.init
2830
YARD::Tags::Library.visible_tags |= tags
2931
end
3032

33+
# @return [String] Path to the templates
3134
def self.templates_path
3235
File.join(__dir__, "yard-apptweak-template", "templates")
3336
end

lib/yard-apptweak-template/patches/c_base_handler.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,36 @@
33
module YARD
44
module Handlers
55
module C
6+
# Patch for YARD's C Base handler to correctly map C exception variables
7+
# to their corresponding Ruby class names.
68
class Base < Handlers::Base
79
# Temporary workaround until a proper fix can be applied to YARD master.
810
alias namespace_for_variable_original namespace_for_variable
11+
12+
# Overrides the original method to include custom mapping for C exception variables.
13+
# Falls back to the original implementation if no custom mapping is found.
14+
#
15+
# @param var [String] The C variable name.
16+
# @return [CodeObjects::NamespaceObject, nil] The corresponding namespace object or nil.
917
def namespace_for_variable(var)
1018
patch_namespace_for_variable(var) ||
1119
namespace_for_variable_original(var)
1220
end
1321

1422
private
1523

24+
# Attempts to find a Ruby class name mapping for the given C variable.
25+
#
26+
# @param var [String] The C variable name.
27+
# @return [CodeObjects::Proxy, nil] A proxy object for the mapped class or nil.
1628
def patch_namespace_for_variable(var)
1729
name = PATCH_ERROR_NAME[var]
1830
# $stderr.puts "Mapped #{var} to #{name}" if name
1931
name.nil? ? nil : P(name)
2032
end
2133

2234
# Generated by update_error_map.rb (Copy+past results)
35+
# Maps C exception variable names to their Ruby class names.
2336
PATCH_ERROR_NAME = {
2437
"rb_eException" => "Exception",
2538
"rb_eSystemExit" => "SystemExit",

lib/yard-apptweak-template/stubs/autoload.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module ApptweakTemplateYARD
44
module Stubs
5+
# Generates the autoload file for the SketchUp API stubs.
56
class AutoLoadGenerator
67
# @param [YARD::CodeObject::Base] namespace_objects
78
# @param [IO] out
@@ -20,7 +21,7 @@ def generate(namespace_objects, out)
2021

2122
private
2223

23-
class Node
24+
class Node # :nodoc:
2425
attr_reader :object, :dependencies
2526

2627
def initialize(object)
@@ -53,7 +54,7 @@ def hash
5354
end
5455
end
5556

56-
class NodeFactory
57+
class NodeFactory # :nodoc:
5758
def initialize
5859
@dependencies = {}
5960
end

lib/yard-apptweak-template/yard/handlers/class_constants.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
module ApptweakTemplateYARD
4+
# Handles the definition of class constants defined in the Ruby code using
5+
# the `DEFINE_RUBY_CLASS_CONSTANT` macro.
46
class ClassConstantHandler < YARD::Handlers::C::Base
57
MATCH = /\bDEFINE_RUBY_CLASS_CONSTANT\s*\(([^,]+)\s*,\s*([^,]+)\s*,\s*(\w+)\s*\)\s*;/xm
68
handles MATCH

lib/yard-apptweak-template/yard/handlers/class_enum_constants.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
module ApptweakTemplateYARD
4+
# Handles the definition of class enum constants defined in the Ruby code
5+
# using the `DEFINE_RUBY_CLASS_ENUM` macro.
46
class ClassEnumConstantHandler < YARD::Handlers::C::Base
57
MATCH = /\bDEFINE_RUBY_CLASS_ENUM\s*\(([^,]+)\s*,\s*(\w+)\s*\)\s*;/xm
68
handles MATCH

lib/yard-apptweak-template/yard/handlers/global_constants.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
module ApptweakTemplateYARD
4+
# Handles the definition of global constants defined in the Ruby code using
5+
# the `DEFINE_RUBY_CONSTANT` macro or `rb_define_global_const`.
46
class GlobalConstantHandler < YARD::Handlers::C::Base
57
MATCH = /\bDEFINE_RUBY_(?:(?:NAMED_)?CONSTANT|ENUM)\s*\((?:[^)]+,\s*)?(\w+)\)\s*;/xm
68
handles MATCH

lib/yard-apptweak-template/yard/html_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
require "rouge"
44

55
# Injection pattern copied from YARD::CodeRay:
6-
# https://github.com/sagmor/yard-coderay/blob/master/lib/yard/coderay/html_helper.rb
6+
#
7+
# @see https://github.com/sagmor/yard-coderay/blob/master/lib/yard/coderay/html_helper.rb
78
module ApptweakTemplateYARD
9+
# Module for Yard-related code.
810
module HTMLHelper
11+
# Highlight the source code of a C++ method.
12+
#
13+
# @param source [String] The source code to highlight.
14+
# @return [String] The highlighted source code.
915
def html_syntax_highlight_cpp(source)
1016
# puts "html_syntax_highlight_cpp (GEM)"
1117
formatter = Rouge::Formatters::HTML.new

0 commit comments

Comments
 (0)