예제 #1
0
 def test_translation_project_and_version_and_page_htmldir(self):
     proj = Project.objects.get(slug='pip-fr')
     proj.documentation_type = 'sphinx_htmldir'
     url = core_tags.make_document_url(proj, 'abc', 'xyz')
     self.assertEqual(url, '/docs/pip/fr/abc/xyz/')
     url = core_tags.make_document_url(proj, 'abc', 'index')
     self.assertEqual(url, '/docs/pip/fr/abc/')
예제 #2
0
 def test_project_and_version_singlehtml(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'sphinx_singlehtml'
     url = core_tags.make_document_url(proj, 'abc')
     self.assertEqual(url, '/docs/pip/en/abc/')
     url = core_tags.make_document_url(proj, 'abc', '')
     self.assertEqual(url, '/docs/pip/en/abc/')
예제 #3
0
 def test_project_and_version_and_page_htmldir(self):
     proj = Project.objects.get(slug="pip")
     proj.documentation_type = "sphinx_htmldir"
     url = core_tags.make_document_url(proj, "abc", "xyz")
     self.assertEqual(url, "/docs/pip/en/abc/xyz/")
     url = core_tags.make_document_url(proj, "abc", "index")
     self.assertEqual(url, "/docs/pip/en/abc/")
예제 #4
0
 def test_translation_project_only_singlehtml(self):
     proj = Project.objects.get(slug='pip-fr')
     proj.documentation_type = 'sphinx_singlehtml'
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, '/docs/pip/fr/latest/')
     url = core_tags.make_document_url(proj, '')
     self.assertEqual(url, '/docs/pip/fr/latest/')
예제 #5
0
 def test_project_only_singlehtml(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'sphinx_singlehtml'
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, '/docs/pip/en/latest/')
     url = core_tags.make_document_url(proj, '')
     self.assertEqual(url, '/docs/pip/en/latest/')
