build scala doc and then move the outdir

def build_scala_docs(app):
    """build scala doc and then move the outdir"""
    scala_path = app.builder.srcdir + '/../scala-package'
    scala_doc_sources = 'find . -type f -name "*.scala" | egrep \"\.\/core|\.\/infer\" | egrep -v \"\/javaapi\"  | egrep -v \"Suite\"'
    scala_doc_classpath = ':'.join([
        '`find native -name "*.jar" | grep "target/lib/" | tr "\\n" ":" `',
        '`find macros -name "*.jar" | tr "\\n" ":" `',
        '`find core -name "*.jar" | tr "\\n" ":" `',
        '`find infer -name "*.jar" | tr "\\n" ":" `'
    ])
    # There are unresolvable errors on mxnet 1.2.x. We are ignoring those errors while aborting the ci on newer versions
    scala_ignore_errors = '; exit 0' if any(v in _BUILD_VER for v in ['1.2.', '1.3.']) else ''
    _run_cmd('cd {}; scaladoc `{}` -classpath {} -feature -deprecation {}'
             .format(scala_path, scala_doc_sources, scala_doc_classpath, scala_ignore_errors))
    dest_path = app.builder.outdir + '/api/scala/docs'
    _run_cmd('rm -rf ' + dest_path)
    _run_cmd('mkdir -p ' + dest_path)
    # 'index' and 'package.html' do not exist in later versions of scala; delete these after upgrading scala>2.12.x
    scaladocs = ['index', 'index.html', 'org', 'lib', 'index.js', 'package.html']
    for doc_file in scaladocs:
        _run_cmd('cd ' + scala_path + ' && mv -f ' + doc_file + ' ' + dest_path + '; exit 0')