Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 398102324
  • Loading branch information
MarkDaoust authored and ramakumar1729 committed Oct 18, 2021
1 parent b4ffd52 commit 25fddf9
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Docs

licenses(["notice"])

py_binary(
name = "build_docs",
srcs = ["build_docs.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
# py/absl:app dep,
# py/absl/flags dep,
# py/tensorflow_docs/api_generator:generate_lib dep,
# py/tensorflow_ranking dep,
],
)
71 changes: 71 additions & 0 deletions docs/build_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2021 The TensorFlow Ranking Authors.
#
# 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.

r"""Generates api_docs for tensorflow_ranking.
```shell
pip install git+http://github.com/tensorflow/docs
python build_docs.py --output_dir=/tmp/tfr_api
```
"""

import os

from absl import app
from absl import flags

from tensorflow_docs.api_generator import generate_lib
from tensorflow_docs.api_generator import public_api

import tensorflow_ranking as tfr

# Hide these from the documentation. Nobody should be accessing things through
# `tfr.python.*` and `tfr.extension.*`
del tfr.python
del tfr.extension

# `losses_impl` and `metrics_impl` are not available under tfr namespace, see
# `dir(tfr)` for available APIs. These must be removed from the documentation.
del tfr.losses_impl
del tfr.losses.losses_impl
del tfr.metrics_impl
del tfr.metrics.metrics_impl

FLAGS = flags.FLAGS


def build_docs(output_dir):
"""Build api docs for tensorflow_datasets."""
doc_generator = generate_lib.DocGenerator(
root_title="TensorFlow Ranking",
py_modules=[("tfr", tfr)],
base_dir=os.path.dirname(tfr.__file__),
search_hints=True,
code_url_prefix="https://github.com/tensorflow/ranking/tree/master/tensorflow_ranking",
site_path="ranking/api_docs/python",
callbacks=[public_api.local_definitions_filter])

doc_generator.build(output_dir)


def _main(_):
build_docs(FLAGS.output_dir)


if __name__ == "__main__":
flags.DEFINE_string("output_dir",
"/tmp/tfr_api",
"Output directory.")

app.run(_main)

0 comments on commit 25fddf9

Please sign in to comment.