예제 #6
0
 def test_project_and_version_htmldir(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'sphinx_htmldir'
     url = core_tags.make_document_url(proj, 'abc')
     self.assertEqual(url, '/docs/pip/en/abc/')
     url = core_tags.make_document_url(proj, 'abc', '')
     self.assertEqual(url, '/docs/pip/en/abc/')
예제 #7
0
 def test_translation_project_and_version_singlehtml(self):
     proj = Project.objects.get(slug='pip-fr')
     proj.documentation_type = 'sphinx_singlehtml'
     url = core_tags.make_document_url(proj, 'abc')
     self.assertEqual(url, '/docs/pip/fr/abc/')
     url = core_tags.make_document_url(proj, 'abc', '')
     self.assertEqual(url, '/docs/pip/fr/abc/')
예제 #8
0
 def test_translation_project_and_version_and_page_singlehtml(self):
     proj = Project.objects.get(slug="pip-fr")
     proj.documentation_type = "sphinx_singlehtml"
     url = core_tags.make_document_url(proj, "abc", "xyz")
     self.assertEqual(url, "/docs/pip/fr/abc/index.html#document-xyz")
     url = core_tags.make_document_url(proj, "abc", "index")
     self.assertEqual(url, "/docs/pip/fr/abc/")
예제 #9
0
 def test_translation_project_and_version_htmldir(self):
     proj = Project.objects.get(slug='pip-fr')
     proj.documentation_type = 'sphinx_htmldir'
     url = core_tags.make_document_url(proj, 'abc')
     self.assertEqual(url, '/docs/pip/fr/abc/')
     url = core_tags.make_document_url(proj, 'abc', '')
     self.assertEqual(url, '/docs/pip/fr/abc/')
예제 #10
0
 def test_project_and_version_and_page_signlehtml(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'sphinx_singlehtml'
     url = core_tags.make_document_url(proj, 'abc', 'xyz')
     self.assertEqual(url, '/docs/pip/en/abc/index.html#document-xyz')
     url = core_tags.make_document_url(proj, 'abc', 'index')
     self.assertEqual(url, '/docs/pip/en/abc/')
예제 #11
0
 def test_translation_project_and_version_htmldir(self):
     proj = Project.objects.get(slug="pip-fr")
     proj.documentation_type = "sphinx_htmldir"
     url = core_tags.make_document_url(proj, "abc")
     self.assertEqual(url, "/docs/pip/fr/abc/")
     url = core_tags.make_document_url(proj, "abc", "")
     self.assertEqual(url, "/docs/pip/fr/abc/")
예제 #12
0
 def test_project_and_version_and_page_htmldir(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'sphinx_htmldir'
     url = core_tags.make_document_url(proj, 'abc', 'xyz')
     self.assertEqual(url, '/docs/pip/en/abc/xyz/')
     url = core_tags.make_document_url(proj, 'abc', 'index')
     self.assertEqual(url, '/docs/pip/en/abc/')
예제 #13
0
 def test_translation_project_and_version_and_page_singlehtml(self):
     proj = Project.objects.get(slug='pip-fr')
     proj.documentation_type = 'sphinx_singlehtml'
     url = core_tags.make_document_url(proj, 'abc', 'xyz')
     self.assertEqual(url, '/docs/pip/fr/abc/index.html#document-xyz')
     url = core_tags.make_document_url(proj, 'abc', 'index')
     self.assertEqual(url, '/docs/pip/fr/abc/')
예제 #14
0
 def test_project_and_version_singlehtml(self):
     proj = Project.objects.get(slug="pip")
     proj.documentation_type = "sphinx_singlehtml"
     url = core_tags.make_document_url(proj, "abc")
     self.assertEqual(url, "/docs/pip/en/abc/")
     url = core_tags.make_document_url(proj, "abc", "")
     self.assertEqual(url, "/docs/pip/en/abc/")
예제 #15
0
 def test_translation_project_only_singlehtml(self):
     proj = Project.objects.get(slug="pip-fr")
     proj.documentation_type = "sphinx_singlehtml"
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, "/docs/pip/fr/latest/")
     url = core_tags.make_document_url(proj, "")
     self.assertEqual(url, "/docs/pip/fr/latest/")
예제 #16
0
 def test_project_only_htmldir(self):
     proj = Project.objects.get(slug="pip")
     proj.documentation_type = "sphinx_htmldir"
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, "/docs/pip/en/latest/")
     url = core_tags.make_document_url(proj, "")
     self.assertEqual(url, "/docs/pip/en/latest/")
예제 #17
0
 def test_project_only_htmldir(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'sphinx_htmldir'
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, '/docs/pip/en/latest/')
     url = core_tags.make_document_url(proj, '')
     self.assertEqual(url, '/docs/pip/en/latest/')
예제 #18
0
 def test_translation_project_only_htmldir(self):
     proj = Project.objects.get(slug='pip-fr')
     proj.documentation_type = 'sphinx_htmldir'
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, '/docs/pip/fr/latest/')
     url = core_tags.make_document_url(proj, '')
     self.assertEqual(url, '/docs/pip/fr/latest/')
예제 #19
0
def docurl(request):
    """
    Get the url that a slug resolves to.

    Example::

        GET https://readthedocs.org/api/v2/docurl/?project=requests&version=latest&doc=index

    """
    project = request.GET.get("project")
    version = request.GET.get("version", "latest")
    doc = request.GET.get("doc", "index")

    project = get_object_or_404(Project, slug=project)
    version = get_object_or_404(Version.objects.public(request.user, project=project, only_active=False), slug=version)
    return Response({"url": make_document_url(project=project, version=version.slug, page=doc)})
예제 #20
0
def docurl(request):
    """
    Get the url that a slug resolves to.

    Example::

        GET https://readthedocs.org/api/v2/docurl/?project=requests&version=latest&doc=index

    """
    project = request.GET.get('project')
    version = request.GET.get('version', LATEST)
    doc = request.GET.get('doc', 'index')

    project = get_object_or_404(Project, slug=project)
    version = get_object_or_404(Version.objects.public(request.user,
                                                       project=project,
                                                       only_active=False),
                                slug=version)
    return Response({
        'url':
        make_document_url(project=project, version=version.slug, page=doc)
    })
