From c6deba60030f43c54261469dd9f25b390c6ea578 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 6 Jun 2019 19:55:17 +0000 Subject: [PATCH] android: fix javadoc --- modules/java/jar/CMakeLists.txt | 2 ++ modules/java/jar/build.xml.in | 8 ++++--- platforms/android/build_sdk.py | 37 ++++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/modules/java/jar/CMakeLists.txt b/modules/java/jar/CMakeLists.txt index 0e16e3b5eb..2cce25a76b 100644 --- a/modules/java/jar/CMakeLists.txt +++ b/modules/java/jar/CMakeLists.txt @@ -25,6 +25,8 @@ if(OPENCV_JAVA_TARGET_VERSION) set(OPENCV_ANT_JAVAC_EXTRA_ATTRS "${OPENCV_ANT_JAVAC_EXTRA_ATTRS} target=\"${OPENCV_JAVA_TARGET_VERSION}\"") endif() +set(OPENCV_JAVADOC_DESTINATION "${OpenCV_BINARY_DIR}/doc/doxygen/html/javadoc" CACHE STRING "") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build.xml.in" "${OPENCV_JAVA_DIR}/build.xml" @ONLY) list(APPEND depends "${OPENCV_JAVA_DIR}/build.xml") diff --git a/modules/java/jar/build.xml.in b/modules/java/jar/build.xml.in index 28a428c418..bf2830186e 100644 --- a/modules/java/jar/build.xml.in +++ b/modules/java/jar/build.xml.in @@ -30,12 +30,13 @@ + todir="@OPENCV_JAVADOC_DESTINATION@" /> + var url = window.location.href; - url = url.substring(0, url.lastIndexOf('/', url.indexOf('.html'))) + '/../../../mymath.js'; + var pos = url.lastIndexOf('/javadoc/'); + url = pos >= 0 ? (url.substring(0, pos) + '/javadoc/mymath.js') : (window.location.origin + '/mymath.js'); var script = document.createElement('script'); script.src = '@OPENCV_MATHJAX_RELPATH@/MathJax.js?config=TeX-AMS-MML_HTMLorMML,' + url; document.getElementsByTagName('head')[0].appendChild(script); diff --git a/platforms/android/build_sdk.py b/platforms/android/build_sdk.py index 9d46f0e0e0..240d9af08d 100755 --- a/platforms/android/build_sdk.py +++ b/platforms/android/build_sdk.py @@ -1,6 +1,13 @@ #!/usr/bin/env python -import os, sys, subprocess, argparse, shutil, glob, re +import os, sys +import argparse +import glob +import re +import shutil +import subprocess +import time + import logging as log import xml.etree.ElementTree as ET @@ -285,14 +292,34 @@ class Builder: for f in files: if f == "android.jar" or f == "annotations.jar": classpaths.append(os.path.join(dir, f)) + srcdir = os.path.join(self.resultdest, 'sdk', 'java', 'src') + dstdir = self.docdest + # synchronize with modules/java/jar/build.xml.in + shutil.copy2(os.path.join(SCRIPT_DIR, '../../doc/mymath.js'), dstdir) cmd = [ "javadoc", - "-header", "OpenCV %s" % self.opencv_version, + '-windowtitle', 'OpenCV %s Java documentation' % self.opencv_version, + '-doctitle', 'OpenCV Java documentation (%s)' % self.opencv_version, "-nodeprecated", - "-footer", 'OpenCV %s Documentation' % self.opencv_version, "-public", - '-sourcepath', os.path.join(self.resultdest, 'sdk', 'java', 'src'), - "-d", self.docdest, + '-sourcepath', srcdir, + '-encoding', 'UTF-8', + '-charset', 'UTF-8', + '-docencoding', 'UTF-8', + '--allow-script-in-comments', + '-header', +''' + +''' % 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0', + '-bottom', 'Generated on %s / OpenCV %s' % (time.strftime("%Y-%m-%d %H:%M:%S"), self.opencv_version), + "-d", dstdir, "-classpath", ":".join(classpaths), '-subpackages', 'org.opencv', ]