• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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# ==============================================================================
15"""Specifies sources of doc strings for API modules."""
16from __future__ import absolute_import
17from __future__ import division
18from __future__ import print_function
19
20import collections
21
22from tensorflow.python.util import tf_export
23
24
25# Specifies docstring source for a module.
26# Only one of docstring or docstring_module_name should be set.
27# * If docstring is set, then we will use this docstring when
28#   for the module.
29# * If docstring_module_name is set, then we will copy the docstring
30#   from docstring source module.
31DocSource = collections.namedtuple(
32    'DocSource', ['docstring', 'docstring_module_name'])
33# Each attribute of DocSource is optional.
34DocSource.__new__.__defaults__ = (None,) * len(DocSource._fields)
35
36_TENSORFLOW_DOC_SOURCES = {
37    'app': DocSource(docstring_module_name='platform.app'),
38    'bitwise': DocSource(docstring_module_name='ops.bitwise_ops'),
39    'compat': DocSource(docstring_module_name='util.compat'),
40    'distribute': DocSource(docstring_module_name='distribute.distribute_lib'),
41    'distributions': DocSource(
42        docstring_module_name='ops.distributions.distributions'),
43    'errors': DocSource(docstring_module_name='framework.errors'),
44    'gfile': DocSource(docstring_module_name='platform.gfile'),
45    'graph_util': DocSource(docstring_module_name='framework.graph_util'),
46    'image': DocSource(docstring_module_name='ops.image_ops'),
47    'keras.estimator': DocSource(docstring_module_name='keras.estimator'),
48    'linalg': DocSource(docstring_module_name='ops.linalg_ops'),
49    'logging': DocSource(docstring_module_name='ops.logging_ops'),
50    'losses': DocSource(docstring_module_name='ops.losses.losses'),
51    'manip': DocSource(docstring_module_name='ops.manip_ops'),
52    'math': DocSource(docstring_module_name='ops.math_ops'),
53    'metrics': DocSource(docstring_module_name='ops.metrics'),
54    'nn': DocSource(docstring_module_name='ops.nn_ops'),
55    'nn.rnn_cell': DocSource(docstring_module_name='ops.rnn_cell'),
56    'python_io': DocSource(docstring_module_name='lib.io.python_io'),
57    'ragged': DocSource(docstring_module_name='ops.ragged'),
58    'resource_loader': DocSource(
59        docstring_module_name='platform.resource_loader'),
60    'sets': DocSource(docstring_module_name='ops.sets'),
61    'signal': DocSource(docstring_module_name='ops.signal.signal'),
62    'sparse': DocSource(docstring_module_name='ops.sparse_ops'),
63    'strings': DocSource(docstring_module_name='ops.string_ops'),
64    'summary': DocSource(docstring_module_name='summary.summary'),
65    'sysconfig': DocSource(docstring_module_name='platform.sysconfig'),
66    'test': DocSource(docstring_module_name='platform.test'),
67    'train': DocSource(docstring_module_name='training.training'),
68}
69
70_ESTIMATOR_DOC_SOURCES = {
71    'estimator': DocSource(
72        docstring_module_name='estimator_lib'),
73    'estimator.export': DocSource(
74        docstring_module_name='export.export_lib'),
75    'estimator.inputs': DocSource(
76        docstring_module_name='inputs.inputs'),
77}
78
79
80def get_doc_sources(api_name):
81  """Get a map from module to a DocSource object.
82
83  Args:
84    api_name: API you want to generate (e.g. `tensorflow` or `estimator`).
85
86  Returns:
87    Map from module name to DocSource object.
88  """
89  if api_name == tf_export.TENSORFLOW_API_NAME:
90    return _TENSORFLOW_DOC_SOURCES
91  if api_name == tf_export.ESTIMATOR_API_NAME:
92    return _ESTIMATOR_DOC_SOURCES
93  return {}
94