예제 #21
0
 def test_translation_project_and_version_and_page(self):
     proj = Project.objects.get(slug="pip-fr")
     url = core_tags.make_document_url(proj, "abc", "xyz")
     self.assertEqual(url, "/docs/pip/fr/abc/xyz.html")
     url = core_tags.make_document_url(proj, "abc", "index")
     self.assertEqual(url, "/docs/pip/fr/abc/")
예제 #22
0
 def test_project_only(self):
     proj = Project.objects.get(slug="pip")
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, "/docs/pip/en/latest/")
     url = core_tags.make_document_url(proj, "")
     self.assertEqual(url, "/docs/pip/en/latest/")
예제 #23
0
 def test_translation_project_only(self):
     proj = Project.objects.get(slug='pip-fr')
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, '/docs/pip/fr/latest/')
     url = core_tags.make_document_url(proj, '')
     self.assertEqual(url, '/docs/pip/fr/latest/')
예제 #24
0
 def test_translation_project_and_version_and_page(self):
     proj = Project.objects.get(slug='pip-fr')
     url = core_tags.make_document_url(proj, 'abc', 'xyz')
     self.assertEqual(url, '/docs/pip/fr/abc/xyz.html')
     url = core_tags.make_document_url(proj, 'abc', 'index')
     self.assertEqual(url, '/docs/pip/fr/abc/')
예제 #25
0
 def test_project_and_version(self):
     proj = Project.objects.get(slug="pip")
     url = core_tags.make_document_url(proj, "abc")
     self.assertEqual(url, "/docs/pip/en/abc/")
     url = core_tags.make_document_url(proj, "abc", "")
     self.assertEqual(url, "/docs/pip/en/abc/")
예제 #26
0
 def test_mkdocs_index_no_directory_urls(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'mkdocs'
     url = core_tags.make_document_url(proj, LATEST, 'index.html')
     self.assertEqual(url, '/docs/pip/en/latest/')
예제 #27
0
 def test_project_and_version_and_page(self):
     proj = Project.objects.get(slug='pip')
     url = core_tags.make_document_url(proj, 'abc', 'xyz')
     self.assertEqual(url, '/docs/pip/en/abc/xyz.html')
     url = core_tags.make_document_url(proj, 'abc', 'index')
     self.assertEqual(url, '/docs/pip/en/abc/')
예제 #28
0
 def test_project_and_version(self):
     proj = Project.objects.get(slug='pip')
     url = core_tags.make_document_url(proj, 'abc')
     self.assertEqual(url, '/docs/pip/en/abc/')
     url = core_tags.make_document_url(proj, 'abc', '')
     self.assertEqual(url, '/docs/pip/en/abc/')
예제 #29
0
 def test_translation_project_and_version(self):
     proj = Project.objects.get(slug='pip-fr')
     url = core_tags.make_document_url(proj, 'abc')
     self.assertEqual(url, '/docs/pip/fr/abc/')
     url = core_tags.make_document_url(proj, 'abc', '')
     self.assertEqual(url, '/docs/pip/fr/abc/')
예제 #30
0
 def test_translation_project_only(self):
     proj = Project.objects.get(slug='pip-fr')
     url = core_tags.make_document_url(proj)
     self.assertEqual(url, '/docs/pip/fr/latest/')
     url = core_tags.make_document_url(proj, '')
     self.assertEqual(url, '/docs/pip/fr/latest/')
예제 #31
0
 def test_mkdocs_index(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'mkdocs'
     url = core_tags.make_document_url(proj, 'latest', 'index')
     self.assertEqual(url, '/docs/pip/en/latest/')
예제 #32
0
 def test_mkdocs_index_no_directory_urls(self):
     proj = Project.objects.get(slug='pip')
     proj.documentation_type = 'mkdocs'
     url = core_tags.make_document_url(proj, LATEST, 'index.html')
     self.assertEqual(url, '/docs/pip/en/latest/')