Exemple #1
0
 def test_get_url_from_path_percent_sign_path(self):
     prj = self._prj()
     sd = SphinxDocs(prj.name)
     path = 'docs/doubanlib%2Fsqlstore.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/rstdocs/doubanlib%252Fsqlstore/'
     path = 'docs/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/rstdocs/%25E6%2580%25A7%25E8%2583%25BD%25E6%25B5%258B%25E8%25AF%2595/'  # noqa
Exemple #2
0
 def test_get_url_from_path_percent_sign_path(self):
     prj = self._prj()
     sd = SphinxDocs(prj.name)
     path = 'docs/doubanlib%2Fsqlstore.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/rstdocs/doubanlib%252Fsqlstore/'
     path = 'docs/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/rstdocs/%25E6%2580%25A7%25E8%2583%25BD%25E6%25B5%258B%25E8%25AF%2595/'  # noqa
Exemple #3
0
 def test_get_url_from_path_sphinx_doc_raw_builder_no_subdir(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         mydocs:
             dir: mydocsdir/3
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     path = 'mydocsdir/3/foo.bar'
     url = sd.get_url_from_path(path)
     assert url == 'docs/mydocs/foo.bar'
Exemple #4
0
 def test_get_url_from_path_sphinx_doc_raw_builder_no_subdir(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         mydocs:
             dir: mydocsdir/3
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     path = 'mydocsdir/3/foo.bar'
     url = sd.get_url_from_path(path)
     assert url == 'docs/mydocs/foo.bar'
Exemple #5
0
 def test_get_url_from_path_sphinx_doc_builder_pickle_subdir(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         mydocs:
             dir: mydocsdir
         pages:
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     path = 'mydocsdir/subdir/doc1.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/mydocs/subdir/doc1/'
Exemple #6
0
 def test_get_url_from_path_sphinx_doc_builder_pickle_subdir(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         mydocs:
             dir: mydocsdir
         pages:
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     path = 'mydocsdir/subdir/doc1.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/mydocs/subdir/doc1/'
Exemple #7
0
    def test_get_url_from_path_complex_src_dir(self):
        prj = self._prj()
        base_yaml_conf_two_builders = """
        docs:
            mypages:
                builder: raw
                dir: blog/output
                name: Blog
                sort: 1

        """
        self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
        sd = SphinxDocs(prj.name)
        path = 'blog/output/doc1.html'
        url = sd.get_url_from_path(path)
        assert url == 'docs/mypages/doc1.html'
Exemple #8
0
    def test_get_url_from_path_doc_builder_raw(self):
        prj = self._prj()
        base_yaml_conf_two_builders = """
        docs:
            mydocs:
                dir: mydocsdir
            mypages:
                builder: raw
                dir: pages/1

        """
        self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
        sd = SphinxDocs(prj.name)
        path = 'pages/1/subdir/doc1.html'
        url = sd.get_url_from_path(path)
        assert url == 'docs/mypages/subdir/doc1.html'
Exemple #9
0
    def test_get_url_from_path_complex_src_dir(self):
        prj = self._prj()
        base_yaml_conf_two_builders = """
        docs:
            mypages:
                builder: raw
                dir: blog/output
                name: Blog
                sort: 1

        """
        self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
        sd = SphinxDocs(prj.name)
        path = 'blog/output/doc1.html'
        url = sd.get_url_from_path(path)
        assert url == 'docs/mypages/doc1.html'
Exemple #10
0
    def test_get_url_from_path_doc_builder_raw(self):
        prj = self._prj()
        base_yaml_conf_two_builders = """
        docs:
            mydocs:
                dir: mydocsdir
            mypages:
                builder: raw
                dir: pages/1

        """
        self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
        sd = SphinxDocs(prj.name)
        path = 'pages/1/subdir/doc1.html'
        url = sd.get_url_from_path(path)
        assert url == 'docs/mypages/subdir/doc1.html'
Exemple #11
0
 def test_get_url_from_path_sphinx_doc_builder_default(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         mypages:
             builder: raw
             dir: mypagesdir
             name: Pages
             sort: 1
         mariodocs:
             builder: html
             dir: htmldocs/1
             name: HTMLDocs
             sort: 2
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     path = 'htmldocs/1/index.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/mariodocs/index.html'
Exemple #12
0
 def test_get_url_from_path_sphinx_doc_builder_default(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         mypages:
             builder: raw
             dir: mypagesdir
             name: Pages
             sort: 1
         mariodocs:
             builder: html
             dir: htmldocs/1
             name: HTMLDocs
             sort: 2
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     path = 'htmldocs/1/index.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/mariodocs/index.html'
Exemple #13
0
 def _doc_file_as_dict(self, path, name, doc_dir):
     last_commit = self.repo.get_last_commit("HEAD", path)
     if not last_commit:
         return
     sd = SphinxDocs(project_name=self.project.name)
     data = {
         'type': 'docs',
         'description': '',
         'author': last_commit.author.name,
         'time': last_commit.time.strftime('%Y-%m-%dT%H:%M:%S'),
         'project_id': self.project.id,
         'project_name': self.project.name,
         'doc_name': name,
         'doc_dir': doc_dir,
         'url': sd.get_url_from_path(path)
     }
     blob = self.repo.get_file('HEAD', path)
     src = blob.data or ''
     if path.endswith('.html'):
         data['content'] = html_index_content(src)
     else:
         data['content'] = src
     return data
Exemple #14
0
 def test_get_url_from_path_old_conf(self):
     prj = self._prj()
     sd = SphinxDocs(prj.name)
     path = 'docs/index.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/rstdocs/index/'
Exemple #15
0
 def test_get_url_from_path_old_conf(self):
     prj = self._prj()
     sd = SphinxDocs(prj.name)
     path = 'docs/index.rst'
     url = sd.get_url_from_path(path)
     assert url == 'docs/rstdocs/index/'