From d2284083b35cb9b8c2387e6f7365aa73004cbc96 Mon Sep 17 00:00:00 2001 From: Mark McDonald Date: Thu, 10 Nov 2022 19:36:37 -0800 Subject: [PATCH] Generate docs from `mediapipe/tasks/java`. The last CL used `mediapipe/java`, which is an old API. I've also added a flag to override the Java source location. This shouldn't be needed normally but makes local testing easier for both internal and external users. PiperOrigin-RevId: 487704937 --- docs/build_java_api_docs.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/build_java_api_docs.py b/docs/build_java_api_docs.py index 54e96aae..7b44e79f 100644 --- a/docs/build_java_api_docs.py +++ b/docs/build_java_api_docs.py @@ -20,6 +20,10 @@ from absl import flags 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/', 'Write docs here.') @@ -35,14 +39,17 @@ _ = flags.DEFINE_bool( def main(_) -> None: - mp_root = pathlib.Path(__file__) - while (mp_root := mp_root.parent).name != 'mediapipe': - # Find the nearest `mediapipe` dir. - pass + if not (java_root := _JAVA_ROOT.value): + # Default to using a relative path to find the Java source. + mp_root = pathlib.Path(__file__) + while (mp_root := mp_root.parent).name != 'mediapipe': + # Find the nearest `mediapipe` dir. + pass + java_root = mp_root / 'tasks/java' gen_java.gen_java_docs( package='com.google.mediapipe', - source_path=mp_root / 'java', + source_path=pathlib.Path(java_root), output_dir=pathlib.Path(_OUT_DIR.value), site_path=pathlib.Path(_SITE_PATH.value))