Skip to content

Commit b46ed63

Browse files
MarkDaoustcopybara-github
authored andcommitted
Add class="external" to the small_source_link.
+ actually fix api-gen test (that's howe the golden api_cache file got out of sync). PiperOrigin-RevId: 444814024
1 parent f5e0e0c commit b46ed63

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

tools/tensorflow_docs/api_generator/pretty_docs/base_page.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,14 @@ def top_source_link(location):
486486
return table
487487

488488

489-
def small_source_link(location):
489+
def small_source_link(location, text='View source'):
490490
"""Returns a small source link."""
491-
template = '<a target="_blank" href="{url}">View source</a>\n\n'
492-
493-
if not location.url:
491+
if location.url:
492+
return ('<a target="_blank" class="external" '
493+
f'href="{location.url}">{text}</a>\n\n')
494+
else:
494495
return ''
495496

496-
return template.format(url=location.url)
497-
498497

499498
def build_collapsable_aliases(aliases: List[str]) -> str:
500499
"""Returns the top "Aliases" line."""

tools/tensorflow_docs/api_generator/pretty_docs/pretty_docs_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_other_source_link_after_table(self):
5454
5555
</table>
5656
57-
<a target="_blank" href="{url}">View source</a>
57+
<a target="_blank" class="external" href="{url}">View source</a>
5858
5959
""")
6060
self.assertEqual(expected, table)

0 commit comments

Comments
 (0)