Exemple #1
0
 def read(self):
     """
     Read and decode a single file and return the data. Returns content
     with relative links modified as per `source_path`
     """
     content = OriginalFileInput.read(self)
     return fix_relative_links(content, self.source_path)
Exemple #2
0
 def read(self):
     """
     Read and decode a single file and return the data. Returns content
     with relative links modified as per `source_path`
     """
     content = OriginalFileInput.read(self)
     return fix_relative_links(content, self.source_path, self.relative_source_path)
Exemple #3
0
 def test_with_rst(self):
     """Tests whether reStructuredText's links are modified correctly"""
     rst_content = '`title<docs/directory/file>`'
     source_path = os.path.join(os.pardir, 'README.rst')
     new_content = linkfix.fix_relative_links(rst_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '`title     <directory/file>`')
Exemple #4
0
 def test_with_markdown(self):
     """Tests whether markdown links are modified correctly"""
     md_content = '[title](docs/directory/file.md)'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '[title   ](directory/file.html)')
Exemple #5
0
 def test_static_path_subproject(self):
     md_content = '![icon](docs/_static/images/login.png)'
     source_path = os.path.join(os.pardir, 'README.md')
     abs_source_path = os.path.join('subrepo', 'README.md')
     new_content = linkfix.fix_relative_links(md_content, abs_source_path,
                                              source_path)
     self.assertEqual(new_content,
                      '![icon](../../_static/images/login.png)')
Exemple #6
0
 def test_static_path_depth2(self):
     md_content = '![icon](docs/_static/images/login.png)'
     source_path = os.path.join(os.pardir, os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path, source_path)
     self.assertEqual(new_content, '![icon     ](_static/images/login.png)')
Exemple #7
0
 def test_with_image(self):
     md_content = '![icon](app/src/icons/launcher.png)'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path, source_path)
     self.assertEqual(new_content, '![icon](../app/src/icons/launcher.png)')
Exemple #8
0
 def test_with_html(self):
     html_content = '<img src="docs/directory/file">'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(html_content, source_path, source_path)
     self.assertEqual(new_content, '<img src="directory/file.html">')
Exemple #9
0
 def test_with_rst(self):
     """Tests whether reStructuredText's links are modified correctly"""
     rst_content = '`title<docs/directory/file>`'
     source_path = os.path.join(os.pardir, 'README.rst')
     new_content = linkfix.fix_relative_links(rst_content, source_path, source_path)
     self.assertEqual(new_content, '`title     <directory/file>`')
Exemple #10
0
 def test_with_markdown(self):
     """Tests whether markdown links are modified correctly"""
     md_content = '[title](docs/directory/file.md)'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path, source_path)
     self.assertEqual(new_content, '[title   ](directory/file.html)')
Exemple #11
0
 def test_local_rst_link(self):
     md_content = '`title<#section>`'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path, source_path)
     self.assertEqual(new_content, '`title<#section>`')
Exemple #12
0
 def test_local_markdown_link(self):
     md_content = '[title](#section)'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path, source_path)
     self.assertEqual(new_content, '[title](#section)')
Exemple #13
0
 def test_static_path_subproject(self):
     md_content = '![icon](docs/_static/images/login.png)'
     source_path = os.path.join(os.pardir, 'README.md')
     abs_source_path = os.path.join('subrepo', 'README.md')
     new_content = linkfix.fix_relative_links(md_content, abs_source_path, source_path)
     self.assertEqual(new_content, '![icon](../../_static/images/login.png)')
Exemple #14
0
 def test_with_image(self):
     md_content = '![icon](app/src/icons/launcher.png)'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '![icon](../app/src/icons/launcher.png)')
Exemple #15
0
 def test_with_html(self):
     html_content = '<img src="docs/directory/file">'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(html_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '<img src="directory/file.html">')
Exemple #16
0
 def test_local_rst_link(self):
     md_content = '`title<#section>`'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '`title<#section>`')
Exemple #17
0
 def test_local_markdown_link(self):
     md_content = '[title](#section)'
     source_path = os.path.join(os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '[title](#section)')
Exemple #18
0
 def test_static_path_depth2(self):
     md_content = '![icon](docs/_static/images/login.png)'
     source_path = os.path.join(os.pardir, os.pardir, 'README.md')
     new_content = linkfix.fix_relative_links(md_content, source_path,
                                              source_path)
     self.assertEqual(new_content, '![icon     ](_static/images/login.png)')