|
49 | 49 |
|
50 | 50 | flags.DEFINE_string( |
51 | 51 | 'git_branch', |
52 | | - default='master', |
| 52 | + default=None, |
53 | 53 | help='The name of the corresponding branch on github.') |
54 | 54 |
|
55 | | -flags.DEFINE_string( |
56 | | - 'output_dir', |
57 | | - default='docs/api_docs/python/', |
58 | | - help='Where to write the resulting docs to.') |
| 55 | +CODE_PREFIX_TEMPLATE = "https://github.com/tensorflow/addons/tree/{git_branch}/tensorflow_addons" |
| 56 | +flags.DEFINE_string("code_url_prefix", None, |
| 57 | + "The url prefix for links to the code.") |
| 58 | +flags.mark_flags_as_mutual_exclusive(['code_url_prefix', 'git_branch']) |
| 59 | + |
| 60 | +flags.DEFINE_string("output_dir", "/tmp/addons_api", |
| 61 | + "Where to output the docs") |
| 62 | + |
| 63 | +flags.DEFINE_bool("search_hints", True, |
| 64 | + "Include metadata search hints in the generated files") |
| 65 | + |
| 66 | +flags.DEFINE_string("site_path", "addons/api_docs/python", |
| 67 | + "Path prefix in the _toc.yaml") |
59 | 68 |
|
60 | 69 |
|
61 | 70 | def main(argv): |
62 | 71 | if argv[1:]: |
63 | 72 | raise ValueError('Unrecognized arguments: {}'.format(argv[1:])) |
64 | 73 |
|
65 | | - code_url_prefix = ('https://github.com/tensorflow/addons/tree/' |
66 | | - '{git_branch}/tensorflow_addons'.format( |
67 | | - git_branch=FLAGS.git_branch)) |
| 74 | + if FLAGS.code_url_prefix: |
| 75 | + code_url_prefix = FLAGS.code_url_prefix |
| 76 | + elif FLAGS.git_branch: |
| 77 | + code_url_prefix = CODE_PREFIX_TEMPLATE.format( |
| 78 | + git_branch=FLAGS.git_branch) |
| 79 | + else: |
| 80 | + code_url_prefix = CODE_PREFIX_TEMPLATE.format(git_branch='master') |
68 | 81 |
|
69 | 82 | doc_generator = generate_lib.DocGenerator( |
70 | 83 | root_title=PROJECT_FULL_NAME, |
71 | | - # Replace `tensorflow_docs` with your module, here. |
72 | 84 | py_modules=[(PROJECT_SHORT_NAME, tfa)], |
73 | 85 | code_url_prefix=code_url_prefix, |
74 | 86 | private_map={'tfa': ['__version__', 'utils', 'version']}, |
75 | | - # This callback cleans up a lot of aliases caused by internal imports. |
76 | | - callbacks=[public_api.local_definitions_filter]) |
| 87 | + # This callback usually cleans up a lot of aliases caused by internal imports. |
| 88 | + callbacks=[public_api.local_definitions_filter], |
| 89 | + search_hints=FLAGS.search_hints, |
| 90 | + site_path=FLAGS.site_path) |
77 | 91 |
|
78 | 92 | doc_generator.build(FLAGS.output_dir) |
79 | 93 |
|
|
0 commit comments