mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Don't use JavaScript and section anchors in the htmlhelp version.
This commit is contained in:
4
README
4
README
@@ -1,6 +1,10 @@
|
||||
doctools README
|
||||
===============
|
||||
|
||||
FIXME: This is already outdated since the conversion has happened and the
|
||||
reST sources are in the Python tree now.
|
||||
|
||||
|
||||
What you need to know
|
||||
---------------------
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
doc,
|
||||
source_class=DocTreeInput,
|
||||
reader=doctree.Reader(),
|
||||
writer=HTMLWriter(self.config),
|
||||
writer=HTMLWriter(self.config, self.name),
|
||||
settings_overrides={'output_encoding': 'unicode'}
|
||||
)
|
||||
|
||||
@@ -299,7 +299,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
from .search import IndexBuilder
|
||||
self.indexer = IndexBuilder()
|
||||
self.load_indexer(filenames)
|
||||
self.docwriter = HTMLWriter(self.config)
|
||||
self.docwriter = HTMLWriter(self.config, self.name)
|
||||
self.docsettings = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(self.docwriter,)).get_default_values()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<link rel="stylesheet" href="{{ pathto('style/default.css', 1) }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ pathto('style/pygments.css', 1) }}" type="text/css">
|
||||
{%- endif %}
|
||||
{%- if builder != 'htmlhelp' %}
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: '{{ pathto("", 1) }}',
|
||||
@@ -24,6 +25,7 @@
|
||||
<script type="text/javascript" src="{{ pathto('style/jquery.js', 1) }}"></script>
|
||||
<script type="text/javascript" src="{{ pathto('style/interface.js', 1) }}"></script>
|
||||
<script type="text/javascript" src="{{ pathto('style/doctools.js', 1) }}"></script>
|
||||
{%- endif %}
|
||||
<link rel="author" title="About these documents" href="{{ pathto('about.rst') }}">
|
||||
<link rel="contents" title="Global table of contents" href="{{ pathto('contents.rst') }}">
|
||||
<link rel="index" title="Global index" href="{{ pathto('genindex.rst') }}">
|
||||
|
||||
@@ -16,12 +16,9 @@ from .util.smartypants import sphinx_smarty_pants
|
||||
|
||||
|
||||
class HTMLWriter(Writer):
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, buildername):
|
||||
Writer.__init__(self)
|
||||
if config.get('use_smartypants', False):
|
||||
self.translator_class = SmartyPantsHTMLTranslator
|
||||
else:
|
||||
self.translator_class = HTMLTranslator
|
||||
self.translator_class = translator_class(config, buildername)
|
||||
|
||||
|
||||
version_text = {
|
||||
@@ -30,7 +27,8 @@ version_text = {
|
||||
'versionadded': 'New in version %s',
|
||||
}
|
||||
|
||||
class HTMLTranslator(BaseTranslator):
|
||||
def translator_class(config, buildername):
|
||||
class HTMLTranslator(BaseTranslator):
|
||||
"""
|
||||
Our custom HTML translator.
|
||||
"""
|
||||
@@ -55,7 +53,7 @@ class HTMLTranslator(BaseTranslator):
|
||||
if node.parent['desctype'] in ('class', 'exception'):
|
||||
self.body.append('%s ' % node.parent['desctype'])
|
||||
def depart_desc_signature(self, node):
|
||||
if node['ids']:
|
||||
if node['ids'] and buildername != 'htmlhelp':
|
||||
self.body.append(u'<a class="headerlink" href="#%s" ' % node['ids'][0] +
|
||||
u'title="Permalink to this definition">\u00B6</a>')
|
||||
self.body.append('</dt>\n')
|
||||
@@ -224,7 +222,8 @@ class HTMLTranslator(BaseTranslator):
|
||||
|
||||
def depart_title(self, node):
|
||||
close_tag = self.context[-1]
|
||||
if close_tag.startswith(('</h', '</a></h')) and \
|
||||
if buildername != 'htmlhelp' and \
|
||||
close_tag.startswith(('</h', '</a></h')) and \
|
||||
node.parent.hasattr('ids') and node.parent['ids']:
|
||||
aname = node.parent['ids'][0]
|
||||
# add permalink anchor
|
||||
@@ -233,7 +232,7 @@ class HTMLTranslator(BaseTranslator):
|
||||
BaseTranslator.depart_title(self, node)
|
||||
|
||||
|
||||
class SmartyPantsHTMLTranslator(HTMLTranslator):
|
||||
class SmartyPantsHTMLTranslator(HTMLTranslator):
|
||||
"""
|
||||
Handle ordinary text via smartypants, converting quotes and dashes
|
||||
to the correct entities.
|
||||
@@ -271,3 +270,8 @@ class SmartyPantsHTMLTranslator(HTMLTranslator):
|
||||
if self.no_smarty <= 0:
|
||||
text = sphinx_smarty_pants(text)
|
||||
return text
|
||||
|
||||
if config.get('use_smartypants', False):
|
||||
return SmartyPantsHTMLTranslator
|
||||
else:
|
||||
return HTMLTranslator
|
||||
|
||||
Reference in New Issue
Block a user