Merge pull request #176 from eputnam/pdoc36

(PDOC-36) fix hack for README urls
This commit is contained in:
willmeek 2018-04-23 16:33:31 +01:00 committed by GitHub
commit 8ce914ee71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -24,7 +24,7 @@ module PuppetStrings::Yard::Util
# @return [String] HTML document with links converted # @return [String] HTML document with links converted
def self.github_to_yard_links(data) def self.github_to_yard_links(data)
data.scan(/href\=\"\#(.+)\"/).each do |bad_link| data.scan(/href\=\"\#(.+)\"/).each do |bad_link|
data.gsub!(bad_link.first, "label-#{bad_link.first.capitalize.gsub('-', '+')}") data.gsub!("=\"##{bad_link.first}\"", "=\"#label-#{bad_link.first.capitalize.gsub('-', '+')}\"")
end end
data data
end end

View File

@ -39,5 +39,10 @@ STR
str = '<a href="www.github.com/blah/document.html#module-description">' str = '<a href="www.github.com/blah/document.html#module-description">'
expect(subject.github_to_yard_links(str)).to eq(str) expect(subject.github_to_yard_links(str)).to eq(str)
end end
it 'leaves plain text alone' do
str = '<a href="#module-description"> module-description'
expect(subject.github_to_yard_links(str)).to eq('<a href="#label-Module+description"> module-description')
end
end end
end end