|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | # ============================================================================== |
15 | | -""" Modified from the tfdocs example api reference docs generation script. |
| 15 | +"""Modified from the tfdocs example api reference docs generation script. |
16 | 16 |
|
17 | 17 | This script generates API reference docs. |
18 | 18 |
|
|
31 | 31 | from absl import app |
32 | 32 | from absl import flags |
33 | 33 |
|
34 | | -import tensorflow_addons |
| 34 | +import tensorflow_addons as tfa |
| 35 | + |
35 | 36 | from tensorflow_docs.api_generator import generate_lib |
| 37 | +from tensorflow_docs.api_generator import parser |
36 | 38 | from tensorflow_docs.api_generator import public_api |
37 | 39 |
|
38 | | -PROJECT_SHORT_NAME = 'tfaddons' |
| 40 | +from tensorflow.python.util import tf_inspect |
| 41 | + |
| 42 | +# Use tensorflow's `tf_inspect`, which is aware of `tf_decorator`. |
| 43 | +parser.tf_inspect = tf_inspect |
| 44 | + |
| 45 | +PROJECT_SHORT_NAME = 'tfa' |
39 | 46 | PROJECT_FULL_NAME = 'TensorFlow Addons' |
40 | | -CODE_URL_PREFIX = 'https://github.com/tensorflow/addons/tree/master/tensorflow_addons' |
41 | 47 |
|
42 | 48 | FLAGS = flags.FLAGS |
43 | 49 |
|
| 50 | +flags.DEFINE_string( |
| 51 | + 'git_branch', |
| 52 | + default='master', |
| 53 | + help='The name of the corresponding branch on github.') |
| 54 | + |
44 | 55 | flags.DEFINE_string( |
45 | 56 | 'output_dir', |
46 | | - default='/addons/docs/api_docs/python/', |
| 57 | + default='docs/api_docs/python/', |
47 | 58 | help='Where to write the resulting docs to.') |
48 | 59 |
|
49 | 60 |
|
50 | 61 | def main(argv): |
51 | 62 | if argv[1:]: |
52 | 63 | raise ValueError('Unrecognized arguments: {}'.format(argv[1:])) |
53 | 64 |
|
| 65 | + code_url_prefix = ('https://github.com/tensorflow/addons/tree/' |
| 66 | + '{git_branch}/tensorflow_addons'.format( |
| 67 | + git_branch=FLAGS.git_branch)) |
| 68 | + |
54 | 69 | doc_generator = generate_lib.DocGenerator( |
55 | 70 | root_title=PROJECT_FULL_NAME, |
56 | 71 | # Replace `tensorflow_docs` with your module, here. |
57 | | - py_modules=[(PROJECT_SHORT_NAME, tensorflow_addons)], |
58 | | - code_url_prefix=CODE_URL_PREFIX, |
| 72 | + py_modules=[(PROJECT_SHORT_NAME, tfa)], |
| 73 | + code_url_prefix=code_url_prefix, |
| 74 | + private_map={'tfa': ['__version__', 'utils', 'version']}, |
59 | 75 | # This callback cleans up a lot of aliases caused by internal imports. |
60 | 76 | callbacks=[public_api.local_definitions_filter]) |
61 | 77 |
|
|
0 commit comments