# HG changeset patch # User Alessio Caiazza # Date 1269169111 -3600 # Node ID 1eb6771ce4a84ed6dd76e340b17439c76b918248 # Parent ba52b1257333046ce4f46556e8b6f16a9b02c4ab using yard for documetation diff -r ba52b1257333046ce4f46556e8b6f16a9b02c4ab -r 1eb6771ce4a84ed6dd76e340b17439c76b918248 .hgignore --- a/.hgignore Tue Feb 16 19:03:44 2010 +0100 +++ b/.hgignore Sun Mar 21 11:58:31 2010 +0100 @@ -24,3 +24,5 @@ ^script/*$ ^doc/*$ ^pkg/*$ +^meta/*$ +^\.yardoc/*$ diff -r ba52b1257333046ce4f46556e8b6f16a9b02c4ab -r 1eb6771ce4a84ed6dd76e340b17439c76b918248 Rakefile --- a/Rakefile Tue Feb 16 19:03:44 2010 +0100 +++ b/Rakefile Sun Mar 21 11:58:31 2010 +0100 @@ -41,6 +41,7 @@ p.email = "nolith@abisso.org" p.platform = Gem::Platform::RUBY p.ignore_pattern = ["tmp/**/*", "script/*"] + p.development_dependencies = ['yard'] p.runtime_dependencies << ['ruby-aes-normal', '~> 1.0'] p.runtime_dependencies << ['bit-struct'] #, '~> 0.13.6'] end diff -r ba52b1257333046ce4f46556e8b6f16a9b02c4ab -r 1eb6771ce4a84ed6dd76e340b17439c76b918248 tasks/yard_doc.rake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tasks/yard_doc.rake Sun Mar 21 11:58:31 2010 +0100 @@ -0,0 +1,50 @@ +# ======================= +# = Documentation tasks = +# ======================= +begin + require 'yard' + require 'yard/rake/yardoc_task' + + task :documentation => :'documentation:generate' + namespace :documentation do + YARD::Rake::YardocTask.new :generate do |t| + t.files = ['lib/**/*.rb'] + t.options = ['--output-dir', File.join('meta', 'documentation'), + '--readme', 'README'] + end + + YARD::Rake::YardocTask.new :dotyardoc do |t| + t.files = ['lib/**/*.rb', 'ext/**/*.c'] + t.options = ['--no-output', + '--readme', 'README'] + end + + class Numeric + def pretty_inspect(decimal_points = 3) + bits = self.to_s.split('.') + bits[0] = bits[0].reverse.scan(/\d{1,3}/).join(',').reverse + bits[1] = bits[1][0...decimal_points] if bits[1] + bits.join('.') + end + end + + task :verify do + documentation_threshold = 50.0 + doc = YARD::CLI::Yardoc.new; doc.generate = false; doc.run + + percent_documented = ( + YARD::Registry.all.select {|o| !o.docstring.empty? }.size / + YARD::Registry.all.size.to_f + ) * 100 + puts "Documentation coverage: #{percent_documented.pretty_inspect(1)}% (threshold: #{documentation_threshold.pretty_inspect(1)}%)" + end + + task :open do + system 'open ' + File.join('meta', 'documentation', 'index.html') if PLATFORM['darwin'] + end + end + +rescue LoadError + desc 'You need the `yard` gem to generate documentation' + task :documentation +end \ No newline at end of file