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
This commit is contained in:
Mark McDonald 2022-11-10 19:36:37 -08:00 committed by Copybara-Service
parent 8c8b668ba3
commit d2284083b3

View File

@ -20,6 +20,10 @@ 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.')
@ -35,14 +39,17 @@ _ = flags.DEFINE_bool(
def main(_) -> None: def main(_) -> None:
if not (java_root := _JAVA_ROOT.value):
# 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
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=mp_root / 'java', source_path=pathlib.Path(java_root),
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))