Skip to content

Commit d155aaa

Browse files
committed
PiperOrigin-RevId: 222102227
1 parent eb6bf18 commit d155aaa

13 files changed

+217
-192
lines changed

site/en/install/source_windows.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ bazel build --config=opt --config=cuda --define=no_tensorflow_py_deps=true //ten
172172

173173
#### Bazel build options
174174

175-
Use this option when building to avoid issue with package creation: https://github.com/tensorflow/tensorflow/issues/22390
175+
Use this option when building to avoid issue with package creation:
176+
https://github.com/tensorflow/tensorflow/issues/22390
176177

177178
<pre class="devsite-terminal tfo-terminal-windows devsite-click-to-copy">
178179
--define=no_tensorflow_py_deps=true

site/en/lite/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ Welcome to the warp zone!
22

33
# TensorFlow Lite
44

5-
These docs are available here: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/g3doc
5+
These docs are available here:
6+
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/g3doc

site/en/tfx/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Welcome to the warp zone!
44

55
These docs are available here:
66

7-
* Data Validation: https://github.com/tensorflow/data-validation/tree/master/g3doc
8-
* Transform: https://github.com/tensorflow/transform/tree/master/docs
9-
* Model Analysis: https://github.com/tensorflow/model-analysis/tree/master/g3doc
7+
* Data Validation:
8+
https://github.com/tensorflow/data-validation/tree/master/g3doc
9+
* Transform: https://github.com/tensorflow/transform/tree/master/docs
10+
* Model Analysis:
11+
https://github.com/tensorflow/model-analysis/tree/master/g3doc

tools/release_tools/update_versions.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2015 The TensorFlow Authors. 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+
# ==============================================================================
115
"""Update tensorflow version in docs. Run this from the repo-root."""
216
import argparse
317
import re

tools/setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
# enum introduced in Python 3.4
5757
REQUIRED_PKGS.append('enum34')
5858

