22
22
23
23
import os
24
24
import pathlib
25
+ import re
25
26
import textwrap
26
27
27
28
from absl import app
36
37
37
38
import yaml
38
39
39
- # del google.ai.generativelanguage_v1beta2
40
-
41
40
google .ai .generativelanguage .__doc__ = """\
42
41
This package, `google.ai.generativelanguage`, is a low-level auto-generated client library for the PaLM API.
43
42
@@ -132,13 +131,15 @@ def drop_staticmethods(self, parent, children):
132
131
yield name , value
133
132
134
133
def __call__ (self , path , parent , children ):
135
- if "generativelanguage" in path or "generativeai" in path :
134
+ if (
135
+ any ("generativelanguage" in part for part in path )
136
+ or "generativeai" in path ):
136
137
children = self .filter_base_dirs (path , parent , children )
137
138
children = public_api .explicit_package_contents_filter (
138
139
path , parent , children
139
140
)
140
141
141
- if "generativelanguage" in path :
142
+ if any ( "generativelanguage" in part for part in path ) :
142
143
if "ServiceClient" in path [- 1 ]:
143
144
children = list (self .drop_staticmethods (parent , children ))
144
145
@@ -154,7 +155,7 @@ def make_default_filters(self):
154
155
public_api .add_proto_fields ,
155
156
public_api .filter_builtin_modules ,
156
157
public_api .filter_private_symbols ,
157
- MyFilter (self ._base_dir ), # public_api.FilterBaseDirs(self._base_dir),
158
+ MyFilter (self ._base_dir ), # Replaces: public_api.FilterBaseDirs(self._base_dir),
158
159
public_api .FilterPrivateMap (self ._private_map ),
159
160
public_api .filter_doc_controls_skip ,
160
161
public_api .ignore_typing ,
@@ -182,12 +183,10 @@ def gen_api_docs():
182
183
pathlib .Path (google .generativeai .__file__ ).parent ,
183
184
pathlib .Path (google .ai .generativelanguage .__file__ ).parent .parent ,
184
185
),
185
- code_url_prefix = (None , None ),
186
+ code_url_prefix = ('https://github.com/google/generative-ai-python/blob/master/google/generativeai' ,
187
+ 'https://github.com/googleapis/google-cloud-python/tree/main/packages/google-ai-generativelanguage/google/ai' ),
186
188
search_hints = _SEARCH_HINTS .value ,
187
189
site_path = _SITE_PATH .value ,
188
- # This callback ensures that docs are only generated for objects that
189
- # are explicitly imported in your __init__.py files. There are other
190
- # options but this is a good starting point.
191
190
callbacks = [],
192
191
)
193
192
@@ -213,6 +212,16 @@ def gen_api_docs():
213
212
redirects ["redirects" ].insert (0 , {"from" : "/api/python" , "to" : "/api/" })
214
213
redirects_path .write_text (yaml .dump (redirects ))
215
214
215
+ # clear `oneof` junk from proto pages
216
+ for fpath in out_path .rglob ('*.md' ):
217
+ old_content = fpath .read_text ()
218
+ new_content = old_content
219
+ new_content = re .sub (r'\.\. _oneof:.*?\n' , '' , new_content )
220
+ new_content = re .sub (r'`oneof`_.*?\n' , '' , new_content )
221
+ new_content = re .sub (r'\.\. code-block:: python.*?\n' , '' , new_content )
222
+ if new_content != old_content :
223
+ fpath .write_text (new_content )
224
+
216
225
print ("Output docs to: " , _OUTPUT_DIR .value )
217
226
218
227
0 commit comments