Skip to content

Commit ddea411

Browse files
Johannes Ballécopybara-github
authored andcommitted
Adds back API doc generation script.
PiperOrigin-RevId: 437857077 Change-Id: I189beaa9875e3201501cbcb39f6036a1227a5169
1 parent bceedf9 commit ddea411

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

build_docs.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2022 Google LLC. 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+
"""Generates API docs for the TensorFlow Compression library."""
16+
17+
import os
18+
from absl import app
19+
from absl import flags
20+
import tensorflow_compression as tfc
21+
from tensorflow_docs.api_generator import generate_lib
22+
23+
24+
_OUTPUT_DIR = flags.DEFINE_string(
25+
"output_dir", "/tmp/generated_docs",
26+
"Where to write the resulting docs.")
27+
_CODE_URL_PREFIX = flags.DEFINE_string(
28+
"code_url_prefix",
29+
"https://github.com/tensorflow/compression/tree/master/tensorflow_compression",
30+
"The URL prefix for links to code.")
31+
_SEARCH_HINTS = flags.DEFINE_bool(
32+
"search_hints", True,
33+
"Whether to include metadata search hints in the generated files.")
34+
_SITE_PATH = flags.DEFINE_string(
35+
"site_path", "/api_docs/python",
36+
"Path prefix in _toc.yaml.")
37+
38+
39+
def gen_api_docs():
40+
"""Generates API docs for the TensorFlow Compression library."""
41+
doc_generator = generate_lib.DocGenerator(
42+
root_title="TensorFlow Compression",
43+
py_modules=[("tfc", tfc)],
44+
base_dir=os.path.dirname(tfc.__file__),
45+
code_url_prefix=_CODE_URL_PREFIX.value,
46+
private_map=dict(
47+
tfc=["python"],
48+
),
49+
search_hints=_SEARCH_HINTS.value,
50+
site_path=_SITE_PATH.value,
51+
)
52+
doc_generator.build(_OUTPUT_DIR.value)
53+
print("Output docs to: ", _OUTPUT_DIR.value)
54+
55+
56+
def main(_):
57+
gen_api_docs()
58+
59+
60+
if __name__ == "__main__":
61+
app.run(main)

0 commit comments

Comments
 (0)