I am using yard to generate project documentation, but i don't want to display the [view source] link in the documentation, i have dived into the yard official guides but still don't get the solution.
Anything ideas? Thanks.
I might be a little late but you can trivially customize the default template by removing the "source" section from the method_details partial. You can do so by creating the file "my_template/default/method_details/setup.rb" in the root of your project with the contents:
def init
super
sections.first.delete(:source)
end
Then you can call YARD with your custom template modifications:
$ yardoc -p my_template
I could not find a direct way to do this in yard, but you can try running the following on the generated yard documentation folder:
require "find"
Find.find(".") do |file|
if file.match(/\.html$/)
puts "Filtering #{file}"
content = File.read(file)
no_source_content = content.gsub(/<table class="source_code".*?<\/table>/m, "")
File.open(file, "w") { |io| io.write no_source_content }
end
end
unless File.read("css/common.css").match(/Hide source links/)
File.open("css/common.css", "a+") { |io| io.write("\n/* Hide source links */\n.toggleSource { display:none }") }
end
Currently i just use javascript to remove the source html:
$('.showSource').remove();
来源:https://stackoverflow.com/questions/7116207/how-to-prevent-view-source-link-when-creating-documentation-using-yard