4646from tensorflow_docs .api_generator import generate_lib
4747from tensorflow_docs .api_generator import parser
4848from tensorflow_docs .api_generator import public_api
49+ from tensorflow_docs .api_generator import utils
4950
5051from tensorflow .python .util import tf_inspect
5152
53+
54+ # tfio doesn't eagerly import submodules.
55+ utils .recursive_import (tfio )
56+
5257# Use tensorflow's `tf_inspect`, which is aware of `tf_decorator`.
5358parser .tf_inspect = tf_inspect
5459
5964
6065flags .DEFINE_string (
6166 'git_branch' ,
62- default = 'master' ,
67+ default = None ,
6368 help = 'The name of the corresponding branch on github.' )
6469
70+ flags .DEFINE_string ("output_dir" , "/tmp/io_api" ,
71+ "Where to output the docs" )
72+
73+ CODE_PREFIX_TEMPLATE = "https://github.com/tensorflow/io/tree/{git_branch}/tensorflow_io"
6574flags .DEFINE_string (
66- 'output_dir' ,
67- default = 'docs/api_docs/python/' ,
68- help = 'Where to write the resulting docs to.' )
75+ "code_url_prefix" , None ,
76+ "The url prefix for links to the code." )
77+
78+ flags .DEFINE_bool ("search_hints" , True ,
79+ "Include metadata search hints in the generated files" )
80+
81+ flags .DEFINE_string ("site_path" , "io/api_docs/python" ,
82+ "Path prefix in the _toc.yaml" )
83+
84+ flags .mark_flags_as_mutual_exclusive (['code_url_prefix' , 'git_branch' ])
85+
6986
7087
7188def main (argv ):
7289 if argv [1 :]:
7390 raise ValueError ('Unrecognized arguments: {}' .format (argv [1 :]))
7491
75- code_url_prefix = ('https://github.com/tensorflow/io/tree/'
76- '{git_branch}/tensorflow_io' .format (
77- git_branch = FLAGS .git_branch ))
92+ if FLAGS .git_branch :
93+ code_url_prefix = CODE_PREFIX_TEMPLATE .format (git_branch = FLAGS .git_branch )
94+ elif FLAGS .code_url_prefix :
95+ code_url_prefix = FLAGS .code_url_prefix
96+ else :
97+ code_url_prefix = CODE_PREFIX_TEMPLATE .format (git_branch = 'master' )
7898
7999 doc_generator = generate_lib .DocGenerator (
80100 root_title = PROJECT_FULL_NAME ,
@@ -83,7 +103,9 @@ def main(argv):
83103 code_url_prefix = code_url_prefix ,
84104 private_map = {'tfio' : ['__version__' , 'utils' , 'version' ]},
85105 # This callback cleans up a lot of aliases caused by internal imports.
86- callbacks = [public_api .local_definitions_filter ])
106+ callbacks = [public_api .local_definitions_filter ],
107+ search_hints = FLAGS .search_hints ,
108+ site_path = FLAGS .site_path )
87109
88110 doc_generator .build (FLAGS .output_dir )
89111
0 commit comments