コード例 #1
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_create_with_index_and_doc_and_two_builders(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         html:
             dir: ''
             builder: html
         pickle:
             dir: ''
             builder: pickle
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     self._add(prj, 'index.rst', base_index_rst)
     self._add(prj, 'doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ['html', 'pickle']
     pickle_builder = sd.get_builder('pickle')
     assert pickle_builder.template
     doc = pickle_builder.template_data('', {})
     assert doc['title'] == 'Unit testing sphinx docs'
     html_builder = sd.get_builder('html')
     assert not html_builder.template
     raw = html_builder.raw_content('index.html', {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #2
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_two_builders_with_other_config_fmt(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         docs:
             builder: html
             html_theme: default
             html_short_title: testsub
             dir: html_docs
         pages:
             builder: raw
     """
     self._add(prj, "code_config.yaml", base_yaml_conf_two_builders)
     self._add(prj, "html_docs/index.rst", base_index_rst)
     self._add(prj, "html_docs/doc1.rst", base_document1_rst)
     self._add(prj, "pages/index.html", self.html1)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ["docs", "pages"]  # noqa Sorted alphabetically by default
     raw_builder = sd.get_builder("pages")
     doc = raw_builder.raw_content("index.html", {})
     assert doc == self.html1
     html_builder = sd.get_builder("docs")
     assert not html_builder.template
     raw = html_builder.raw_content("index.html", {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #3
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_two_builders_with_other_config_fmt(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     #sphinx_docs:
     #    dir: "docs"
     #    builders:
     #        - html:
     #            html_theme: default
     #            html_short_title: testsub
     #            dir: html_docs
     #        - raw:
     #            dir: pages
     docs:
         docs:
             builder: html
             html_theme: default
             html_short_title: testsub
             dir: html_docs
         pages:
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     self._add(prj, 'html_docs/index.rst', base_index_rst)
     self._add(prj, 'html_docs/doc1.rst', base_document1_rst)
     self._add(prj, 'pages/index.html', self.html1)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ['docs', 'pages']  # noqa Sorted alphabetically by default
     raw_builder = sd.get_builder('pages')
     doc = raw_builder.raw_content('index.html', {})
     assert doc == self.html1
     html_builder = sd.get_builder('docs')
     assert not html_builder.template
     raw = html_builder.raw_content('index.html', {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #4
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
    def test_html_and_raw_builders_in_different_dirs(self):
        prj = self._prj()
        base_yaml_conf_two_builders = """
docs:
    docs:
        builder: html
        html_short_title: testsub
        dir: html_docs
        html_theme: default
    pages:
        builder: raw
        dir: pages
"""
        self._add(prj, "code_config.yaml", base_yaml_conf_two_builders)
        self._add(prj, "html_docs/index.rst", base_index_rst)
        self._add(prj, "html_docs/doc1.rst", base_document1_rst)
        self._add(prj, "pages/index.html", self.html1)
        sd = SphinxDocs(prj.name)
        sd.build_all()
        assert sd.builders == ["docs", "pages"]
        raw_builder = sd.get_builder("pages")
        doc = raw_builder.raw_content("index.html", {})
        assert doc == self.html1
        html_builder = sd.get_builder("docs")
        assert not html_builder.template
        raw = html_builder.raw_content("index.html", {})
        assert "<h1>Unit testing sphinx docs" in raw
コード例 #5
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_create_with_index_and_doc_and_two_builders(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         docs:
             builder: html
             dir: ""
             html_theme: default
             html_short_title: testsub
         docs2:
             dir: ""
             builder: pickle
     """
     self._add(prj, "code_config.yaml", base_yaml_conf_two_builders)
     self._add(prj, "index.rst", base_index_rst)
     self._add(prj, "doc1.rst", base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ["docs", "docs2"]
     pickle_builder = sd.get_builder("docs2")
     assert pickle_builder.template
     doc = pickle_builder.template_data("", {})
     assert doc["title"] == "Unit testing sphinx docs"
     html_builder = sd.get_builder("docs")
     assert not html_builder.template
     raw = html_builder.raw_content("index.html", {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #6
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_html_and_raw_builders_in_different_dirs(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         html:
             dir: html_docs
             builder: html
         raw:
             builder: raw
             dir: pages
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     self._add(prj, 'html_docs/index.rst', base_index_rst)
     self._add(prj, 'html_docs/doc1.rst', base_document1_rst)
     self._add(prj, 'pages/index.html', self.html1)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ['html', 'raw']
     raw_builder = sd.get_builder('raw')
     doc = raw_builder.raw_content('index.html', {})
     assert doc == self.html1
     html_builder = sd.get_builder('html')
     assert not html_builder.template
     raw = html_builder.raw_content('index.html', {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #7
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_build_info(self):
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     bi = sd.last_build_info()
     assert bi['status'] == 'success'
コード例 #8
0
 def test_build_info(self):
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     bi = sd.last_build_info()
     assert bi['status'] == 'success'
コード例 #9
0
def check_sphinx_builds():
    for proj in get_origin_projects():
        try:
            docs = SphinxDocs(proj.name)
        except JagareError:
            continue
        if not docs.enabled or not docs.need_rebuild():
            continue
        sphinx_builds_add(docs)
コード例 #10
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_build_info(self):
     prj = self._prj()
     self._add(prj, "code_config.yaml", base_yaml_conf)
     self._add(prj, "index.rst", base_index_rst)
     self._add(prj, "doc1.rst", base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     bi = sd.last_build_info()
     assert bi["status"] == "success"
コード例 #11
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_create_with_index_and_doc(self):
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder()
     doc = builder.template_data('', {})
     assert doc['title'] == 'Unit testing sphinx docs'
コード例 #12
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_pages_no_docsdir(self):
     prj = self._prj()
     self._add(prj, "code_config.yaml", self.conf)
     self._add(prj, "pagesNOT_THE_SAME/index.html", self.html1)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.last_build_info()["status"] == "no_doc_dir_found"
     builder = sd.get_builder(sd.builders[0])
     assert builder.raw_content("index.html", {}) is False
コード例 #13
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
コード例 #14
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 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
コード例 #15
0
 def test_create_with_index_and_doc(self):
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder()
     doc = builder.template_data('', {})
     assert doc['title'] == 'Unit testing sphinx docs'
コード例 #16
0
ファイル: tasks.py プロジェクト: leeccong/code
def check_sphinx_builds():
    for proj in get_origin_projects():
        try:
            docs = SphinxDocs(proj.name)
        except JagareError:
            continue
        if not docs.enabled or not docs.need_rebuild():
            continue
        sphinx_builds_add(docs)
コード例 #17
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_create_with_index_and_doc(self):
     prj = self._prj()
     self._add(prj, "code_config.yaml", base_yaml_conf)
     self._add(prj, "index.rst", base_index_rst)
     self._add(prj, "doc1.rst", base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder("docs")
     doc = builder.template_data("", {})
     assert doc["title"] == "Unit testing sphinx docs"
コード例 #18
0
 def test_use_autodoc_not_configured(self):
     prj = self._prj()
     self._add(prj, 'docs/conf.py', self.conf_py)
     self._add(prj, 'docs/index.rst', self.index_rst)
     self._add(prj, 'testapi.py', self.api_py)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder()
     doc = builder.template_data('', {})
     assert "Test C docstring" not in doc['body']
コード例 #19
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_use_autodoc_not_configured(self):
     prj = self._prj()
     self._add(prj, 'docs/conf.py', self.conf_py)
     self._add(prj, 'docs/index.rst', self.index_rst)
     self._add(prj, 'testapi.py', self.api_py)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder()
     doc = builder.template_data('', {})
     assert "Test C docstring" not in doc['body']
コード例 #20
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_create_with_index_and_doc_and_conf_py(self):
     conf_content = """rst_epilog = 'Ahhhhhhhhhhhhhhhh la fin' """
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     self._add(prj, 'docs/conf.py', conf_content)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder()
     doc = builder.template_data('', {})
     assert 'Ahhhhhhhhhhhhhhhh' in doc['body']
コード例 #21
0
ファイル: settings.py プロジェクト: jackfrued/code-1
 def pages(self, request):
     user = request.user
     docs = SphinxDocs(self.proj_name)
     tdt = {
         'project': CodeDoubanProject.get_by_name(self.proj_name),
         'request': request,
         'user': user,
         'docs': docs,
         'last_build': docs.last_build_info(),
     }
     return st('settings/pages.html', **tdt)
コード例 #22
0
ファイル: settings.py プロジェクト: 000fan000/code
 def pages(self, request):
     user = request.user
     docs = SphinxDocs(self.proj_name)
     tdt = {
         'project': CodeDoubanProject.get_by_name(self.proj_name),
         'request': request,
         'user': user,
         'docs': docs,
         'last_build': docs.last_build_info(),
     }
     return st('settings/pages.html', **tdt)
コード例 #23
0
 def test_create_with_index_and_doc_and_conf_py(self):
     conf_content = """rst_epilog = 'Ahhhhhhhhhhhhhhhh la fin' """
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     self._add(prj, 'docs/conf.py', conf_content)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     builder = sd.get_builder()
     doc = builder.template_data('', {})
     assert 'Ahhhhhhhhhhhhhhhh' in doc['body']
コード例 #24
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_create_with_index_and_doc_and_get_again(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', base_yaml_conf)
     self._add(prj, 'index.rst', base_index_rst)
     self._add(prj, 'doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     sd2 = SphinxDocs(prj.name)
     builder = sd2.get_builder()
     assert builder.template
     doc = builder.template_data('', {})
     assert doc['title'] == 'Unit testing sphinx docs'
コード例 #25
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_need_rebuild(self):
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     sd = SphinxDocs(prj.name)
     assert sd.need_rebuild()
     sd.build_all()
     assert not sd.need_rebuild()
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)  # Bad, should not have to refresh object
     assert sd.need_rebuild()
     sd.build_all()
     assert not sd.need_rebuild()
コード例 #26
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'
コード例 #27
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 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'
コード例 #28
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_need_rebuild(self):
     prj = self._prj()
     self._add(prj, "code_config.yaml", base_yaml_conf)
     self._add(prj, "index.rst", base_index_rst)
     sd = SphinxDocs(prj.name)
     assert sd.need_rebuild()
     sd.build_all()
     assert not sd.need_rebuild()
     self._add(prj, "doc1.rst", base_document1_rst)
     sd = SphinxDocs(prj.name)  # Bad, should not have to refresh object
     assert sd.need_rebuild()
     sd.build_all()
     assert not sd.need_rebuild()
コード例 #29
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 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/'
コード例 #30
0
ファイル: sphinx_docs.py プロジェクト: jackfrued/code-1
 def _q_access(self, request):
     self.docs = SphinxDocs(self.proj)
     if not self.docs.enabled:
         raise TraversalError(
             "docs not enabled: %s" % self.docs.disabled_reason)
     self.builder_name, self.explicit_builder = guess_builder_from_path(
         self.docs.builders, self.proj, request.get_path())
     if self.explicit_builder:
         self.base_path = "/%s/docs/%s/" % (self.proj, self.builder_name)
     else:
         self.base_path = "/%s/docs/" % (self.proj)
     self.builder = self.docs.get_builder(self.builder_name)
     if not self.builder:
         raise TraversalError("Unknown builder")
コード例 #31
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/'
コード例 #32
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
    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'
コード例 #33
0
 def test_create_with_index_and_doc(self):
     prj = self._prj()
     #        self._add(prj, 'code_config.yaml', base_yaml_conf)
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     _el.CodeSearch.index_a_project_docs(prj.id)
     ds = _el.DocsSearch(prj.id)
     ret = ds._doc_file_as_dict('docs/doc1.rst', 'docs', 'docs')
     assert ret['doc_name'] == 'docs'
     assert ret['url'] == 'docs/rstdocs/doc1/'
     assert ret['content'] == base_document1_rst
     assert ret['type'] == 'docs'
     assert ret['doc_dir'] == 'docs'
     _el.CodeSearch.delete_a_project_docs(prj.id)
コード例 #34
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'
コード例 #35
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'
コード例 #36
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
    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'
コード例 #37
0
ファイル: test_search.py プロジェクト: leeccong/code
    def test_create_with_index_and_doc(self):
        prj = self._prj()
#        self._add(prj, 'code_config.yaml', base_yaml_conf)
        self._add(prj, 'docs/index.rst', base_index_rst)
        self._add(prj, 'docs/doc1.rst', base_document1_rst)
        sd = SphinxDocs(prj.name)
        sd.build_all()
        _el.CodeSearch.index_a_project_docs(prj.id)
        ds = _el.DocsSearch(prj.id)
        ret = ds._doc_file_as_dict('docs/doc1.rst', 'docs', 'docs')
        assert ret['doc_name'] == 'docs'
        assert ret['url'] == 'docs/rstdocs/doc1/'
        assert ret['content'] == base_document1_rst
        assert ret['type'] == 'docs'
        assert ret['doc_dir'] == 'docs'
        _el.CodeSearch.delete_a_project_docs(prj.id)
コード例 #38
0
ファイル: settings.py プロジェクト: 000fan000/code
 def sphinx_docs(self, request):
     user = request.user
     docs = SphinxDocs(self.proj_name)
     if request.get_form_var('force_rebuild') == 'mq':
         sphinx_builds_add(self.proj_name)
         return request.redirect(
             '/%s/settings/sphinx_docs' % self.proj_name)
     if request.get_form_var('force_rebuild') == 'direct':
         docs.build_all()
         return request.redirect(
             '/%s/settings/sphinx_docs' % self.proj_name)
     tdt = {
         'project': CodeDoubanProject.get_by_name(self.proj_name),
         'request': request,
         'enabled': docs.enabled,
         'last_build': docs.last_build_info(),
         'user': user,
     }
     return st('settings/sphinx_docs.html', **tdt)
コード例 #39
0
ファイル: settings.py プロジェクト: jackfrued/code-1
 def sphinx_docs(self, request):
     user = request.user
     docs = SphinxDocs(self.proj_name)
     if request.get_form_var('force_rebuild') == 'mq':
         sphinx_builds_add(self.proj_name)
         return request.redirect('/%s/settings/sphinx_docs' %
                                 self.proj_name)
     if request.get_form_var('force_rebuild') == 'direct':
         docs.build_all()
         return request.redirect('/%s/settings/sphinx_docs' %
                                 self.proj_name)
     tdt = {
         'project': CodeDoubanProject.get_by_name(self.proj_name),
         'request': request,
         'enabled': docs.enabled,
         'last_build': docs.last_build_info(),
         'user': user,
     }
     return st('settings/sphinx_docs.html', **tdt)
コード例 #40
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 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'
コード例 #41
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'
コード例 #42
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_create_disabled(self):
     prj = self._prj()
     conf = """
     sphinx_docs: ""
     docs:
         docs:
             builder: pickle
     """
     self._add(prj, 'code_config.yaml', conf)
     sd = SphinxDocs(prj.name)
     assert sd.enabled is True, "should be enabled by default"
コード例 #43
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_two_builders_with_other_config_fmt(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         docs:
             builder: html
             html_theme: default
             html_short_title: testsub
             dir: html_docs
         pages:
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     self._add(prj, 'html_docs/index.rst', base_index_rst)
     self._add(prj, 'html_docs/doc1.rst', base_document1_rst)
     self._add(prj, 'pages/index.html', self.html1)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ['docs', 'pages']  # noqa Sorted alphabetically by default
     raw_builder = sd.get_builder('pages')
     doc = raw_builder.raw_content('index.html', {})
     assert doc == self.html1
     html_builder = sd.get_builder('docs')
     assert not html_builder.template
     raw = html_builder.raw_content('index.html', {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #44
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
    def test_html_and_raw_builders_in_different_dirs(self):
        prj = self._prj()
        base_yaml_conf_two_builders = """
docs:
    docs:
        builder: html
        html_short_title: testsub
        dir: html_docs
        html_theme: default
    pages:
        builder: raw
        dir: pages
"""
        self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
        self._add(prj, 'html_docs/index.rst', base_index_rst)
        self._add(prj, 'html_docs/doc1.rst', base_document1_rst)
        self._add(prj, 'pages/index.html', self.html1)
        sd = SphinxDocs(prj.name)
        sd.build_all()
        assert sd.builders == ['docs', 'pages']
        raw_builder = sd.get_builder('pages')
        doc = raw_builder.raw_content('index.html', {})
        assert doc == self.html1
        html_builder = sd.get_builder('docs')
        assert not html_builder.template
        raw = html_builder.raw_content('index.html', {})
        assert "<h1>Unit testing sphinx docs" in raw
コード例 #45
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_create_with_index_and_doc_and_two_builders(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         docs:
             builder: html
             dir: ""
             html_theme: default
             html_short_title: testsub
         docs2:
             dir: ""
             builder: pickle
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     self._add(prj, 'index.rst', base_index_rst)
     self._add(prj, 'doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ['docs', 'docs2']
     pickle_builder = sd.get_builder('docs2')
     assert pickle_builder.template
     doc = pickle_builder.template_data('', {})
     assert doc['title'] == 'Unit testing sphinx docs'
     html_builder = sd.get_builder('docs')
     assert not html_builder.template
     raw = html_builder.raw_content('index.html', {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #46
0
 def test_html_and_raw_builders(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         html:
             dir: docs
             builder: html
         raw:
             dir: docs
             builder: raw
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/index.html', self.html1)
     self._add(prj, 'docs/doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.builders == ['html', 'raw']
     raw_builder = sd.get_builder('raw')
     doc = raw_builder.raw_content('index.html', {})
     assert doc == self.html1
     html_builder = sd.get_builder('html')
     assert not html_builder.template
     raw = html_builder.raw_content('index.html', {})
     assert "<h1>Unit testing sphinx docs" in raw
コード例 #47
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_pages_mode(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', self.conf)
     self._add(prj, 'pages/index.html', self.html1)
     sd = SphinxDocs(prj.name)
     assert sd.builders == ['pages']
     assert sd.last_build_info() is None
     sd.build_all()
     assert sd.last_build_info()['status'] == 'success'
     builder = sd.get_builder(sd.builders[0])
     assert builder.raw_content('index.html', {}) == self.html1
コード例 #48
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_create_with_index_and_doc_and_get_again(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', base_yaml_conf)
     self._add(prj, 'index.rst', base_index_rst)
     self._add(prj, 'doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     sd2 = SphinxDocs(prj.name)
     builder = sd2.get_builder('docs')
     assert builder.template
     doc = builder.template_data('', {})
     assert doc['title'] == 'Unit testing sphinx docs'
コード例 #49
0
ファイル: __init__.py プロジェクト: jackfrued/code-1
 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
コード例 #50
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_pages_no_docsdir(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', self.conf)
     self._add(prj, 'pagesNOT_THE_SAME/index.html', self.html1)
     sd = SphinxDocs(prj.name)
     sd.build_all()
     assert sd.last_build_info()['status'] == 'no_doc_dir_found'
     builder = sd.get_builder(sd.builders[0])
     assert builder.raw_content('index.html', {}) is False
コード例 #51
0
 def test_sort_key(self):
     prj = self._prj()
     base_yaml_conf_two_builders = """
     docs:
         docs:
             builder: html
             html_theme: default
             html_short_title: testsub
             sort: 2
         pages:
             builder: raw
             sort: 1
     """
     self._add(prj, 'code_config.yaml', base_yaml_conf_two_builders)
     sd = SphinxDocs(prj.name)
     assert sd.builders == ['pages', 'docs']
コード例 #52
0
ファイル: test_docs.py プロジェクト: sdgdsffdsfff/code-1
 def test_pages_mode(self):
     prj = self._prj()
     self._add(prj, "code_config.yaml", self.conf)
     self._add(prj, "pages/index.html", self.html1)
     sd = SphinxDocs(prj.name)
     assert sd.builders == ["pages"]
     assert sd.last_build_info() is None
     sd.build_all()
     assert sd.last_build_info()["status"] == "success"
     builder = sd.get_builder(sd.builders[0])
     assert builder.raw_content("index.html", {}) == self.html1
コード例 #53
0
ファイル: test_sphinx_docs.py プロジェクト: leeccong/code
 def test_pages_mode(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', self.conf)
     self._add(prj, 'pages/index.html', self.html1)
     sd = SphinxDocs(prj.name)
     assert sd.builders == [self.builder]
     assert sd.last_build_info() is None
     sd.build_all()
     assert sd.last_build_info()['status'] == 'success'
     builder = sd.get_builder(sd.builders[0])
     assert builder.raw_content('index.html', {}) == self.html1
コード例 #54
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_create_wrong(self):
     sd = SphinxDocs('unexisting_project')
     assert sd.enabled is False
コード例 #55
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_need_rebuild(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', base_yaml_conf)
     self._add(prj, 'index.rst', base_index_rst)
     sd = SphinxDocs(prj.name)
     assert sd.need_rebuild()
     sd.build_all()
     assert not sd.need_rebuild()
     self._add(prj, 'doc1.rst', base_document1_rst)
     sd = SphinxDocs(prj.name)  # Bad, should not have to refresh object
     assert sd.need_rebuild()
     sd.build_all()
     assert not sd.need_rebuild()
コード例 #56
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/'
コード例 #57
0
ファイル: test_docs.py プロジェクト: jackfrued/code-1
 def test_create_enabled(self):
     prj = self._prj()
     self._add(prj, 'code_config.yaml', base_yaml_conf)
     sd = SphinxDocs(prj.name)
     assert sd.enabled is True
コード例 #58
0
 def test_create_enabled(self):
     prj = self._prj()
     sd = SphinxDocs(prj.name)
     assert sd.enabled is True