Right now Yardoc will generate docs like: doc/ModuleName.html, doc/ModuleName/ClassName.html and doc/ModuleName/ClassName/method_name.html I was wondering how I can adjust serialized_path
(without monkey patching everything) to do something like: doc/ModuleName/index.html doc/ModuleName/ClassName/index.html and doc/ModuleName/ClassName/method_name/index.html
Asked
Active
Viewed 75 times
0

Jordon Bedwell
- 3,189
- 3
- 23
- 32
-
Why you want to do that? If it's for prettier URLs you can achieve that with rewriting. – Slartibartfast Oct 30 '11 at 20:21
-
@slartibartfast Lets say I do take this suggestion, I would then be stuck with sloppy URLs and having to manually edit a bunch of links or to 301 redirect (which again it just plain sloppy), that is not ideal, at all... – Jordon Bedwell Oct 31 '11 at 05:59
-
By rewriting I meant something on server configuration level. You can add a rewrite rule that says something like "if there is no file with this name, try appending .html". Even on shared (apache) hostings you can probably add this kind of rule in your local `.htaccess` – Slartibartfast Oct 31 '11 at 07:45
-
@slartibartfast And I didn't mean that? I think you are a bit confused so let me clarify for you. Links are outputted as ModuleName/ClassName.html, or ../_index.html (until I fixed that -- just it using _) I do not want that, I will not use a Dirty front-end hack to create pretty URL's (which would still leave the outputted links relative and to .html files and would again require another dirty front-end hack to 301) that creates as mess for management, that creates a mess period. I'm no fan of dirty hacks because they always need to be fixed later, development procrastination is bad :P – Jordon Bedwell Oct 31 '11 at 07:56
1 Answers
0
You'll need to monkey patch (from what I've noticed, after 2 days of searching I found no other way) So...Create a file named yardoc_pretty-uris.rb and when you run yardoc do -e yardo_pretty-print.rb
.
yardoc_pretty-uris.rb contents:
module YARD
module Serializers
class FileSystemSerializer
def serialized_path(object)
return object if object.is_a?(String)
if object.is_a?(CodeObjects::ExtraFileObject)
fspath = ["file.#{object.name}.#{@extension}"]
else
objname = "top-level-namespace"
objname = object.name.to_s if object != YARD::Registry.root
# Make this shit pretty URL's prease.....
fspath = [objname, "index.#{@extension}"]
if object.namespace && object.namespace.path != ""
fspath.unshift(*object.namespace.path.split(CodeObjects::NSEP))
end
end
fspath.map! do |part|
part.downcase!
part.gsub(/[^0-9a-zA-Z\-_\.]/, '')
end
File.join(fspath)
end
end
end
end

Jordon Bedwell
- 3,189
- 3
- 23
- 32