mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove termset node. It is not used anywhere. Restore termsep node and set as Deprecation. refs #2251
This commit is contained in:
8
CHANGES
8
CHANGES
@@ -21,9 +21,11 @@ Incompatible changes
|
||||
refers to :confval:`exclude_patterns` to exclude extra files and directories.
|
||||
* #2300: enhance autoclass:: to use the docstring of __new__ if __init__ method's is missing
|
||||
of empty
|
||||
* #2251: term nodes in a glossary directive are wrapped with ``termset`` node to handle
|
||||
multiple term correctly. ``termsep`` node is removed and ``termset`` is added.
|
||||
By this change, every writers must have visit_termset and depart_termset method.
|
||||
* #2251: Previously, under glossary directives, multiple terms for one definition are
|
||||
converted into single ``term`` node and the each terms in the term node are separated
|
||||
by ``termsep`` node. In new implementation, each terms are converted into individual
|
||||
``term`` nodes and ``termsep`` node is removed.
|
||||
By this change, output layout of every builders are changed a bit.
|
||||
|
||||
Features added
|
||||
--------------
|
||||
|
||||
@@ -54,4 +54,4 @@ You should not need to generate the nodes below in extensions.
|
||||
.. autoclass:: start_of_file
|
||||
.. autoclass:: productionlist
|
||||
.. autoclass:: production
|
||||
.. autoclass:: termset
|
||||
.. autoclass:: termsep
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import warnings
|
||||
|
||||
from docutils import nodes
|
||||
|
||||
|
||||
@@ -208,8 +210,17 @@ class abbreviation(nodes.Inline, nodes.TextElement):
|
||||
"""Node for abbreviations with explanations."""
|
||||
|
||||
|
||||
class termset(nodes.Structural, nodes.Element):
|
||||
"""A set of <term> node"""
|
||||
class termsep(nodes.Structural, nodes.Element):
|
||||
"""Separates two terms within a <term> node.
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
sphinx.addnodes.termsep is deprecated. It will be removed at Sphinx-1.5.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kw):
|
||||
warnings.warn('sphinx.addnodes.termsep will be removed at Sphinx-1.5',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
super(termsep, self).__init__(*args, **kw)
|
||||
|
||||
|
||||
class manpage(nodes.Inline, nodes.TextElement):
|
||||
|
||||
@@ -235,14 +235,6 @@ def register_term_to_glossary(env, node, new_id=None):
|
||||
node['names'].append(new_id)
|
||||
|
||||
|
||||
def make_termset_from_termnodes(termnodes):
|
||||
# make a single "termset" node with all the terms
|
||||
termset = addnodes.termset('', *termnodes)
|
||||
termset.source, termset.line = termnodes[0].source, termnodes[0].line
|
||||
termset.rawsource = termset.astext()
|
||||
return termset
|
||||
|
||||
|
||||
class Glossary(Directive):
|
||||
"""
|
||||
Directive to create a glossary with cross-reference targets for :term:
|
||||
@@ -337,16 +329,15 @@ class Glossary(Directive):
|
||||
termtexts.append(term.astext())
|
||||
termnodes.append(term)
|
||||
|
||||
termset = make_termset_from_termnodes(termnodes)
|
||||
termset += system_messages
|
||||
termnodes.extend(system_messages)
|
||||
|
||||
defnode = nodes.definition()
|
||||
if definition:
|
||||
self.state.nested_parse(definition, definition.items[0][1],
|
||||
defnode)
|
||||
|
||||
termnodes.append(defnode)
|
||||
items.append((termtexts,
|
||||
nodes.definition_list_item('', termset, defnode)))
|
||||
nodes.definition_list_item('', *termnodes)))
|
||||
|
||||
if 'sorted' in self.options:
|
||||
items.sort(key=lambda x:
|
||||
|
||||
@@ -13,6 +13,7 @@ import sys
|
||||
import posixpath
|
||||
import os
|
||||
import copy
|
||||
import warnings
|
||||
|
||||
from six import string_types
|
||||
from docutils import nodes
|
||||
@@ -629,11 +630,11 @@ class HTMLTranslator(BaseTranslator):
|
||||
def depart_abbreviation(self, node):
|
||||
self.body.append('</abbr>')
|
||||
|
||||
def visit_termset(self, node):
|
||||
pass
|
||||
|
||||
def depart_termset(self, node):
|
||||
pass
|
||||
def visit_termsep(self, node):
|
||||
warnings.warn('sphinx.addnodes.termsep will be removed at Sphinx-1.5',
|
||||
DeprecationWarning)
|
||||
self.body.append('<br />')
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_manpage(self, node):
|
||||
return self.visit_literal_emphasis(node)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import re
|
||||
import sys
|
||||
from os import path
|
||||
import warnings
|
||||
|
||||
from six import itervalues, text_type
|
||||
from docutils import nodes, writers
|
||||
@@ -1222,11 +1223,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.unrestrict_footnote(node)
|
||||
self.in_term -= 1
|
||||
|
||||
def visit_termset(self, node):
|
||||
pass
|
||||
|
||||
def depart_termset(self, node):
|
||||
pass
|
||||
def visit_termsep(self, node):
|
||||
warnings.warn('sphinx.addnodes.termsep will be removed at Sphinx-1.5',
|
||||
DeprecationWarning)
|
||||
self.body.append(', ')
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_classifier(self, node):
|
||||
self.body.append('{[}')
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import warnings
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.writers.manpage import (
|
||||
MACRO_DEF,
|
||||
@@ -200,11 +202,11 @@ class ManualPageTranslator(BaseTranslator):
|
||||
def depart_versionmodified(self, node):
|
||||
self.depart_paragraph(node)
|
||||
|
||||
def visit_termset(self, node):
|
||||
pass
|
||||
|
||||
def depart_termset(self, node):
|
||||
pass
|
||||
def visit_termsep(self, node):
|
||||
warnings.warn('sphinx.addnodes.termsep will be removed at Sphinx-1.5',
|
||||
DeprecationWarning)
|
||||
self.body.append(', ')
|
||||
raise nodes.SkipNode
|
||||
|
||||
# overwritten -- we don't want source comments to show up
|
||||
def visit_comment(self, node):
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import re
|
||||
import textwrap
|
||||
from os import path
|
||||
import warnings
|
||||
|
||||
from six import itervalues
|
||||
from six.moves import range
|
||||
@@ -952,10 +953,12 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
def depart_term(self, node):
|
||||
pass
|
||||
|
||||
def visit_termset(self, node):
|
||||
pass
|
||||
def visit_termsep(self, node):
|
||||
warnings.warn('sphinx.addnodes.termsep will be removed at Sphinx-1.5',
|
||||
DeprecationWarning)
|
||||
self.body.append('\n%s ' % self.at_item_x)
|
||||
|
||||
def depart_termset(self, node):
|
||||
def depart_termsep(self, node):
|
||||
pass
|
||||
|
||||
def visit_classifier(self, node):
|
||||
|
||||
@@ -12,6 +12,7 @@ import os
|
||||
import re
|
||||
import textwrap
|
||||
from itertools import groupby
|
||||
import warnings
|
||||
|
||||
from six.moves import zip_longest
|
||||
|
||||
@@ -640,11 +641,11 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
if not self._classifier_count_in_li:
|
||||
self.end_state(end=None)
|
||||
|
||||
def visit_termset(self, node):
|
||||
pass
|
||||
|
||||
def depart_termset(self, node):
|
||||
pass
|
||||
def visit_termsep(self, node):
|
||||
warnings.warn('sphinx.addnodes.termsep will be removed at Sphinx-1.5',
|
||||
DeprecationWarning)
|
||||
self.add_text(', ')
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_classifier(self, node):
|
||||
self.add_text(' : ')
|
||||
|
||||
Reference in New Issue
Block a user