From 9f681d20e86e9b038cb327956b501ab5e76942eb Mon Sep 17 00:00:00 2001 From: Mark McDonald Date: Thu, 10 Nov 2022 17:00:00 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 487676791 --- docs/BUILD | 18 +++++++++++++ docs/build_java_api_docs.py | 51 +++++++++++++++++++++++++++++++++++++ docs/build_py_api_docs.py | 2 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 docs/build_java_api_docs.py diff --git a/docs/BUILD b/docs/BUILD index cb8794dab..ad08df66a 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -12,3 +12,21 @@ py_binary( "//third_party/py/tensorflow_docs/api_generator:public_api", ], ) + +py_binary( + name = "build_java_api_docs", + srcs = ["build_java_api_docs.py"], + data = [ + "//third_party/java/doclava/current:doclava.jar", + "//third_party/java/jsilver:jsilver_jar", + ], + env = { + "DOCLAVA_JAR": "$(location //third_party/java/doclava/current:doclava.jar)", + "JSILVER_JAR": "$(location //third_party/java/jsilver:jsilver_jar)", + }, + deps = [ + "//third_party/py/absl:app", + "//third_party/py/absl/flags", + "//third_party/py/tensorflow_docs/api_generator/gen_java", + ], +) diff --git a/docs/build_java_api_docs.py b/docs/build_java_api_docs.py new file mode 100644 index 000000000..54e96aae1 --- /dev/null +++ b/docs/build_java_api_docs.py @@ -0,0 +1,51 @@ +# Copyright 2022 The MediaPipe Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Generate Java reference docs for MediaPipe.""" +import pathlib + +from absl import app +from absl import flags + +from tensorflow_docs.api_generator import gen_java + +_OUT_DIR = flags.DEFINE_string('output_dir', '/tmp/mp_java/', + 'Write docs here.') + +_SITE_PATH = flags.DEFINE_string('site_path', '/mediapipe/api_docs/java', + 'Path prefix in the _toc.yaml') + +_ = flags.DEFINE_string('code_url_prefix', None, + '[UNUSED] The url prefix for links to code.') + +_ = flags.DEFINE_bool( + 'search_hints', True, + '[UNUSED] Include metadata search hints in the generated files') + + +def main(_) -> None: + mp_root = pathlib.Path(__file__) + while (mp_root := mp_root.parent).name != 'mediapipe': + # Find the nearest `mediapipe` dir. + pass + + gen_java.gen_java_docs( + package='com.google.mediapipe', + source_path=mp_root / 'java', + output_dir=pathlib.Path(_OUT_DIR.value), + site_path=pathlib.Path(_SITE_PATH.value)) + + +if __name__ == '__main__': + app.run(main) diff --git a/docs/build_py_api_docs.py b/docs/build_py_api_docs.py index 9911d0736..fa1e4314f 100644 --- a/docs/build_py_api_docs.py +++ b/docs/build_py_api_docs.py @@ -1,4 +1,4 @@ -# Copyright 2022 The TensorFlow Authors. All Rights Reserved. +# Copyright 2022 The MediaPipe Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.