message: Add support for running the doctest locally.
diff: @@ -36,15 +36,23 @@ import doctest # pylint: disable=g-import-not-at-top, g-bad-import-order
  FLAGS = flags.FLAGS
  -flags.DEFINE_string('module', '', 'A specific module to run doctest on.')
  -flags.DEFINE_boolean('list', False,
  +flags.DEFINE_string('module', None, 'A specific module to run doctest on.')
  +flags.DEFINE_boolean('list', None,
  'List all the modules in the core package imported.')
  +flags.DEFINE_string('file', None, 'A specific file to run doctest on.')
  +
  +flags.mark_flags_as_mutual_exclusive(['module', 'file'])
  +flags.mark_flags_as_mutual_exclusive(['list', 'file'])
  PACKAGE = 'tensorflow.python.'
  def find_modules():
  - """Finds all the modules in the core package imported."""
  + """Finds all the modules in the core package imported.
  +
  + Returns:
  + A list containing all the modules in tensorflow.python.
  + """
  tf_modules = []
  for name, module in sys.modules.items():
  @@ -76,6 +84,29 @@ def filter_on_submodules(all_modules, submodule):
  return filtered_modules
  +def get_module_and_inject_docstring(file_path):
  + """Replaces the docstring of the module with the changed file's content.
  +
  + Args:
  + file_path: Path to the file
  +
  + Returns:
  + A list containing the module changed by the file.
  + """
  +
  + file_path = os.path.abspath(file_path)
  + mod_index = file_path.find(PACKAGE.replace('.', os.sep))
  + file_mod_name, _ = os.path.splitext(file_path[mod_index:])
  + file_module = sys.modules[file_mod_name.replace(os.sep, '.')]
  +
  + with open(file_path, 'r') as f:
  + content = f.read()
  +
  + file_module.__doc__ = content
  +
  + return [file_module]
  +
  +
  class TfTestCase(tf.test.TestCase):
  def set_up(self, test):
  @@ -125,6 +156,9 @@ def load_tests(unused_loader, tests, unused_ignore):
  print('**************************************************')
  return tests
  + if FLAGS.file:
  + tf_modules = get_module_and_inject_docstring(FLAGS.file)
  +
  for module in tf_modules:
  testcase = TfTestCase()
  tests.addTests(
  