| 1 |
MRuby.autoload :Documentation, 'mruby/doc' |
| 2 |
|
| 3 |
desc 'generate document' |
| 4 |
task :doc => %w[doc:api doc:capi] |
| 5 |
|
| 6 |
namespace :doc do |
| 7 |
desc 'generate yard docs' |
| 8 |
task :api do |
| 9 |
begin |
| 10 |
sh "mrbdoc" |
| 11 |
rescue |
| 12 |
puts "ERROR: To generate YARD documentation, you should install yard-mruby gem." |
| 13 |
puts " $ gem install yard-mruby yard-coderay" |
| 14 |
puts "https://yardoc.org/" |
| 15 |
puts "https://rubygems.org/gems/yard-mruby" |
| 16 |
puts "https://rubygems.org/gems/yard-coderay" |
| 17 |
end |
| 18 |
end |
| 19 |
|
| 20 |
desc 'generate doxygen docs' |
| 21 |
task :capi do |
| 22 |
begin |
| 23 |
sh "doxygen Doxyfile" |
| 24 |
rescue |
| 25 |
puts "ERROR: To generate C API documents, you need Doxygen and Graphviz." |
| 26 |
puts "On Debian-based systems:" |
| 27 |
puts " $ sudo apt-get install doxygen graphviz" |
| 28 |
puts "On RHEL-based systems:" |
| 29 |
puts " $ sudo dnf install doxygen graphviz" |
| 30 |
puts "On macOS-based systems:" |
| 31 |
puts " $ brew install doxygen graphviz" |
| 32 |
puts "https://www.doxygen.nl/" |
| 33 |
puts "https://graphviz.org/" |
| 34 |
end |
| 35 |
end |
| 36 |
|
| 37 |
desc 'clean all built docs' |
| 38 |
task :clean => %w[clean:api clean:capi] |
| 39 |
|
| 40 |
namespace :clean do |
| 41 |
desc 'clean yard docs' |
| 42 |
task :api do |
| 43 |
rm_rf 'doc/api' |
| 44 |
end |
| 45 |
|
| 46 |
desc 'clean doxygen docs' |
| 47 |
task :capi do |
| 48 |
rm_rf 'doc/capi' |
| 49 |
end |
| 50 |
end |
| 51 |
|
| 52 |
namespace :view do |
| 53 |
desc 'open yard docs' |
| 54 |
task :api do |
| 55 |
if RUBY_PLATFORM.include?('darwin') |
| 56 |
sh 'open doc/api/index.html' |
| 57 |
else |
| 58 |
sh 'xdg-open doc/api/index.html' |
| 59 |
end |
| 60 |
end |
| 61 |
|
| 62 |
desc 'open doxygen docs' |
| 63 |
task :capi do |
| 64 |
if RUBY_PLATFORM.include?('darwin') |
| 65 |
sh 'open doc/capi/html/index.html' |
| 66 |
else |
| 67 |
sh 'xdg-open doc/capi/html/index.html' |
| 68 |
end |
| 69 |
end |
| 70 |
end |
| 71 |
|
| 72 |
desc 'update doc/internal/opcode.md' |
| 73 |
task 'update-opcode.md' do |
| 74 |
unless system(*%W(git --git-dir #{MRUBY_ROOT}/.git --work-tree #{MRUBY_ROOT} diff --quiet @ -- doc/internal/opcode.md)) |
| 75 |
abort <<~'ERRMESG' |
| 76 |
The file "doc/internal/opcode.md" has been modified but not committed. |
| 77 |
To avoid loss of your edits, the automatic update process has been aborted. |
| 78 |
ERRMESG |
| 79 |
end |
| 80 |
|
| 81 |
MRuby::Documentation.update_opcode_md |
| 82 |
end |
| 83 |
end |
| 84 |
|
| 85 |
# deprecated |
| 86 |
task "api_doc" => "doc:api" |
| 87 |
task "capi_doc" => "doc:capi" |
| 88 |
task "clean_doc" => "doc:clean" |
| 89 |
task "clean_api_doc" => "doc:clean:api" |
| 90 |
task "clean_capi_doc" => "doc:clean:capi" |
| 91 |
task "view_api" => "doc:view:api" |
| 92 |
task "view_capi" => "doc:view:capi" |