aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tools/docs/generate_lib.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/tools/docs/generate_lib.py')
-rw-r--r--tensorflow/tools/docs/generate_lib.py29
1 files changed, 11 insertions, 18 deletions
diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py
index 483921fc2f..1cd9cb7ca9 100644
--- a/tensorflow/tools/docs/generate_lib.py
+++ b/tensorflow/tools/docs/generate_lib.py
@@ -36,23 +36,6 @@ from tensorflow.tools.docs import pretty_docs
from tensorflow.tools.docs import py_guide_parser
-def _is_free_function(py_object, full_name, index):
- """Check if input is a free function (and not a class- or static method)."""
- if not tf_inspect.isfunction(py_object):
- return False
-
- # Static methods are functions to tf_inspect (in 2.7), so check if the parent
- # is a class. If there is no parent, it's not a function.
- if '.' not in full_name:
- return False
-
- parent_name = full_name.rsplit('.', 1)[0]
- if tf_inspect.isclass(index[parent_name]):
- return False
-
- return True
-
-
def write_docs(output_dir,
parser_config,
yaml_toc,
@@ -109,7 +92,7 @@ def write_docs(output_dir,
# Methods and some routines are documented only as part of their class.
if not (tf_inspect.ismodule(py_object) or tf_inspect.isclass(py_object) or
- _is_free_function(py_object, full_name, parser_config.index)):
+ parser.is_free_function(py_object, full_name, parser_config.index)):
continue
sitepath = os.path.join('api_docs/python',
@@ -548,6 +531,13 @@ class DocGenerator(object):
help='The path from the site-root to api_docs'
'directory for this project')
+ self.argument_parser.add_argument(
+ '--api_cache_out_path',
+ type=str,
+ default=None,
+ help='Path to store a json-serialized api-index, so links can be '
+ 'inserted into docs without rebuilding the api_docs')
+
def add_output_dir_argument(self):
self.argument_parser.add_argument(
'--output_dir',
@@ -648,6 +638,9 @@ class DocGenerator(object):
visitor = self.run_extraction()
reference_resolver = self.make_reference_resolver(visitor, doc_index)
+ if getattr(flags, 'api_cache_out_path', None):
+ reference_resolver.to_json_file(flags.api_cache_out_path)
+
# Build the guide_index for the api_docs back links.
root_title = getattr(flags, 'root_title', 'TensorFlow')
guide_index = _build_guide_index(