mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5390 from tk0miya/4018_htmlhelp_file_suffix
Fix #4018: htmlhelp: Add htmlhelp_file_suffix and htmlhelp_link_suffix
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -27,6 +27,8 @@ Features added
|
|||||||
__ https://github.com/sphinx-contrib/sphinx-pretty-searchresults
|
__ https://github.com/sphinx-contrib/sphinx-pretty-searchresults
|
||||||
|
|
||||||
* #4182: autodoc: Support :confval:`suppress_warnings`
|
* #4182: autodoc: Support :confval:`suppress_warnings`
|
||||||
|
* #4018: htmlhelp: Add :confval:`htmlhelp_file_suffix` and
|
||||||
|
:confval:`htmlhelp_link_suffix`
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -1347,6 +1347,19 @@ Options for HTML help output
|
|||||||
|
|
||||||
Output file base name for HTML help builder. Default is ``'pydoc'``.
|
Output file base name for HTML help builder. Default is ``'pydoc'``.
|
||||||
|
|
||||||
|
.. confval:: htmlhelp_file_suffix
|
||||||
|
|
||||||
|
This is the file name suffix for generated HTML help files. The
|
||||||
|
default is ``".html"``.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
.. confval:: htmlhelp_link_suffix
|
||||||
|
|
||||||
|
Suffix for generated links to HTML files. The default is ``".html"``.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
|
||||||
.. _applehelp-options:
|
.. _applehelp-options:
|
||||||
|
|
||||||
|
|||||||
@@ -283,11 +283,14 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
self.init_highlighter()
|
self.init_highlighter()
|
||||||
self.init_css_files()
|
self.init_css_files()
|
||||||
self.init_js_files()
|
self.init_js_files()
|
||||||
if self.config.html_file_suffix is not None:
|
|
||||||
self.out_suffix = self.config.html_file_suffix
|
|
||||||
|
|
||||||
if self.config.html_link_suffix is not None:
|
html_file_suffix = self.get_builder_config('file_suffix', 'html')
|
||||||
self.link_suffix = self.config.html_link_suffix
|
if html_file_suffix is not None:
|
||||||
|
self.out_suffix = html_file_suffix
|
||||||
|
|
||||||
|
html_link_suffix = self.get_builder_config('link_suffix', 'html')
|
||||||
|
if html_link_suffix is not None:
|
||||||
|
self.link_suffix = html_link_suffix
|
||||||
else:
|
else:
|
||||||
self.link_suffix = self.out_suffix
|
self.link_suffix = self.out_suffix
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from docutils import nodes
|
|||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||||
|
from sphinx.config import string_classes
|
||||||
from sphinx.environment.adapters.indexentries import IndexEntries
|
from sphinx.environment.adapters.indexentries import IndexEntries
|
||||||
from sphinx.locale import __
|
from sphinx.locale import __
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
@@ -195,10 +196,10 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
StandaloneHTMLBuilder.init(self)
|
# the output files for HTML help is .html by default
|
||||||
# the output files for HTML help must be .html only
|
|
||||||
self.out_suffix = '.html'
|
self.out_suffix = '.html'
|
||||||
self.link_suffix = '.html'
|
self.link_suffix = '.html'
|
||||||
|
StandaloneHTMLBuilder.init(self)
|
||||||
# determine the correct locale setting
|
# determine the correct locale setting
|
||||||
locale = chm_locales.get(self.config.language)
|
locale = chm_locales.get(self.config.language)
|
||||||
if locale is not None:
|
if locale is not None:
|
||||||
@@ -341,6 +342,8 @@ def setup(app):
|
|||||||
app.add_builder(HTMLHelpBuilder)
|
app.add_builder(HTMLHelpBuilder)
|
||||||
|
|
||||||
app.add_config_value('htmlhelp_basename', lambda self: make_filename(self.project), None)
|
app.add_config_value('htmlhelp_basename', lambda self: make_filename(self.project), None)
|
||||||
|
app.add_config_value('htmlhelp_file_suffix', None, 'html', string_classes)
|
||||||
|
app.add_config_value('htmlhelp_link_suffix', None, 'html', string_classes)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'version': 'builtin',
|
'version': 'builtin',
|
||||||
|
|||||||
23
tests/test_build_htmlhelp.py
Normal file
23
tests/test_build_htmlhelp.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
test_build_htmlhelp
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Test the HTML Help builder and check output against XPath.
|
||||||
|
|
||||||
|
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
||||||
|
:license: BSD, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('htmlhelp', testroot='basic')
|
||||||
|
def test_default_htmlhelp_file_suffix(app, warning):
|
||||||
|
assert app.builder.out_suffix == '.html'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('htmlhelp', testroot='basic',
|
||||||
|
confoverrides={'htmlhelp_file_suffix': '.htm'})
|
||||||
|
def test_htmlhelp_file_suffix(app, warning):
|
||||||
|
assert app.builder.out_suffix == '.htm'
|
||||||
Reference in New Issue
Block a user