diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 483898def..8622f5c33 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -91,3 +91,16 @@ jobs: bundle exec erb_lint --lint-all env: RAILS_VERSION: '~> 8' + yard-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 4.0 + bundler-cache: true + - name: YARD Lint + run: bundle exec yard-lint lib/ diff --git a/.yard-lint.yml b/.yard-lint.yml new file mode 100644 index 000000000..9578a58c1 --- /dev/null +++ b/.yard-lint.yml @@ -0,0 +1,106 @@ +# YARD-Lint Configuration +# See https://github.com/mensfeld/yard-lint for documentation + +AllValidators: + YardOptions: + - --plugin + - activesupport-concern + + Exclude: + - 'vendor/**/*' + - 'spec/**/*' + - 'test/**/*' + - 'performance/**/*' + + FailOnSeverity: error + +Documentation/UndocumentedObjects: + Enabled: false + +Documentation/UndocumentedMethodArguments: + Enabled: false + +Documentation/UndocumentedBooleanMethods: + Enabled: true + +Documentation/UndocumentedOptions: + Enabled: false + +Documentation/MissingReturn: + Enabled: false + +Documentation/MarkdownSyntax: + Enabled: true + +Documentation/EmptyCommentLine: + Enabled: true + +Documentation/BlankLineBeforeDefinition: + Enabled: false + +Tags/Order: + Enabled: true + +Tags/InvalidTypes: + Enabled: true + +Tags/TypeSyntax: + Enabled: true + +Tags/MeaninglessTag: + Enabled: true + +Tags/CollectionType: + Enabled: true + +Tags/TagTypePosition: + Enabled: true + +Tags/ApiTags: + Enabled: false + +Tags/OptionTags: + Enabled: false + +Tags/ExampleSyntax: + Enabled: true + +Tags/ExampleStyle: + Enabled: true + +Tags/RedundantParamDescription: + Enabled: true + +Tags/InformalNotation: + Enabled: true + +Tags/NonAsciiType: + Enabled: true + +Tags/TagGroupSeparator: + Enabled: false + +Tags/ForbiddenTags: + Enabled: true + +Warnings/UnknownTag: + Enabled: true + Severity: error + +Warnings/UnknownDirective: + Enabled: true + +Warnings/InvalidTagFormat: + Enabled: true + +Warnings/InvalidDirectiveFormat: + Enabled: true + +Warnings/DuplicatedParameterName: + Enabled: true + +Warnings/UnknownParameterName: + Enabled: true + +Semantic/AbstractMethods: + Enabled: true diff --git a/Gemfile b/Gemfile index d27f4c484..d1aa87cf1 100644 --- a/Gemfile +++ b/Gemfile @@ -46,5 +46,6 @@ group :development, :test do gem "turbo-rails" gem "warning" gem "yard-activesupport-concern", "< 1" + gem "yard-lint", "~> 1.5" gem "yard", "< 1" end diff --git a/Gemfile.lock b/Gemfile.lock index 3b796204f..b7824b9f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -409,6 +409,9 @@ GEM yard (0.9.43) yard-activesupport-concern (0.0.1) yard (>= 0.8) + yard-lint (1.5.1) + yard (~> 0.9) + zeitwerk (~> 2.6) zeitwerk (2.7.5) PLATFORMS @@ -460,6 +463,7 @@ DEPENDENCIES warning yard (< 1) yard-activesupport-concern (< 1) + yard-lint (~> 1.5) CHECKSUMS action_text-trix (2.1.18) sha256=3fdb83f8bff4145d098be283cdd47ac41caf5110bfa6df4695ed7127d7fb3642 @@ -621,6 +625,7 @@ CHECKSUMS xpath (3.2.0) sha256=6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e yard (0.9.43) sha256=cf8733a8f0485df2a162927e9b5f182215a61f6d22de096b8f402c726a1c5821 yard-activesupport-concern (0.0.1) sha256=be790cb0efc23e2e87677063598ac8b743586154657bbd9655a7f03ce78390ef + yard-lint (1.5.1) sha256=41d194855b4f54aa957a0337720c6f48e252e4a31d7412c46cc94a12399c0149 zeitwerk (2.7.5) sha256=d8da92128c09ea6ec62c949011b00ed4a20242b255293dd66bf41545398f73dd RUBY VERSION diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 33b31ae91..a489804d7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 6 ## main +* Add `yard-lint` to CI. + + *Joel Hawksley* + ## 4.8.0 * Add `compile.view_component` ActiveSupport::Notifications event for eager compilation at boot time. diff --git a/lib/view_component/compiler.rb b/lib/view_component/compiler.rb index 69b555046..9a4eecd47 100644 --- a/lib/view_component/compiler.rb +++ b/lib/view_component/compiler.rb @@ -57,9 +57,8 @@ def compile(raise_errors: false, force: false) end end + # @param requested_details [ActionView::TemplateDetails::Requested] i.e. locales, formats, variants # @return all matching compiled templates, in priority order based on the requested details from LookupContext - # - # @param [ActionView::TemplateDetails::Requested] requested_details i.e. locales, formats, variants def find_templates_for(requested_details) filtered_templates = @templates.select do |template| template.details.matches?(requested_details) diff --git a/lib/view_component/slot.rb b/lib/view_component/slot.rb index e70a421e2..ca90ca804 100644 --- a/lib/view_component/slot.rb +++ b/lib/view_component/slot.rb @@ -96,7 +96,6 @@ def to_s # end # end # end - # def method_missing(symbol, *args, **kwargs, &block) @__vc_component_instance.public_send(symbol, *args, **kwargs, &block) end diff --git a/lib/view_component/test_helpers.rb b/lib/view_component/test_helpers.rb index f6763e91e..dcf8b0619 100644 --- a/lib/view_component/test_helpers.rb +++ b/lib/view_component/test_helpers.rb @@ -71,17 +71,16 @@ def rendered_json # assert_text("Hello, World!") # ``` # - # Note: `#rendered_preview` expects a preview to be defined with the same class - # name as the calling test, but with `Test` replaced with `Preview`: - # - # MyComponentTest -> MyComponentPreview etc. - # - # In RSpec, `Preview` is appended to `described_class`. - # # @param name [String] The name of the preview to be rendered. # @param from [ViewComponent::Preview] The class of the preview to be rendered. # @param params [Hash] Parameters to be passed to the preview. # @return [Nokogiri::HTML5] + # @note `#rendered_preview` expects a preview to be defined with the same class + # name as the calling test, but with `Test` replaced with `Preview`: + # + # MyComponentTest -> MyComponentPreview etc. + # + # In RSpec, `Preview` is appended to `described_class`. def render_preview(name, from: __vc_test_helpers_preview_class, params: {}) previews_controller = __vc_test_helpers_build_controller(Rails.application.config.view_component.previews.controller.constantize) @@ -125,7 +124,7 @@ def render_in_view_context(...) # end # ``` # - # @param variants [Symbol[]] The variants to be set for the provided block. + # @param variants [Array] The variants to be set for the provided block. def with_variant(*variants) old_variants = vc_test_controller.view_context.lookup_context.variants @@ -162,7 +161,7 @@ def with_controller_class(klass) # end # ``` # - # @param formats [Symbol[]] The format(s) to be set for the provided block. + # @param formats [Array] The format(s) to be set for the provided block. def with_format(*formats) old_formats = vc_test_controller.view_context.lookup_context.formats