1# Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15r"""Generate python docs for tf.lite. 16 17# How to run 18 19``` 20python build_docs.py --output_dir=/path/to/output 21``` 22 23""" 24 25import pathlib 26 27from absl import app 28from absl import flags 29 30import tensorflow as tf 31 32from tensorflow_docs.api_generator import generate_lib 33 34flags.DEFINE_string('output_dir', '/tmp/lite_api/', 35 'The path to output the files to') 36 37flags.DEFINE_string('code_url_prefix', 38 'https://github.com/tensorflow/tensorflow/blob/master/', 39 'The url prefix for links to code.') 40 41flags.DEFINE_bool('search_hints', True, 42 'Include metadata search hints in the generated files') 43 44flags.DEFINE_string('site_path', 'lite/api_docs/python', 45 'Path prefix in the _toc.yaml') 46 47FLAGS = flags.FLAGS 48 49 50def main(_): 51 doc_generator = generate_lib.DocGenerator( 52 root_title='TensorFlow Lite', 53 py_modules=[('tf.lite', tf.lite)], 54 base_dir=str(pathlib.Path(tf.__file__).parent), 55 code_url_prefix=FLAGS.code_url_prefix, 56 search_hints=FLAGS.search_hints, 57 site_path=FLAGS.site_path, 58 callbacks=[]) 59 60 doc_generator.build(output_dir=FLAGS.output_dir) 61 62 63if __name__ == '__main__': 64 app.run(main) 65