Skip to content

Commit 935e671

Browse files
armando-fandangofacaiy
authored andcommitted
added API docs generator in build_docs.py (#196)
* added API docs generator in build_docs.py * added API docs generator in build_docs.py
1 parent a9ee66a commit 935e671

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tools/docs/build_docs.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright 2015 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+
# ==============================================================================
15+
""" Modified from the tfdocs example api reference docs generation script.
16+
17+
This script generates API reference docs.
18+
19+
Install pre-requisites:
20+
$> pip install -U git+https://github.com/tensorflow/docs
21+
$> pip install artifacts/tensorflow_addons-*.whl
22+
23+
Generate Docs:
24+
$> from the repo root run: python tools/docs/build_docs.py
25+
"""
26+
27+
from __future__ import absolute_import
28+
from __future__ import division
29+
from __future__ import print_function
30+
31+
from absl import app
32+
from absl import flags
33+
34+
import tensorflow_addons
35+
from tensorflow_docs.api_generator import generate_lib
36+
from tensorflow_docs.api_generator import public_api
37+
38+
PROJECT_SHORT_NAME = 'tfaddons'
39+
PROJECT_FULL_NAME = 'TensorFlow Addons'
40+
CODE_URL_PREFIX = 'https://github.com/tensorflow/addons/tree/master/tensorflow_addons'
41+
42+
FLAGS = flags.FLAGS
43+
44+
flags.DEFINE_string(
45+
'output_dir',
46+
default='/addons/docs/api_docs/python/',
47+
help='Where to write the resulting docs to.')
48+
49+
50+
def main(argv):
51+
if argv[1:]:
52+
raise ValueError('Unrecognized arguments: {}'.format(argv[1:]))
53+
54+
doc_generator = generate_lib.DocGenerator(
55+
root_title=PROJECT_FULL_NAME,
56+
# Replace `tensorflow_docs` with your module, here.
57+
py_modules=[(PROJECT_SHORT_NAME, tensorflow_addons)],
58+
code_url_prefix=CODE_URL_PREFIX,
59+
# This callback cleans up a lot of aliases caused by internal imports.
60+
callbacks=[public_api.local_definitions_filter])
61+
62+
doc_generator.build(FLAGS.output_dir)
63+
64+
print('Output docs to: ', FLAGS.output_dir)
65+
66+
67+
if __name__ == '__main__':
68+
app.run(main)

0 commit comments

Comments
 (0)