Skip to content

Commit f869fb0

Browse files
martinwicketensorflower-gardener
authored andcommitted
Add tf_debug docs. Seal debugger API.
Change: 147395124
1 parent 4514c71 commit f869fb0

5 files changed

Lines changed: 26 additions & 5 deletions

File tree

tensorflow/python/debug/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,8 @@
8080
from tensorflow.python.debug.wrappers.hooks import DumpingDebugHook
8181
from tensorflow.python.debug.wrappers.hooks import LocalCLIDebugHook
8282
from tensorflow.python.debug.wrappers.local_cli_wrapper import LocalCLIDebugWrapperSession
83+
84+
from tensorflow.python.util import all_util as _all_util
85+
86+
87+
_all_util.remove_undocumented(__name__)

tensorflow/tools/docs/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ py_binary(
6868
":parser",
6969
":py_guide_parser",
7070
"//tensorflow:tensorflow_py",
71+
"//tensorflow/python/debug:debug_py",
7172
"//tensorflow/tools/common:public_api",
7273
"//tensorflow/tools/common:traverse",
7374
],

tensorflow/tools/docs/doc_generator_visitor.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ def __init__(self, root_name=''):
3737
Args:
3838
root_name: The name of the root module/class.
3939
"""
40-
self._root_name = root_name or ''
41-
self._prefix = (root_name + '.') if root_name else ''
40+
self.set_root_name(root_name)
4241
self._index = {}
4342
self._tree = {}
4443
self._reverse_index = None
4544
self._duplicates = None
4645
self._duplicate_of = None
4746

47+
def set_root_name(self, root_name):
48+
"""Sets the root name for subsequent __call__s."""
49+
self._root_name = root_name or ''
50+
self._prefix = (root_name + '.') if root_name else ''
51+
4852
@property
4953
def index(self):
5054
"""A map from fully qualified names to objects to be documented.
@@ -114,6 +118,10 @@ def duplicates(self):
114118
self._maybe_find_duplicates()
115119
return self._duplicates
116120

121+
def _add_prefix(self, name):
122+
"""Adds the root name to a name."""
123+
return self._prefix + name if name else self._root_name
124+
117125
def __call__(self, parent_name, parent, children):
118126
"""Visitor interface, see `tensorflow/tools/common:traverse` for details.
119127
@@ -132,7 +140,7 @@ def __call__(self, parent_name, parent, children):
132140
RuntimeError: If this visitor is called with a `parent` that is not a
133141
class or module.
134142
"""
135-
parent_name = self._prefix + parent_name if parent_name else self._root_name
143+
parent_name = self._add_prefix(parent_name)
136144
self._index[parent_name] = parent
137145
self._tree[parent_name] = []
138146

tensorflow/tools/docs/generate.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import six
2727
import tensorflow as tf
2828

29+
from tensorflow.python import debug as tf_debug
30+
2931
from tensorflow.tools.common import public_api
3032
from tensorflow.tools.common import traverse
3133
from tensorflow.tools.docs import doc_generator_visitor
@@ -181,6 +183,10 @@ def extract():
181183

182184
traverse.traverse(tf, api_visitor)
183185

186+
# tf_debug is not imported with tf, it's a separate module altogether
187+
visitor.set_root_name('tfdbg')
188+
traverse.traverse(tf_debug, api_visitor)
189+
184190
return visitor
185191

186192

@@ -344,7 +350,8 @@ def other_docs(src_dir, output_dir, visitor, doc_index):
344350
output = parser.replace_references(
345351
md_string, relative_path_to_root, visitor.duplicate_of,
346352
doc_index=doc_index, index=visitor.index)
347-
open(full_out_path, 'w').write(header + output)
353+
with open(full_out_path, 'w') as f:
354+
f.write(header + output)
348355

349356
print('Done.')
350357

tensorflow/tools/docs/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _one_ref(string, relative_path_to_root, duplicate_of, doc_index, index):
196196
log_error('Handle doc reference "@{%s}"' % string)
197197
return 'TODO:%s' % string
198198

199-
elif string.startswith('tf'): # Python symbol
199+
elif string.startswith('tf.') or string.startswith('tfdbg.'): # Python symbol
200200
return _markdown_link(
201201
link_text, string, relative_path_to_root, duplicate_of, index)
202202
elif string.startswith('tensorflow::'): # C++ symbol

0 commit comments

Comments
 (0)