Show raw ops pages, but hide them from search.

PiperOrigin-RevId: 294811206
Change-Id: Ia37cb4337e5370aa68832fe02596da87988ce684
This commit is contained in:
Mark Daoust 2020-02-12 18:51:22 -08:00 committed by TensorFlower Gardener
parent ad526e3816
commit f00437d811
2 changed files with 18 additions and 13 deletions

View File

@ -77,7 +77,6 @@ from tensorflow.python.util.deprecation import deprecated_args
from tensorflow.python.util.lazy_loader import LazyLoader
from tensorflow.python.util.tf_export import kwarg_only
from tensorflow.python.util.tf_export import tf_export
from tensorflow.tools.docs.doc_controls import do_not_generate_docs
ag_ctx = LazyLoader(
"ag_ctx", globals(),
@ -6606,8 +6605,7 @@ register_tensor_conversion_function = \
def to_raw_op(f):
"""Make a given op wrapper function `f` raw.
Raw op wrappers are not included in the docs, and can only be called
with keyword arguments.
Raw op wrappers can only be called with keyword arguments.
Args:
f: An op wrapper function to make raw.
@ -6619,7 +6617,7 @@ def to_raw_op(f):
# due to double-registration.
f = types.FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__,
f.__closure__)
return kwarg_only(do_not_generate_docs(f))
return kwarg_only(f)
def raise_from_not_ok_status(e, name):

View File

@ -36,17 +36,15 @@ import textwrap
from absl import app
from absl import flags
import tensorflow as tf
import tensorflow.compat.v2 as tf
from tensorflow_docs.api_generator import doc_controls
from tensorflow_docs.api_generator import doc_generator_visitor
from tensorflow_docs.api_generator import generate_lib
import tensorboard
import tensorflow_estimator
from tensorflow.python.framework import ops
from tensorflow.python.util import tf_export
from tensorflow.python.util import tf_inspect
@ -55,6 +53,11 @@ from tensorflow.python.util import tf_inspect
# So patch `tf.__all__` to list everything.
tf.__all__ = [item_name for item_name, value in tf_inspect.getmembers(tf)]
# tf_export generated two copies of the module objects.
# This will just list compat.v2 as an alias for tf. Close enough, let's not
# duplicate all the module skeleton files.
tf.compat.v2 = tf
FLAGS = flags.FLAGS
flags.DEFINE_string(
@ -103,7 +106,7 @@ def generate_raw_ops_doc():
| Op Name | Has Gradient |
|---------|:------------:|""")
parts = [tf.raw_ops.__doc__, warning, table_header]
parts = [warning, table_header]
for op_name in sorted(dir(tf.raw_ops)):
try:
@ -111,15 +114,16 @@ def generate_raw_ops_doc():
has_gradient = "\N{HEAVY CHECK MARK}\N{VARIATION SELECTOR-16}"
except LookupError:
has_gradient = "\N{CROSS MARK}"
parts.append("| {} | {} |".format(op_name, has_gradient))
link = (
'<a id={op_name} href="{FLAGS.site_path}/api_docs/python/tf/raw_ops">'
'{op_name}</a>').format(op_name=op_name, FLAGS=FLAGS.site_path)
parts.append(
"| {link} | {has_gradient} |".format(link=link,
has_gradient=has_gradient))
return "\n".join(parts)
tf.raw_ops.__doc__ = generate_raw_ops_doc()
# The doc generator isn't aware of tf_export.
# So prefix the score tuples with -1 when this is the canonical name, +1
# otherwise. The generator chooses the name with the lowest score.
@ -173,6 +177,9 @@ def build_docs(output_dir, code_url_prefix, search_hints=True):
code_url_prefix: prefix for "Defined in" links.
search_hints: Bool. Include meta-data search hints at the top of each file.
"""
# The custom page will be used for raw_ops.md not the one generated above.
doc_controls.custom_page_content(tf.raw_ops, generate_raw_ops_doc())
_hide_layer_and_module_methods()
try: