Created
May 15, 2020 20:41
-
-
Save lorawoodford/40a97bbba35db23185c08298a50e2a05 to your computer and use it in GitHub Desktop.
Docs will build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :doc do | |
desc "Generate the documentation" | |
task :yard do | |
puts "Generating YARD documentation" | |
system(File.join("..", "build", "run"), "doc:yardoc") | |
end | |
desc "Create the API.md file" | |
task :api do | |
require 'erb' | |
require 'sinatra' | |
require 'jsonmodel' | |
require_relative '../backend/app/lib/rest.rb' | |
require_relative '../backend/app/lib/username.rb' | |
require_relative '../backend/app/model/backend_enum_source.rb' | |
require_relative '../common/log.rb' | |
require_relative '../backend/app/lib/streaming_import.rb' | |
require_relative '../backend/app/lib/component_transfer.rb' | |
class ArchivesSpaceService < Sinatra::Base | |
def self.helpers | |
nil | |
end | |
include RESTHelpers | |
end | |
@time = Time.new | |
JSONModel::init(:enum_source => BackendEnumSource) | |
require_relative '../backend/app/lib/export' | |
Dir.glob(File.dirname(__FILE__) + '/../backend/app/controllers/*.rb').sort.each {|file| require file unless (file =~ /system/ || file =~ /oai/ || file =~ /bulk_import/)} | |
@endpoints = ArchivesSpaceService::Endpoint.all.sort{|a,b| a[:uri] <=> b[:uri]} | |
@examples = JSON.parse( IO.read File.dirname(__FILE__) + "/../endpoint_examples.json" ) | |
erb = ERB.new(File.read('API.erb'), nil, '<>') | |
File.open('../API.md', 'w') do |f| | |
f.write erb.result(binding) | |
end | |
end | |
desc 'Rename the YARD index file to avoid problems with Jekyll' | |
task :rename_index do | |
Dir.chdir('../docs') do | |
files = Dir.glob('doc/**/*') | |
files.each do |f| | |
if File::file?(f) | |
content = File.read(f) | |
content.gsub!('"_index.html"', '"alpha_index.html"') | |
content.gsub!('/_index.html', '/alpha_index.html') | |
File.open(f, "w") do |io| | |
io.write content | |
end | |
end | |
end | |
`mv doc/_index.html doc/alpha_index.html` | |
end | |
end | |
desc 'This generates all documentation and publishes it to the doc folder' | |
task :gen do | |
Rake::Task["doc:api"].invoke | |
Rake::Task["doc:yard"].invoke | |
# Rake::Task["doc:yard-txt"].invoke | |
Rake::Task["doc:rename_index"].invoke | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment