Merge pull request #20557 from Homebrew/dug/typed-yard
Enable strict typing in yard extensions
This commit is contained in:
commit
5e3a8d96c6
@ -1,6 +1,9 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "sorbet-runtime"
|
||||||
|
require_relative "../extend/module"
|
||||||
|
|
||||||
# from https://github.com/lsegal/yard/issues/484#issuecomment-442586899
|
# from https://github.com/lsegal/yard/issues/484#issuecomment-442586899
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module YARD
|
module YARD
|
||||||
@ -18,6 +21,7 @@ module Homebrew
|
|||||||
private_constant :SELF_EXPLANATORY_METHODS
|
private_constant :SELF_EXPLANATORY_METHODS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(content: T.nilable(String)).returns(String) }
|
||||||
def parse_content(content)
|
def parse_content(content)
|
||||||
# Convert plain text to tags.
|
# Convert plain text to tags.
|
||||||
content = content&.gsub(/^\s*(TODO|FIXME):\s*/i, "@todo ")
|
content = content&.gsub(/^\s*(TODO|FIXME):\s*/i, "@todo ")
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# This follows the docs at https://github.com/lsegal/yard/blob/main/docs/Templates.md#setuprb
|
# This follows the docs at https://github.com/lsegal/yard/blob/main/docs/Templates.md#setuprb
|
||||||
# rubocop:disable Style/TopLevelMethodDefinition
|
# rubocop:disable Style/TopLevelMethodDefinition
|
||||||
|
sig { void }
|
||||||
def init
|
def init
|
||||||
# `sorbet` is available transitively through the `yard-sorbet` plugin, but we're
|
# `sorbet` is available transitively through the `yard-sorbet` plugin, but we're
|
||||||
# outside of the standalone sorbet config, so `checked` is enabled by default
|
# outside of the standalone sorbet config, so `checked` is enabled by default
|
||||||
T.bind(self, T.all(Class, YARD::Templates::Template), checked: false)
|
T.bind(self, T.all(T::Class[T.anything], YARD::Templates::Template), checked: false)
|
||||||
super
|
super
|
||||||
|
|
||||||
return if sections.empty?
|
return if sections.empty?
|
||||||
@ -14,6 +15,7 @@ def init
|
|||||||
sections[:index].place(:internal).before(:private)
|
sections[:index].place(:internal).before(:private)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def internal
|
def internal
|
||||||
T.bind(self, YARD::Templates::Template, checked: false)
|
T.bind(self, YARD::Templates::Template, checked: false)
|
||||||
erb(:internal) if object.has_tag?(:api) && object.tag(:api).text == "internal"
|
erb(:internal) if object.has_tag?(:api) && object.tag(:api).text == "internal"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user