X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c0a5fa033d0a9bfbeab001f287969756e9e1d16d..6da6b846097364da3abed2abad272e9607b15ca8:/doc/Rakefile diff --git a/doc/Rakefile b/doc/Rakefile index eaa5410100..71d86c32dc 100644 --- a/doc/Rakefile +++ b/doc/Rakefile @@ -3,11 +3,17 @@ # # SPDX-License-Identifier: CC-BY-SA-3.0 +# As a convenience to the documentation writer, you can touch a file +# called 'no-sdk' in the 'doc' directory and it will suppress +# generating the documentation for the SDKs, which (the R docs +# especially) take a fair bit of time and slow down the edit-preview +# cycle. + require "rubygems" require "colorize" -task :generate => [ :realclean, 'sdk/python/arvados/index.html', 'sdk/R/arvados/index.html' ] do - vars = ['baseurl', 'arvados_api_host', 'arvados_workbench_host'] +task :generate => [ :realclean, 'sdk/python/arvados/index.html', 'sdk/R/arvados/index.html', 'sdk/java-v2/javadoc/index.html' ] do + vars = ['baseurl', 'arvados_cluster_uuid', 'arvados_api_host', 'arvados_workbench_host'] vars.each do |v| if ENV[v] website.config.h[v] = ENV[v] @@ -16,6 +22,9 @@ task :generate => [ :realclean, 'sdk/python/arvados/index.html', 'sdk/R/arvados/ end file "sdk/python/arvados/index.html" do |t| + if File.exists? "no-sdk" + next + end `which epydoc` if $? == 0 STDERR.puts `epydoc --html --parse-only -o sdk/python/arvados ../sdk/python/arvados/ 2>&1` @@ -26,18 +35,98 @@ file "sdk/python/arvados/index.html" do |t| end file "sdk/R/arvados/index.html" do |t| + if File.exists? "no-sdk" + next + end `which R` if $? == 0 + tgt = Dir.pwd + Dir.mkdir("sdk/R") + Dir.mkdir("sdk/R/arvados") + puts("tgt", tgt) + cp('css/R.css', 'sdk/R/arvados') + docfiles = [] Dir.chdir("../sdk/R/") do - STDERR.puts `R --quiet --vanilla -e 'pkgdown::build_site()' 2>&1` + STDERR.puts `Rscript createDoc.R README.Rmd #{tgt}/sdk/R/README.md 2>&1` + Dir.entries("man").each do |rd| + if rd[-3..-1] == ".Rd" + htmlfile = "#{rd[0..-4]}.html" + `R CMD Rdconv -t html man/#{rd} > #{tgt}/sdk/R/arvados/#{htmlfile}` + docfiles << htmlfile + end + end end raise if $? != 0 - cp_r("../sdk/R/docs", "sdk/R/arvados") + + File.open("sdk/R/README.md", "r") do |rd| + File.open("sdk/R/index.html.md", "w") do |fn| + fn.write(<<-EOF +--- +layout: default +navsection: sdk +navmenu: R +title: "R SDK Overview" +... + +#{rd.read.gsub(/^```$/, "~~~").gsub(/^```(\w)$/, "~~~\\1")} +EOF + ) + end + end + + File.open("sdk/R/arvados/index.html.textile.liquid", "w") do |fn| + fn.write(<<-EOF +--- +layout: default +navsection: sdk +navmenu: R +title: "R Reference" +... +{% comment %} +Copyright (C) The Arvados Authors. All rights reserved. + +SPDX-License-Identifier: CC-BY-SA-3.0 +{% endcomment %} + +EOF + ) + + docfiles.sort.each do |d| + fn.write("* \"#{d[0..-6]}\":#{d}\n") + end + + end else puts "Warning: R not found, R documentation will not be generated".colorize(:light_red) end end +file "sdk/java-v2/javadoc/index.html" do |t| + if File.exists? "no-sdk" + next + end + `which java` + if $? == 0 + `which gradle` + if $? != 0 + puts "Warning: gradle not found, java sdk documentation will not be generated".colorize(:light_red) + else + tgt = Dir.pwd + docfiles = [] + Dir.chdir("../sdk/java-v2") do + STDERR.puts `gradle javadoc 2>&1` + raise if $? != 0 + puts `sed -i "s/@import.*dejavu.css.*//g" build/docs/javadoc/stylesheet.css` + raise if $? != 0 + end + cp_r("../sdk/java-v2/build/docs/javadoc", "sdk/java-v2") + raise if $? != 0 + end + else + puts "Warning: java not found, java sdk documentation will not be generated".colorize(:light_red) + end +end + task :linkchecker => [ :generate ] do Dir.chdir(".site") do `which linkchecker` @@ -51,8 +140,8 @@ end task :clean do rm_rf "sdk/python/arvados" - rm_rf "sdk/R/arvados" - rm_rf "../sdk/R/docs" + rm_rf "sdk/R" + rm_rf "sdk/java-v2/javadoc" end require "zenweb/tasks"