mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #1448: qthelp: Add new config value; qthelp_namespace
This commit is contained in:
parent
2839fc5f68
commit
1292089255
1
CHANGES
1
CHANGES
@ -35,6 +35,7 @@ Features added
|
||||
* #3973: epub: allow to override build date
|
||||
* #3972: epub: Sort manifest entries by filename
|
||||
* #4052: viewcode: Sort before highlighting module code
|
||||
* #1448: qthelp: Add new config value; :confval:`qthelp_namespace`
|
||||
|
||||
|
||||
Features removed
|
||||
|
@ -2074,6 +2074,11 @@ builder, the HTML options also apply where appropriate.
|
||||
|
||||
The basename for the qthelp file. It defaults to the :confval:`project` name.
|
||||
|
||||
.. confval:: qthelp_namespace
|
||||
|
||||
The namespace for the qthelp file. It defaults to
|
||||
``org.sphinx.<project_name>.<project_version>``.
|
||||
|
||||
.. confval:: qthelp_theme
|
||||
|
||||
The HTML theme for the qthelp output.
|
||||
|
@ -21,6 +21,7 @@ from docutils import nodes
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
from sphinx.config import string_classes
|
||||
from sphinx.environment.adapters.indexentries import IndexEntries
|
||||
from sphinx.util import force_decode, logging
|
||||
from sphinx.util.osutil import make_filename
|
||||
@ -199,7 +200,11 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
|
||||
# it seems that the "namespace" may not contain non-alphanumeric
|
||||
# characters, and more than one successive dot, or leading/trailing
|
||||
# dots, are also forbidden
|
||||
nspace = 'org.sphinx.%s.%s' % (outname, self.config.version)
|
||||
if self.config.qthelp_namespace:
|
||||
nspace = self.config.qthelp_namespace
|
||||
else:
|
||||
nspace = 'org.sphinx.%s.%s' % (outname, self.config.version)
|
||||
|
||||
nspace = re.sub('[^a-zA-Z0-9.]', '', nspace)
|
||||
nspace = re.sub(r'\.+', '.', nspace).strip('.')
|
||||
nspace = nspace.lower()
|
||||
@ -328,6 +333,7 @@ def setup(app):
|
||||
app.add_builder(QtHelpBuilder)
|
||||
|
||||
app.add_config_value('qthelp_basename', lambda self: make_filename(self.project), None)
|
||||
app.add_config_value('qthelp_namespace', None, 'html', string_classes)
|
||||
app.add_config_value('qthelp_theme', 'nonav', 'html')
|
||||
app.add_config_value('qthelp_theme_options', {}, 'html')
|
||||
|
||||
|
28
tests/test_build_qthelp.py
Normal file
28
tests/test_build_qthelp.py
Normal file
@ -0,0 +1,28 @@
|
||||
# -*- 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`.
|
||||
|
||||
:copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('qthelp', testroot='basic')
|
||||
def test_qthelp_namespace(app, status, warning):
|
||||
# default namespace
|
||||
app.builder.build_all()
|
||||
qhp = (app.outdir / 'Python.qhp').text()
|
||||
assert '<namespace>org.sphinx.python</namespace>' in qhp
|
||||
|
||||
# give a namespace
|
||||
app.config.qthelp_namespace = 'org.sphinx-doc.sphinx'
|
||||
app.builder.build_all()
|
||||
qhp = (app.outdir / 'Python.qhp').text()
|
||||
assert '<namespace>org.sphinxdoc.sphinx</namespace>' in qhp
|
Loading…
Reference in New Issue
Block a user