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
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
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'
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'
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/'
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/'
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'
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'
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'
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'
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'
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'
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
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/'
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/'