docs.rake 1.72 KB
Newer Older
1 2 3 4
require 'launchy'

# --- Develop and public documentation ---
desc "Invoke sphinx 'make build' to generate docs."
Julian Arni committed
5 6 7
task :builddocs, [:type, :quiet] do |t, args|
    args.with_defaults(:quiet => "quiet")
    if args.type == 'dev'
8
        path = "docs/en_us/developers"
Julian Arni committed
9
    elsif args.type == 'author'
10
        path = "docs/en_us/course_authors"
Julian Arni committed
11
    elsif args.type == 'data'
12
        path = "docs/en_us/data"
13
    else
14
        path = "docs/en_us"
15 16 17
    end

    Dir.chdir(path) do
Julian Arni committed
18 19 20
        if args.quiet == 'verbose'
            sh('make html quiet=false')
        else
21
            sh('make html quiet=true')
Julian Arni committed
22
        end
23
    end
24 25
end

26
desc "Show docs in browser: dev, author, data."
27
task :showdocs, [:options] do |t, args|
28
    if args.options == 'dev'
29
        path = "docs/en_us/developers"
30
    elsif args.options == 'author'
31
        path = "docs/en_us/course_authors"
32
    elsif args.options == 'data'
33
        path = "docs/en_us/data"
34
    else
35
        path = "docs/en_us/developers"
36
    end
37

38
    Launchy.open("#{path}/build/html/index.html")
39 40 41
end

desc "Build docs and show them in browser"
Julian Arni committed
42 43
task :doc, [:type, :quiet] =>  :builddocs do |t, args|
    Rake::Task["showdocs"].invoke(args.type, args.quiet)
44
end
45 46 47 48


# Run documentation tests
desc "Run documentation tests"
49
task :test_docs => :install_python_prereqs do
50 51 52 53 54 55 56 57 58 59
    # Be sure that sphinx can build docs w/o exceptions.
    test_message = "If a docs test fails, you should run '%s' and look at whole output and fix exceptions.
(You shouldn't fix rst warnings and errors for this to pass, just get rid of exceptions.)"
    puts (test_message  % ["rake doc[docs,verbose]"]).colorize( :light_green )
    test_sh('docs', 'rake builddocs')
end


# Add documentation tests to the main test command
task :test => :'test_docs'