diff --git a/tensorflow/tools/docs/generate.py b/tensorflow/tools/docs/generate.py index 39b2abaae5e..099c24ed34c 100644 --- a/tensorflow/tools/docs/generate.py +++ b/tensorflow/tools/docs/generate.py @@ -21,6 +21,7 @@ from __future__ import print_function import argparse import inspect import os +import sys import six import tensorflow as tf @@ -301,7 +302,7 @@ class UpdateTags(py_guide_parser.PyGuideParser): """Rewrites a Python guide so that each section has an explicit tag.""" def process_section(self, line_number, section_title, tag): - self.replace_line(line_number, '## %s {#%s}' % (section_title, tag)) + self.replace_line(line_number, '## %s' % (section_title, tag)) def other_docs(src_dir, output_dir, visitor, doc_index): @@ -342,7 +343,7 @@ def other_docs(src_dir, output_dir, visitor, doc_index): output = parser.replace_references( md_string, relative_path_to_root, visitor.duplicate_of, - visitor.index, doc_index) + doc_index=doc_index, index=visitor.index) open(full_out_path, 'w').write(header + output) print('Done.') @@ -394,3 +395,6 @@ if __name__ == '__main__': flags, _ = argument_parser.parse_known_args() _main(flags.src_dir, flags.output_dir, flags.base_dir) + if parser.all_errors: + print('Errors during processing:' + '\n '.join(parser.all_errors)) + sys.exit(1) diff --git a/tensorflow/tools/docs/parser.py b/tensorflow/tools/docs/parser.py index ccfa40bc07d..3f48319cad1 100644 --- a/tensorflow/tools/docs/parser.py +++ b/tensorflow/tools/docs/parser.py @@ -33,6 +33,14 @@ IDENTIFIER_RE = '[a-zA-Z_][a-zA-Z0-9_]*' # A regular expression for capturing a @{symbol} reference. SYMBOL_REFERENCE_RE = re.compile(r'@\{([^}]+)\}') +# Log of all reported errors +all_errors = [] + + +def log_error(s): + all_errors.append(s) + print('ERROR:', s) + def documentation_path(full_name): """Returns the file path for the documentation for the given API symbol. @@ -185,7 +193,7 @@ def _one_ref(string, relative_path_to_root, duplicate_of, doc_index, index): return '[%s](%s%s)' % ( link_text, os.path.join(relative_path_to_root, doc_index[string].url), hash_tag) - print('ERROR: Handle doc reference "@{%s}"' % string) + log_error('Handle doc reference "@{%s}"' % string) return 'TODO:%s' % string elif string.startswith('tf'): # Python symbol @@ -203,11 +211,11 @@ def _one_ref(string, relative_path_to_root, duplicate_of, doc_index, index): elif string == 'tensorflow::ops::Const': ret = 'CONST_URL' else: - print('ERROR: Handle C++ reference "@{%s}"' % string) + log_error('Handle C++ reference "@{%s}"' % string) return 'TODO_C++:%s' % string return '[`%s`](%s)' % (link_text, os.path.join(relative_path_to_root, ret)) # Error! - print('ERROR: Did not understand "@{%s}"' % string) + log_error('Did not understand "@{%s}"' % string) return 'ERROR:%s' % string