Home | History | Annotate | Download | only in docs
      1 # Copyright 2015 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 """Generate docs for the TensorFlow Python API."""
     16 
     17 from __future__ import absolute_import
     18 from __future__ import division
     19 from __future__ import print_function
     20 
     21 import os
     22 import sys
     23 
     24 import tensorflow as tf
     25 
     26 from tensorflow.python import debug as tf_debug
     27 from tensorflow.python.util import tf_inspect
     28 from tensorflow.tools.docs import generate_lib
     29 
     30 if __name__ == '__main__':
     31   doc_generator = generate_lib.DocGenerator()
     32   doc_generator.add_output_dir_argument()
     33   doc_generator.add_src_dir_argument()
     34 
     35   # This doc generator works on the TensorFlow codebase. Since this script lives
     36   # at tensorflow/tools/docs, and all code is defined somewhere inside
     37   # tensorflow/, we can compute the base directory (two levels up), which is
     38   # valid unless we're trying to apply this to a different code base, or are
     39   # moving the script around.
     40   script_dir = os.path.dirname(tf_inspect.getfile(tf_inspect.currentframe()))
     41   default_base_dir = os.path.join(script_dir, '..', '..')
     42   doc_generator.add_base_dir_argument(default_base_dir)
     43 
     44   flags = doc_generator.parse_known_args()
     45 
     46   # Suppress documentation of some symbols that users should never use.
     47   del tf.layers.Layer.inbound_nodes
     48   del tf.layers.Layer.outbound_nodes
     49 
     50   # tf_debug is not imported with tf, it's a separate module altogether
     51   doc_generator.set_py_modules([('tf', tf), ('tfdbg', tf_debug)])
     52 
     53   sys.exit(doc_generator.build(flags))
     54