aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tools/docs/parser.py
diff options
context:
space:
mode:
authorGravatar Martin Wicke <wicke@google.com>2017-02-15 17:28:36 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-02-15 17:53:49 -0800
commit448e99d210097c1ebe61e1c6de2534db17f8d364 (patch)
treea6a3b0a23e164e355be63ed18da2e98f711c5e51 /tensorflow/tools/docs/parser.py
parent10eb6fc7a3c6b9825a1c970a65576afd8982526b (diff)
Fix broken links in "defined in" lines.
Change: 147666965
Diffstat (limited to 'tensorflow/tools/docs/parser.py')
-rw-r--r--tensorflow/tools/docs/parser.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tensorflow/tools/docs/parser.py b/tensorflow/tools/docs/parser.py
index 2269e8f364..f6be1561a4 100644
--- a/tensorflow/tools/docs/parser.py
+++ b/tensorflow/tools/docs/parser.py
@@ -836,12 +836,21 @@ def generate_markdown(full_name, py_object, duplicate_of, duplicates, index,
try:
path = os.path.relpath(path=inspect.getfile(py_object), start=base_dir)
- # TODO(wicke): If this is a generated file, point to the source instead.
+ # In case this is compiled, point to the original
+ if path.endswith('.pyc'):
+ path = path[:-1]
+ # TODO(wicke): If this is a generated file, link to the source instead.
+ # TODO(wicke): Move all generated files to a generated/ directory.
+ # TODO(wicke): And make their source file predictable from the file name.
# Never include links outside this code base.
if not path.startswith('..'):
- markdown += '\n\nDefined in [`tensorflow/%s`](%s%s).\n\n' % (
- path, _CODE_URL_PREFIX, path)
+ if re.match('.*/gen_[^/]*.py$', path):
+ # Generated file, don't incude a futile link.
+ markdown += '\n\nDefined in `tensorflow/%s`.\n\n' % path
+ else:
+ markdown += '\n\nDefined in [`tensorflow/%s`](%s%s).\n\n' % (
+ path, _CODE_URL_PREFIX, path)
except TypeError: # getfile throws TypeError if py_object is a builtin.
markdown += '\n\nThis is an alias for a Python built-in.'