mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add a standard @copying block in Texinfo.
This commit is contained in:
parent
883a7fd3cd
commit
b83fb0dd87
@ -15,18 +15,29 @@ import textwrap
|
||||
|
||||
from docutils import nodes, writers
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx import addnodes, __version__
|
||||
from sphinx.locale import versionlabels, _
|
||||
from sphinx.util import ustrftime
|
||||
|
||||
|
||||
COPYING = """\
|
||||
@quotation
|
||||
%(project)s %(release)s, %(date)s
|
||||
|
||||
%(author)s
|
||||
|
||||
Copyright @copyright{} %(copyright)s
|
||||
@end quotation
|
||||
"""
|
||||
|
||||
TEMPLATE = """\
|
||||
\\input texinfo @c -*-texinfo-*-
|
||||
@c %%**start of header
|
||||
@setfilename %(filename)s
|
||||
@documentencoding UTF-8
|
||||
@copying
|
||||
Generated by Sphinx
|
||||
@end copying
|
||||
@ifinfo
|
||||
@*Generated by Sphinx """ + __version__ + """.@*
|
||||
@end ifinfo
|
||||
@settitle %(title)s
|
||||
@defindex ge
|
||||
@paragraphindent %(paragraphindent)s
|
||||
@ -35,9 +46,13 @@ Generated by Sphinx
|
||||
%(direntry)s
|
||||
@c %%**end of header
|
||||
|
||||
@copying
|
||||
%(copying)s
|
||||
@end copying
|
||||
|
||||
@titlepage
|
||||
@title %(title)s
|
||||
@author %(author)s
|
||||
@insertcopying
|
||||
@end titlepage
|
||||
@contents
|
||||
|
||||
@ -48,6 +63,7 @@ Generated by Sphinx
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top %(title)s
|
||||
@insertcopying
|
||||
@end ifnottex
|
||||
|
||||
@c %%**start of body
|
||||
@ -160,13 +176,18 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
ignore_missing_images = False
|
||||
|
||||
default_elements = {
|
||||
'filename': '',
|
||||
'title': '',
|
||||
'paragraphindent': 2,
|
||||
'exampleindent': 4,
|
||||
'direntry': '',
|
||||
'preamble': '',
|
||||
'author': '',
|
||||
'body': '',
|
||||
'copying': '',
|
||||
'date': '',
|
||||
'direntry': '',
|
||||
'exampleindent': 4,
|
||||
'filename': '',
|
||||
'paragraphindent': 2,
|
||||
'preamble': '',
|
||||
'project': '',
|
||||
'release': '',
|
||||
'title': '',
|
||||
}
|
||||
|
||||
def __init__(self, document, builder):
|
||||
@ -224,9 +245,15 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
elements.update({
|
||||
# if empty, the title is set to the first section title
|
||||
'title': settings.title,
|
||||
'author': escape_arg(settings.author),
|
||||
'author': settings.author,
|
||||
# if empty, use basename of input file
|
||||
'filename': settings.texinfo_filename,
|
||||
'release': escape(self.builder.config.release),
|
||||
'project': escape(self.builder.config.project),
|
||||
'copyright': escape(self.builder.config.copyright),
|
||||
'date': escape(self.builder.config.today or
|
||||
ustrftime(self.builder.config.today_fmt
|
||||
or _('%B %d, %Y')))
|
||||
})
|
||||
# Title
|
||||
title = elements['title']
|
||||
@ -242,14 +269,16 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
elements['filename'] += '.info'
|
||||
# Direntry
|
||||
if settings.texinfo_dir_entry:
|
||||
entry = self.format_menu_entry(
|
||||
escape_menu(settings.texinfo_dir_entry),
|
||||
'(%s)' % elements['filename'],
|
||||
escape_arg(settings.texinfo_dir_description))
|
||||
elements['direntry'] = ('@dircategory %s\n'
|
||||
'@direntry\n'
|
||||
'* %s: (%s). %s\n'
|
||||
'%s'
|
||||
'@end direntry\n') % (
|
||||
escape_id(settings.texinfo_dir_category),
|
||||
escape_id(settings.texinfo_dir_entry),
|
||||
elements['filename'],
|
||||
escape_arg(settings.texinfo_dir_description))
|
||||
escape_id(settings.texinfo_dir_category), entry)
|
||||
elements['copying'] = COPYING % elements
|
||||
# allow the user to override them all
|
||||
elements.update(settings.texinfo_elements)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user