mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#209: Added :confval:text_newlines and :confval:text_sectionchars config values.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -51,6 +51,9 @@ Release 1.1 (in development)
|
||||
|
||||
* #553: Added :rst:dir:`testcleanup` blocks in the doctest extension.
|
||||
|
||||
* #209: Added :confval:`text_newlines` and :confval:`text_sectionchars`
|
||||
config values.
|
||||
|
||||
|
||||
Release 1.0.6 (in development)
|
||||
==============================
|
||||
|
||||
@@ -850,6 +850,7 @@ the `Dublin Core metadata <http://dublincore.org/>`_.
|
||||
a chapter, but can be confusing because it mixes entries of differnet
|
||||
depth in one list. The default value is ``True``.
|
||||
|
||||
|
||||
.. _latex-options:
|
||||
|
||||
Options for LaTeX output
|
||||
@@ -1048,6 +1049,37 @@ These options influence LaTeX output.
|
||||
Use the ``'pointsize'`` key in the :confval:`latex_elements` value.
|
||||
|
||||
|
||||
.. _text-options:
|
||||
|
||||
Options for text output
|
||||
-----------------------
|
||||
|
||||
These options influence text output.
|
||||
|
||||
.. confval:: text_newlines
|
||||
|
||||
Determines which end-of-line character(s) are used in text output.
|
||||
|
||||
* ``'unix'``: use Unix-style line endings (``\n``)
|
||||
* ``'windows'``: use Windows-style line endings (``\r\n``)
|
||||
* ``'native'``: use the line ending style of the platform the documentation
|
||||
is built on
|
||||
|
||||
Default: ``'unix'``.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
|
||||
.. confval:: text_sectionchars
|
||||
|
||||
A string of 7 characters that should be used for underlining sections.
|
||||
The first character is used for first-level headings, the second for
|
||||
second-level headings and so on.
|
||||
|
||||
The default is ``'*=-~"+`'``.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
|
||||
|
||||
.. _man-options:
|
||||
|
||||
Options for manual page output
|
||||
|
||||
@@ -156,8 +156,8 @@ class Config(object):
|
||||
latex_preamble = ('', None),
|
||||
|
||||
# text options
|
||||
text_sectionchars = ('*=-~"+`', 'text'),
|
||||
text_windows_newlines = (False, 'text'),
|
||||
text_sectionchars = ('*=-~"+`', 'env'),
|
||||
text_newlines = ('unix', 'env'),
|
||||
|
||||
# manpage options
|
||||
man_pages = ([], None),
|
||||
|
||||
@@ -215,7 +215,7 @@ class Locale(Transform):
|
||||
continue
|
||||
parser.parse(msgstr, patch)
|
||||
patch = patch[0]
|
||||
#XXX doctest and other block markup
|
||||
# XXX doctest and other block markup
|
||||
if not isinstance(patch, nodes.paragraph):
|
||||
continue # skip for now
|
||||
for child in patch.children: # update leaves
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
@@ -52,6 +52,14 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
def __init__(self, document, builder):
|
||||
nodes.NodeVisitor.__init__(self, document)
|
||||
|
||||
newlines = builder.config.text_newlines
|
||||
if newlines == 'windows':
|
||||
self.nl = '\r\n'
|
||||
elif newlines == 'native':
|
||||
self.nl = os.linesep
|
||||
else:
|
||||
self.nl = '\n'
|
||||
self.sectionchars = builder.config.text_sectionchars
|
||||
self.states = [[]]
|
||||
self.stateindent = [0]
|
||||
self.list_counter = []
|
||||
@@ -98,9 +106,9 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
self.new_state(0)
|
||||
def depart_document(self, node):
|
||||
self.end_state()
|
||||
self.body = '\n'.join(line and (' '*indent + line)
|
||||
for indent, lines in self.states[0]
|
||||
for line in lines)
|
||||
self.body = self.nl.join(line and (' '*indent + line)
|
||||
for indent, lines in self.states[0]
|
||||
for line in lines)
|
||||
# XXX header/footer?
|
||||
|
||||
def visit_highlightlang(self, node):
|
||||
@@ -225,7 +233,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_desc_content(self, node):
|
||||
self.new_state()
|
||||
self.add_text('\n')
|
||||
self.add_text(self.nl)
|
||||
def depart_desc_content(self, node):
|
||||
self.end_state()
|
||||
|
||||
@@ -251,7 +259,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
lastname = production['tokenname']
|
||||
else:
|
||||
self.add_text('%s ' % (' '*len(lastname)))
|
||||
self.add_text(production.astext() + '\n')
|
||||
self.add_text(production.astext() + self.nl)
|
||||
self.end_state(wrap=False)
|
||||
raise nodes.SkipNode
|
||||
|
||||
@@ -351,7 +359,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
'not implemented.')
|
||||
self.new_state(0)
|
||||
def depart_entry(self, node):
|
||||
text = '\n'.join('\n'.join(x[1]) for x in self.states.pop())
|
||||
text = self.nl.join(self.nl.join(x[1]) for x in self.states.pop())
|
||||
self.stateindent.pop()
|
||||
self.table[-1].append(text)
|
||||
|
||||
@@ -387,7 +395,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
for width in realwidths:
|
||||
out.append(char * (width+2))
|
||||
out.append('+')
|
||||
self.add_text(''.join(out) + '\n')
|
||||
self.add_text(''.join(out) + self.nl)
|
||||
|
||||
def writerow(row):
|
||||
lines = zip(*row)
|
||||
@@ -399,7 +407,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
else:
|
||||
out.append(' ' * (realwidths[i] + 2))
|
||||
out.append('|')
|
||||
self.add_text(''.join(out) + '\n')
|
||||
self.add_text(''.join(out) + self.nl)
|
||||
|
||||
for i, row in enumerate(fmted_rows):
|
||||
if separator and i == separator:
|
||||
|
||||
Reference in New Issue
Block a user