summaryrefslogtreecommitdiff
path: root/sphinx/writers/html5.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-24 14:32:13 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-01-24 14:32:13 +0900
commit502c4ee5fbef6bf51fe60cc820b1484471dd1b32 (patch)
tree0407a81eb4013f90cc62ae9ad8f1e1b8a51c16db /sphinx/writers/html5.py
parentee5560b7739932d0a7735be0cc81f28d76a61e92 (diff)
parentbecf8f43befe8a1528552106848c0e369b7fba9a (diff)
downloadsphinx-git-502c4ee5fbef6bf51fe60cc820b1484471dd1b32.tar.gz
Merge branch '3.x'
Diffstat (limited to 'sphinx/writers/html5.py')
-rw-r--r--sphinx/writers/html5.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py
index 9e724aee9..53960f637 100644
--- a/sphinx/writers/html5.py
+++ b/sphinx/writers/html5.py
@@ -20,7 +20,7 @@ from docutils.writers.html5_polyglot import HTMLTranslator as BaseTranslator
from sphinx import addnodes
from sphinx.builders import Builder
-from sphinx.deprecation import RemovedInSphinx60Warning
+from sphinx.deprecation import RemovedInSphinx50Warning, RemovedInSphinx60Warning
from sphinx.locale import _, __, admonitionlabels
from sphinx.util import logging
from sphinx.util.docutils import SphinxTranslator
@@ -63,11 +63,6 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
self.docnames = [self.builder.current_docname] # for singlehtml builder
self.manpages_url = self.config.manpages_url
self.protect_literal_text = 0
- self.permalink_text = self.config.html_add_permalinks
- # support backwards-compatible setting to a bool
- if not isinstance(self.permalink_text, str):
- self.permalink_text = 'ΒΆ' if self.permalink_text else ''
- self.permalink_text = self.encode(self.permalink_text)
self.secnumber_suffix = self.config.html_secnumber_suffix
self.param_separator = ''
self.optional_param_level = 0
@@ -296,9 +291,10 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
append_fignumber(figtype, node['ids'][0])
def add_permalink_ref(self, node: Element, title: str) -> None:
- if node['ids'] and self.permalink_text and self.builder.add_permalinks:
+ if node['ids'] and self.config.html_permalinks and self.builder.add_permalinks:
format = '<a class="headerlink" href="#%s" title="%s">%s</a>'
- self.body.append(format % (node['ids'][0], title, self.permalink_text))
+ self.body.append(format % (node['ids'][0], title,
+ self.config.html_permalinks_icon))
# overwritten
def visit_bullet_list(self, node: Element) -> None:
@@ -353,8 +349,8 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
def depart_title(self, node: Element) -> None:
close_tag = self.context[-1]
- if (self.permalink_text and self.builder.add_permalinks and
- node.parent.hasattr('ids') and node.parent['ids']):
+ if (self.config.html_permalinks and self.builder.add_permalinks and
+ node.parent.hasattr('ids') and node.parent['ids']):
# add permalink anchor
if close_tag.startswith('</h'):
self.add_permalink_ref(node.parent, _('Permalink to this headline'))
@@ -363,7 +359,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
node.parent['ids'][0] +
'title="%s">%s' % (
_('Permalink to this headline'),
- self.permalink_text))
+ self.config.html_permalinks_icon))
elif isinstance(node.parent, nodes.table):
self.body.append('</span>')
self.add_permalink_ref(node.parent, _('Permalink to this table'))
@@ -773,6 +769,12 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
def unknown_visit(self, node: Node) -> None:
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
+ @property
+ def permalink_text(self) -> str:
+ warnings.warn('HTMLTranslator.permalink_text is deprecated.',
+ RemovedInSphinx50Warning, stacklevel=2)
+ return self.config.html_permalinks_icon
+
def generate_targets_for_table(self, node: Element) -> None:
"""Generate hyperlink targets for tables.