@@ -226,6 +226,51 @@ update_package_meta_data() {
226226 return 0
227227}
228228
229+ # Updates namespace table of contents.
230+ update_namespace_tocs () {
231+ local files
232+
233+ echo ' Updating namespace table of contents...' >&2
234+
235+ echo ' ' >&2
236+ echo ' Resolving list of namespace READMEs...' >&2
237+ files=$( make list-pkgs-namespace-readmes | tr ' \n' ' ' )
238+ if [[ " $? " -ne 0 ]]; then
239+ echo ' ' >&2
240+ echo ' Error: unexpected error. Encountered an error when resolving a list of namespace READMEs.' >&2
241+ echo ' ' >&2
242+ return 1
243+ fi
244+ echo ' Successfully resolved namespace READMEs.' >&2
245+
246+ echo ' ' >&2
247+ echo ' Updating READMEs...' >&2
248+ make FILES=" ${files} " markdown-namespace-tocs-files
249+ if [[ " $? " -ne 0 ]]; then
250+ echo ' ' >&2
251+ echo ' Error: unexpected error. Encountered an error when updating namespace READMEs.' >&2
252+ echo ' ' >&2
253+ return 1
254+ fi
255+ echo ' Successfully updated READMEs.' >&2
256+
257+ if [[ -n " $( git status --porcelain) " ]]; then
258+ echo ' ' >&2
259+ echo ' Committing changes...' >&2
260+ git add -A && git commit -m ' Update namespace ToCs'
261+ if [[ " $? " -ne 0 ]]; then
262+ echo ' ' >&2
263+ echo ' Error: unexpected error. Unable to commit changes.' >&2
264+ echo ' ' >&2
265+ return 1
266+ fi
267+ echo ' Successfully committed changes.' >&2
268+ fi
269+ echo ' ' >&2
270+
271+ return 0
272+ }
273+
229274# Updates package URLs in Markdown files.
230275update_markdown_package_urls () {
231276 echo ' Updating package URLs in Markdown files...' >&2
@@ -482,6 +527,11 @@ main() {
482527 revert_changes
483528 on_error 1
484529 fi
530+ update_namespace_tocs
531+ if [[ " $? " -ne 0 ]]; then
532+ revert_changes
533+ on_error 1
534+ fi
485535 update_markdown_package_urls
486536 if [[ " $? " -ne 0 ]]; then
487537 revert_changes
0 commit comments