2017-10-08 09:22:56 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_build_qthelp
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the Qt Help builder and check its output. We don't need to
|
|
|
|
test the HTML itself; that's already handled by
|
|
|
|
:file:`test_build_html.py`.
|
|
|
|
|
2017-12-31 10:10:10 -06:00
|
|
|
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
2017-10-08 09:22:56 -05:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
from sphinx.testing.util import etree_parse
|
|
|
|
|
2017-10-08 09:22:56 -05:00
|
|
|
|
2018-03-17 22:32:22 -05:00
|
|
|
@pytest.mark.sphinx('qthelp', testroot='basic')
|
|
|
|
def test_qthelp_basic(app, status, warning):
|
|
|
|
app.builder.build_all()
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
qhp = (app.outdir / 'Python.qhp').text()
|
|
|
|
assert '<customFilter name="Python ">' in qhp
|
|
|
|
assert '<filterAttribute>Python</filterAttribute>' in qhp
|
|
|
|
assert '<filterAttribute></filterAttribute>' in qhp
|
|
|
|
assert '<section title="Python documentation" ref="index.html">' in qhp
|
|
|
|
assert '<file>genindex.html</file>' in qhp
|
|
|
|
assert '<file>index.html</file>' in qhp
|
|
|
|
assert '<file>_static/basic.css</file>' in qhp
|
|
|
|
assert '<file>_static/down.png</file>' in qhp
|
|
|
|
|
2018-03-17 22:32:22 -05:00
|
|
|
qhcp = (app.outdir / 'Python.qhcp').text()
|
|
|
|
assert '<title>Python documentation</title>' in qhcp
|
|
|
|
assert '<homePage>qthelp://org.sphinx.python/doc/index.html</homePage>' in qhcp
|
|
|
|
assert '<startPage>qthelp://org.sphinx.python/doc/index.html</startPage>' in qhcp
|
|
|
|
assert '<input>Python.qhp</input>' in qhcp
|
|
|
|
assert '<output>Python.qch</output>' in qhcp
|
|
|
|
assert '<file>Python.qch</file>' in qhcp
|
|
|
|
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
@pytest.mark.sphinx('qthelp', testroot='need-escaped')
|
|
|
|
def test_qthelp_escaped(app, status, warning):
|
2018-03-17 22:32:23 -05:00
|
|
|
app.builder.build_all()
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
et = etree_parse(app.outdir / 'needbescapedbproject.qhp')
|
|
|
|
customFilter = et.find('.//customFilter')
|
|
|
|
assert len(customFilter) == 2
|
|
|
|
assert customFilter.attrib == {'name': 'need <b>"escaped"</b> project '}
|
|
|
|
assert customFilter[0].text == 'needbescapedbproject'
|
|
|
|
assert customFilter[1].text is None
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
toc = et.find('.//toc')
|
|
|
|
assert len(toc) == 1
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0].attrib == {'title': 'need <b>"escaped"</b> project documentation',
|
2018-03-17 22:32:23 -05:00
|
|
|
'ref': 'index.html'}
|
|
|
|
assert len(toc[0]) == 4
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0][0].attrib == {'title': '<foo>', 'ref': 'foo.html'}
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0][0][0].attrib == {'title': 'quux', 'ref': 'quux.html'}
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0][0][1].attrib == {'title': 'foo "1"', 'ref': 'foo.html#foo-1'}
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0][0][1][0].attrib == {'title': 'foo.1-1', 'ref': 'foo.html#foo-1-1'}
|
|
|
|
assert toc[0][0][2].attrib == {'title': 'foo.2', 'ref': 'foo.html#foo-2'}
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0][1].attrib == {'title': 'bar', 'ref': 'bar.html'}
|
2018-03-17 22:32:23 -05:00
|
|
|
assert toc[0][2].attrib == {'title': 'http://sphinx-doc.org/',
|
|
|
|
'ref': 'http://sphinx-doc.org/'}
|
|
|
|
assert toc[0][3].attrib == {'title': 'baz', 'ref': 'baz.html'}
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
keywords = et.find('.//keywords')
|
|
|
|
assert len(keywords) == 2
|
|
|
|
assert keywords[0].attrib == {'name': '<subsection>', 'ref': 'index.html#index-0'}
|
|
|
|
assert keywords[1].attrib == {'name': '"subsection"', 'ref': 'index.html#index-0'}
|
|
|
|
|
2018-03-17 22:32:23 -05:00
|
|
|
|
2017-10-08 09:22:56 -05:00
|
|
|
@pytest.mark.sphinx('qthelp', testroot='basic')
|
|
|
|
def test_qthelp_namespace(app, status, warning):
|
|
|
|
# default namespace
|
|
|
|
app.builder.build_all()
|
2018-03-17 22:32:22 -05:00
|
|
|
|
2017-10-08 09:22:56 -05:00
|
|
|
qhp = (app.outdir / 'Python.qhp').text()
|
|
|
|
assert '<namespace>org.sphinx.python</namespace>' in qhp
|
|
|
|
|
2018-03-17 22:32:22 -05:00
|
|
|
qhcp = (app.outdir / 'Python.qhcp').text()
|
|
|
|
assert '<homePage>qthelp://org.sphinx.python/doc/index.html</homePage>' in qhcp
|
|
|
|
assert '<startPage>qthelp://org.sphinx.python/doc/index.html</startPage>' in qhcp
|
|
|
|
|
2017-10-08 09:22:56 -05:00
|
|
|
# give a namespace
|
|
|
|
app.config.qthelp_namespace = 'org.sphinx-doc.sphinx'
|
|
|
|
app.builder.build_all()
|
2018-03-17 22:32:22 -05:00
|
|
|
|
2017-10-08 09:22:56 -05:00
|
|
|
qhp = (app.outdir / 'Python.qhp').text()
|
2018-06-16 04:33:09 -05:00
|
|
|
assert '<namespace>org.sphinx-doc.sphinx</namespace>' in qhp
|
2018-03-17 22:32:22 -05:00
|
|
|
|
|
|
|
qhcp = (app.outdir / 'Python.qhcp').text()
|
2018-06-16 04:33:09 -05:00
|
|
|
assert '<homePage>qthelp://org.sphinx-doc.sphinx/doc/index.html</homePage>' in qhcp
|
|
|
|
assert '<startPage>qthelp://org.sphinx-doc.sphinx/doc/index.html</startPage>' in qhcp
|
2018-03-17 22:32:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('qthelp', testroot='basic')
|
|
|
|
def test_qthelp_title(app, status, warning):
|
|
|
|
# default title
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
qhp = (app.outdir / 'Python.qhp').text()
|
|
|
|
assert '<section title="Python documentation" ref="index.html">' in qhp
|
|
|
|
|
|
|
|
qhcp = (app.outdir / 'Python.qhcp').text()
|
|
|
|
assert '<title>Python documentation</title>' in qhcp
|
|
|
|
|
|
|
|
# give a title
|
|
|
|
app.config.html_title = 'Sphinx <b>"full"</b> title'
|
|
|
|
app.config.html_short_title = 'Sphinx <b>"short"</b> title'
|
|
|
|
app.builder.build_all()
|
|
|
|
|
|
|
|
qhp = (app.outdir / 'Python.qhp').text()
|
2018-03-17 22:32:23 -05:00
|
|
|
assert ('<section title="Sphinx <b>"full"</b> title" ref="index.html">'
|
|
|
|
in qhp)
|
2018-03-17 22:32:22 -05:00
|
|
|
|
|
|
|
qhcp = (app.outdir / 'Python.qhcp').text()
|
2018-03-17 22:32:22 -05:00
|
|
|
assert '<title>Sphinx <b>"short"</b> title</title>' in qhcp
|