コード例 #1
0
    def test_no_source_link(self):
        location = parser._FileLocation(rel_path="test")
        table = pretty_docs._top_source_link(location)

        expected = textwrap.dedent(f"""
       <table class="tfo-notebook-buttons tfo-api nocontent" align="left">

       </table>

       """)
        self.assertEqual(expected, table)
コード例 #2
0
    def test_other_source_link_after_table(self):
        url = "somewhere/else"
        location = parser._FileLocation(rel_path="test", url=url)
        table = pretty_docs._top_source_link(location)

        expected = textwrap.dedent(f"""
       <table class="tfo-notebook-buttons tfo-api nocontent" align="left">

       </table>

       <a target="_blank" href="{url}">View source</a>

       """)
        self.assertEqual(expected, table)
コード例 #3
0
    def test_github_source_link_in_table(self):
        url = "https://github.com/tensorflow/docs/blob/master/path/to/file"
        location = parser._FileLocation(rel_path="test", url=url)
        table = pretty_docs._top_source_link(location)

        expected = textwrap.dedent(f"""
        <table class="tfo-notebook-buttons tfo-api nocontent" align="left">
        <td>
          <a target="_blank" href="{url}">
            <img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" />
            View source on GitHub
          </a>
        </td>
        </table>

        """)
        self.assertEqual(expected, table)