Sha256: 5e90ba46fa36bef3d4524087630a31e921f5f71d7440c2f2a6e6a336cba6c112
Contents?: true
Size: 764 Bytes
Versions: 1
Compression:
Stored size: 764 Bytes
Contents
# typed: true # frozen_string_literal: true # Extract & re-add directives to a docstring module YARDSorbet::Directives def self.extract_directives(docstring) parser = YARD::DocstringParser.new.parse(docstring) # Directives are already parsed at this point, and there doesn't # seem to be an API to tweeze them from one node to another without # managing YARD internal state. Instead, we just extract them from # the raw text and re-attach them. directives = parser.raw_text&.split("\n")&.select do |line| line.start_with?('@!') end || [] [parser.to_docstring, directives] end def self.add_directives(docstring, directives) directives.each do |directive| docstring.concat("\n#{directive}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yard-sorbet-0.1.0 | lib/yard-sorbet/directives.rb |