Skip to content

Commit c9066f2

Browse files
committed
Add docs generation script.
1 parent b54526c commit c9066f2

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tools/build_java_api_docs.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Lint as: python3
2+
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ==============================================================================
16+
"""Generate TensorFlow Lite Java reference docs for TensorFlow.org."""
17+
from __future__ import absolute_import
18+
from __future__ import division
19+
from __future__ import print_function
20+
21+
import pathlib
22+
import shutil
23+
import tempfile
24+
25+
from absl import app
26+
from absl import flags
27+
28+
from tensorflow_docs.api_generator import gen_java
29+
30+
FLAGS = flags.FLAGS
31+
32+
# These flags are required by infrastructure, not all of them are used.
33+
flags.DEFINE_string('output_dir', '/tmp/java_api/',
34+
("Use this branch as the root version and don't"
35+
' create in version directory'))
36+
37+
flags.DEFINE_string('site_path', 'java/api_docs/java',
38+
'Path prefix in the _toc.yaml')
39+
40+
flags.DEFINE_string('code_url_prefix', None,
41+
'[UNUSED] The url prefix for links to code.')
42+
43+
flags.DEFINE_bool(
44+
'search_hints', True,
45+
'[UNUSED] Include metadata search hints in the generated files')
46+
47+
# __file__ is the path to this file
48+
TOOLS_DIR = pathlib.Path(__file__).resolve().parent
49+
REPO_ROOT = TOOLS_DIR.parent
50+
51+
52+
def main(unused_argv):
53+
merged_source = pathlib.Path(tempfile.mkdtemp())
54+
(merged_source / 'java/org').mkdir(parents=True)
55+
56+
shutil.copytree(REPO_ROOT/'tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/',
57+
merged_source/'java/org/tensorflow')
58+
shutil.copytree(REPO_ROOT/'tensorflow-framework/src/main/java/org/tensorflow/framework',
59+
merged_source/'java/org/tensorflow/framework')
60+
shutil.copytree(REPO_ROOT/'ndarray/src/main/java/org/tensorflow/ndarray',
61+
merged_source/'java/org/tensorflow/ndarray')
62+
63+
gen_java.gen_java_docs(
64+
package='org.tensorflow',
65+
source_path=merged_source / 'java',
66+
output_dir=pathlib.Path(FLAGS.output_dir),
67+
site_path=pathlib.Path(FLAGS.site_path))
68+
69+
70+
if __name__ == '__main__':
71+
flags.mark_flags_as_required(['output_dir'])
72+
app.run(main)

0 commit comments

Comments
 (0)