Internal change

PiperOrigin-RevId: 488796090
This commit is contained in:
Mark McDonald 2022-11-15 16:58:38 -08:00 committed by Copybara-Service
parent 7e19bbe35c
commit 6702ef3d57
2 changed files with 17 additions and 17 deletions

View File

@ -17,6 +17,7 @@ py_binary(
name = "build_java_api_docs", name = "build_java_api_docs",
srcs = ["build_java_api_docs.py"], srcs = ["build_java_api_docs.py"],
data = [ data = [
"//third_party/android/sdk:api/26.txt",
"//third_party/java/doclava/current:doclava.jar", "//third_party/java/doclava/current:doclava.jar",
"//third_party/java/jsilver:jsilver_jar", "//third_party/java/jsilver:jsilver_jar",
], ],

View File

@ -20,10 +20,6 @@ from absl import flags
from tensorflow_docs.api_generator import gen_java from tensorflow_docs.api_generator import gen_java
_JAVA_ROOT = flags.DEFINE_string('java_src', None,
'Override the Java source path.',
required=False)
_OUT_DIR = flags.DEFINE_string('output_dir', '/tmp/mp_java/', _OUT_DIR = flags.DEFINE_string('output_dir', '/tmp/mp_java/',
'Write docs here.') 'Write docs here.')
@ -37,27 +33,30 @@ _ = flags.DEFINE_bool(
'search_hints', True, 'search_hints', True,
'[UNUSED] Include metadata search hints in the generated files') '[UNUSED] Include metadata search hints in the generated files')
_ANDROID_SDK = pathlib.Path('android/sdk/api/26.txt')
def main(_) -> None: def main(_) -> None:
if not (java_root := _JAVA_ROOT.value):
# Default to using a relative path to find the Java source. # Default to using a relative path to find the Java source.
mp_root = pathlib.Path(__file__) mp_root = pathlib.Path(__file__)
while (mp_root := mp_root.parent).name != 'mediapipe': while (mp_root := mp_root.parent).name != 'mediapipe':
# Find the nearest `mediapipe` dir. # Find the nearest `mediapipe` dir.
pass pass
# Find the root from which all packages are relative.
root = mp_root.parent
# Externally, parts of the repo are nested inside a mediapipe/ directory # Externally, parts of the repo are nested inside a mediapipe/ directory
# that does not exist internally. Support both. # that does not exist internally. Support both.
if (mp_root / 'mediapipe').exists(): if (mp_root / 'mediapipe').exists():
mp_root = mp_root / 'mediapipe' mp_root = mp_root / 'mediapipe'
java_root = mp_root / 'tasks/java'
gen_java.gen_java_docs( gen_java.gen_java_docs(
package='com.google.mediapipe', package='com.google.mediapipe',
source_path=pathlib.Path(java_root), source_path=mp_root / 'tasks/java',
output_dir=pathlib.Path(_OUT_DIR.value), output_dir=pathlib.Path(_OUT_DIR.value),
site_path=pathlib.Path(_SITE_PATH.value)) site_path=pathlib.Path(_SITE_PATH.value),
federated_docs={'https://developer.android.com': root / _ANDROID_SDK})
if __name__ == '__main__': if __name__ == '__main__':