(PDOC-159) server urls fix

When using `puppet strings server`, resources with names containing '::' end up 404ing from the left bar. This is because strings namespaces these objects but YARD does not when building URLs.
e.g. foo::bar's url should be /doc/foo/puppet_classes/foo/bar.html but
ends up instead being doc/foo/puppet_classes/foo_3A_3A_bar.html because
of YARD's url encoding. This is a monkey patch, courtesy @domcleal, that
decodes the urls back so that they are namespaced correctly.
This commit is contained in:
Eric Putnam 2018-04-12 11:53:56 +01:00
parent db7ac68870
commit e63f1c3142
No known key found for this signature in database
GPG Key ID: 3FB595AA224A7751
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# Monkey patch URL decoding in object displays. Usually :: is interpreted as a
# namespace, but this is disabled in our base object, and so instead gets
# URL-encoded.
require 'yard/server/commands/display_object_command'
class YARD::Server::Commands::DisplayObjectCommand
private
alias_method :object_path_yard, :object_path
def object_path
object_path_yard.gsub('_3A', ':')
end
end

View File

@ -6,6 +6,7 @@ module PuppetStrings::Yard
require 'puppet-strings/yard/handlers' require 'puppet-strings/yard/handlers'
require 'puppet-strings/yard/tags' require 'puppet-strings/yard/tags'
require 'puppet-strings/yard/parsers' require 'puppet-strings/yard/parsers'
require 'puppet-strings/monkey_patches/display_object_command'
# Sets up YARD for use with puppet-strings. # Sets up YARD for use with puppet-strings.
# @return [void] # @return [void]