59-
print(find_packages())
60-
6159
setup(
6260
name=project_name,
6361
version=version,
@@ -68,7 +66,7 @@
6866
url='http://github.com/tensorflow/docs',
6967
download_url='https://github.com/tensorflow/docs/tags',
7068
license='Apache 2.0',
71-
packages= find_packages(),#['tensorflow_docs'],
69+
packages=find_packages(),
7270
scripts=[],
7371
install_requires=REQUIRED_PKGS,
7472
extras_require={

tools/tensorflow_docs/api_generator/doc_controls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def should_skip_class_attr(cls, name):
305305
return False
306306

307307
# for each parent class
308-
for parent in cls.__mro__[1:]:
308+
for parent in getattr(cls, "__mro__", [])[1:]:
309309
# if the class should be skipped, don't doc this object.
310310
if should_skip(parent):
311311
return True

tools/tensorflow_docs/api_generator/doc_generator_visitor.py

+26-21
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,35 @@
2626
class DocGeneratorVisitor(object):
2727
"""A visitor that generates docs for a python object when __call__ed."""
2828

29-
def __init__(self, root_name=''):
29+
def __init__(self):
3030
"""Make a visitor.
3131
32-
As this visitor is starting its traversal at a module or class, it will not
33-
be told the name of that object during traversal. `root_name` is the name it
34-
should use for that object, effectively prefixing all names with
35-
"root_name.".
36-
37-
Args:
38-
root_name: The name of the root module/class.
32+
This visitor expects to be called on each node in the api. It is passed the
33+
path to an object, the object, and the filtered list of the object's
34+
children. (see the `__call__` method for details.
35+
36+
This object accumulates the various data-structures necessary to build the
37+
docs, including (see the property definitions for details.):
38+
39+
In the decsription below "master name" is the object's preferred fully
40+
qualified name.
41+
42+
Params:
43+
index: A mapping from master names to python python objects.
44+
tree: A mapping from master names to a list if attribute names.
45+
reverse_index: Mapping from python object ids to master names.
46+
Note that this doesn't work for python numbers, strings or tuples.
47+
duplicate_of: A mapping from a fully qualified names to the object's
48+
master name. The master names are not included as keys.
49+
duplicates: A mapping from master names to lists of other fully qualified
50+
names for the object.
3951
"""
40-
self.set_root_name(root_name)
4152
self._index = {}
4253
self._tree = {}
4354
self._reverse_index = None
4455
self._duplicates = None
4556
self._duplicate_of = None
4657

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-
5258
@property
5359
def index(self):
5460
"""A map from fully qualified names to objects to be documented.
@@ -118,19 +124,16 @@ def duplicates(self):
118124
self._maybe_find_duplicates()
119125
return self._duplicates
120126

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-
125-
def __call__(self, parent_name, parent, children):
127+
def __call__(self, parent_path, parent, children):
126128
"""Visitor interface, see `tensorflow/tools/common:traverse` for details.
127129
128130
This method is called for each symbol found in a traversal using
129131
`tensorflow/tools/common:traverse`. It should not be called directly in
130132
user code.
131133
132134
Args:
133-
parent_name: The fully qualified name of a symbol found during traversal.
135+
parent_path: A tuple of strings. The fully qualified path to a symbol
136+
found during traversal.
134137
parent: The Python object referenced by `parent_name`.
135138
children: A list of `(name, py_object)` pairs enumerating, in alphabetical
136139
order, the children (as determined by `tf_inspect.getmembers`) of
@@ -140,7 +143,7 @@ def __call__(self, parent_name, parent, children):
140143
RuntimeError: If this visitor is called with a `parent` that is not a
141144
class or module.
142145
"""
143-
parent_name = self._add_prefix(parent_name)
146+
parent_name = '.'.join(parent_path)
144147
self._index[parent_name] = parent
145148
self._tree[parent_name] = []
146149

@@ -179,6 +182,8 @@ def _score_name(self, name):
179182
"""
180183
parts = name.split('.')
181184
short_name = parts[-1]
185+
if len(parts) == 1:
186+
return (-99, -99, -99, short_name)
182187

183188
container = self._index['.'.join(parts[:-1])]
184189

tools/tensorflow_docs/api_generator/doc_generator_visitor_test.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from __future__ import division
1919
from __future__ import print_function
2020

21+
import os
2122
import types
2223

2324
from absl.testing import absltest
@@ -41,7 +42,7 @@ class DocGeneratorVisitorTest(absltest.TestCase):
4142
def test_call_module(self):
4243
visitor = doc_generator_visitor.DocGeneratorVisitor()
4344
visitor(
44-
'doc_generator_visitor', doc_generator_visitor,
45+
('doc_generator_visitor',), doc_generator_visitor,
4546
[('DocGeneratorVisitor', doc_generator_visitor.DocGeneratorVisitor)])
4647

4748
self.assertEqual({'doc_generator_visitor': ['DocGeneratorVisitor']},
@@ -55,21 +56,22 @@ def test_call_module(self):
5556
def test_call_class(self):
5657
visitor = doc_generator_visitor.DocGeneratorVisitor()
5758
visitor(
58-
'DocGeneratorVisitor', doc_generator_visitor.DocGeneratorVisitor,
59-
[('index', doc_generator_visitor.DocGeneratorVisitor.index)])
59+
('DocGeneratorVisitor',), doc_generator_visitor.DocGeneratorVisitor,
60+
[('index', doc_generator_visitor.DocGeneratorVisitor.reverse_index)])
6061

6162
self.assertEqual({'DocGeneratorVisitor': ['index']},
6263
visitor.tree)
6364
self.assertEqual({
64-
'DocGeneratorVisitor': doc_generator_visitor.DocGeneratorVisitor,
65+
'DocGeneratorVisitor':
66+
doc_generator_visitor.DocGeneratorVisitor,
6567
'DocGeneratorVisitor.index':
66-
doc_generator_visitor.DocGeneratorVisitor.index
68+
doc_generator_visitor.DocGeneratorVisitor.reverse_index
6769
}, visitor.index)
6870

6971
def test_call_raises(self):
7072
visitor = doc_generator_visitor.DocGeneratorVisitor()
7173
with self.assertRaises(RuntimeError):
72-
visitor('non_class_or_module', 'non_class_or_module_object', [])
74+
visitor(('non_class_or_module',), 'non_class_or_module_object', [])
7375

7476
def test_duplicates_module_class_depth(self):
7577

@@ -79,12 +81,14 @@ class Nested(object):
7981
pass
8082

8183
tf = types.ModuleType('tf')
84+
tf.__file__ = '/tmp/tf/__init__.py'
8285
tf.Parent = Parent
8386
tf.submodule = types.ModuleType('submodule')
8487
tf.submodule.Parent = Parent
8588

8689
visitor = generate_lib.extract(
8790
[('tf', tf)],
91+
base_dir=os.path.dirname(tf.__file__),
8892
private_map={},
8993
do_not_descend_map={},
9094
visitor_cls=NoDunderVisitor)
@@ -120,13 +124,15 @@ class Parent(object):
120124
pass
121125

122126
tf = types.ModuleType('tf')
127+
tf.__file__ = '/tmp/tf/__init__.py'
123128
tf.contrib = types.ModuleType('contrib')
124129
tf.submodule = types.ModuleType('submodule')
125130
tf.contrib.Parent = Parent
126131
tf.submodule.Parent = Parent
127132

128133
visitor = generate_lib.extract(
129134
[('tf', tf)],
135+
base_dir=os.path.dirname(tf.__file__),
130136
private_map={},
131137
do_not_descend_map={},
132138
visitor_cls=NoDunderVisitor)
@@ -156,11 +162,13 @@ class Child(Parent):
156162
pass
157163

158164
tf = types.ModuleType('tf')
165+
tf.__file__ = '/tmp/tf/__init__.py'
159166
tf.Parent = Parent
160167
tf.Child = Child
161168

162169
visitor = generate_lib.extract(
163170
[('tf', tf)],
171+
base_dir=os.path.dirname(tf.__file__),
164172
private_map={},
165173
do_not_descend_map={},
166174
visitor_cls=NoDunderVisitor)
@@ -189,13 +197,15 @@ class Parent(object):
189197
pass
190198

191199
tf = types.ModuleType('tf')
200+
tf.__file__ = '/tmp/tf/__init__.py'
192201
tf.submodule = types.ModuleType('submodule')
193202
tf.submodule.submodule2 = types.ModuleType('submodule2')
194203
tf.Parent = Parent
195204
tf.submodule.submodule2.Parent = Parent
196205

197206
visitor = generate_lib.extract(
198207
[('tf', tf)],
208+
base_dir=os.path.dirname(tf.__file__),
199209
private_map={},
200210
do_not_descend_map={},
201211
visitor_cls=NoDunderVisitor)
@@ -223,11 +233,13 @@ class Parent(object):
223233
Parent.obj2 = Parent.obj1
224234

225235
tf = types.ModuleType('tf')
236+
tf.__file__ = '/tmp/tf/__init__.py'
226237
tf.submodule = types.ModuleType('submodule')
227238
tf.submodule.Parent = Parent
228239

229240
visitor = generate_lib.extract(
230241
[('tf', tf)],
242+
base_dir=os.path.dirname(tf.__file__),
231243
private_map={},
232244
do_not_descend_map={},
233245
visitor_cls=NoDunderVisitor)

0 commit comments

Comments
 (0)