• 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
20from tensorflow.python.util import tf_export
21
22
23class DocSource(object):
24  """Specifies docstring source for a module.
25
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.
31  """
32
33  def __init__(self, docstring=None, docstring_module_name=None):
34    self.docstring = docstring
35    self.docstring_module_name = docstring_module_name
36
37    if self.docstring is not None and self.docstring_module_name is not None:
38      raise ValueError('Only one of `docstring` or `docstring_module_name` can '
39                       'be set.')
40
41
42_TENSORFLOW_DOC_SOURCES = {
43    'app': DocSource(docstring_module_name='platform.app'),
44    'bitwise': DocSource(docstring_module_name='ops.bitwise_ops'),
45    'compat': DocSource(docstring_module_name='util.compat'),
46    'distribute': DocSource(docstring_module_name='distribute.distribute_lib'),
47    'distributions': DocSource(
48        docstring_module_name='ops.distributions.distributions'),
49    'errors': DocSource(docstring_module_name='framework.errors'),
50    'experimental.numpy': DocSource(docstring_module_name='ops.numpy_ops'),
51    'gfile': DocSource(docstring_module_name='platform.gfile'),
52    'graph_util': DocSource(docstring_module_name='framework.graph_util'),
53    'image': DocSource(docstring_module_name='ops.image_ops'),
54    'linalg': DocSource(docstring_module_name='ops.linalg_ops'),
55    'logging': DocSource(docstring_module_name='ops.logging_ops'),
56    'losses': DocSource(docstring_module_name='ops.losses.losses'),
57    'manip': DocSource(docstring_module_name='ops.manip_ops'),
58    'math': DocSource(docstring_module_name='ops.math_ops'),
59    'metrics': DocSource(docstring_module_name='ops.metrics'),
60    'nn': DocSource(docstring_module_name='ops.nn_ops'),
61    'nn.rnn_cell': DocSource(docstring_module_name='ops.rnn_cell'),
62    'python_io': DocSource(docstring_module_name='lib.io.python_io'),
63    'ragged': DocSource(docstring_module_name='ops.ragged'),
64    'resource_loader': DocSource(
65        docstring_module_name='platform.resource_loader'),
66    'sets': DocSource(docstring_module_name='ops.sets'),
67    'signal': DocSource(docstring_module_name='ops.signal.signal'),
68    'sparse': DocSource(docstring_module_name='ops.sparse_ops'),
69    'strings': DocSource(docstring_module_name='ops.string_ops'),
70    'summary': DocSource(docstring_module_name='summary.summary'),
71    'sysconfig': DocSource(docstring_module_name='platform.sysconfig'),
72    'test': DocSource(docstring_module_name='platform.test'),
73    'train': DocSource(docstring_module_name='training.training'),
74}
75
76_ESTIMATOR_DOC_SOURCES = {
77    'estimator': DocSource(
78        docstring_module_name='estimator_lib'),
79    'estimator.export': DocSource(
80        docstring_module_name='export.export_lib'),
81    'estimator.inputs': DocSource(
82        docstring_module_name='inputs.inputs'),
83}
84
85
86def get_doc_sources(api_name):
87  """Get a map from module to a DocSource object.
88
89  Args:
90    api_name: API you want to generate (e.g. `tensorflow` or `estimator`).
91
92  Returns:
93    Map from module name to DocSource object.
94  """
95  if api_name == tf_export.TENSORFLOW_API_NAME:
96    return _TENSORFLOW_DOC_SOURCES
97  if api_name == tf_export.ESTIMATOR_API_NAME:
98    return _ESTIMATOR_DOC_SOURCES
99  return {}
100