From 448e99d210097c1ebe61e1c6de2534db17f8d364 Mon Sep 17 00:00:00 2001 From: Martin Wicke Date: Wed, 15 Feb 2017 17:28:36 -0800 Subject: Fix broken links in "defined in" lines. Change: 147666965 --- tensorflow/tools/docs/parser.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tensorflow/tools/docs/parser.py') 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.' -- cgit v1.2.3