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 docutils import nodes, writers
|
||||||
|
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes, __version__
|
||||||
from sphinx.locale import versionlabels, _
|
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 = """\
|
TEMPLATE = """\
|
||||||
\\input texinfo @c -*-texinfo-*-
|
\\input texinfo @c -*-texinfo-*-
|
||||||
@c %%**start of header
|
@c %%**start of header
|
||||||
@setfilename %(filename)s
|
@setfilename %(filename)s
|
||||||
@documentencoding UTF-8
|
@documentencoding UTF-8
|
||||||
@copying
|
@ifinfo
|
||||||
Generated by Sphinx
|
@*Generated by Sphinx """ + __version__ + """.@*
|
||||||
@end copying
|
@end ifinfo
|
||||||
@settitle %(title)s
|
@settitle %(title)s
|
||||||
@defindex ge
|
@defindex ge
|
||||||
@paragraphindent %(paragraphindent)s
|
@paragraphindent %(paragraphindent)s
|
||||||
@ -35,9 +46,13 @@ Generated by Sphinx
|
|||||||
%(direntry)s
|
%(direntry)s
|
||||||
@c %%**end of header
|
@c %%**end of header
|
||||||
|
|
||||||
|
@copying
|
||||||
|
%(copying)s
|
||||||
|
@end copying
|
||||||
|
|
||||||
@titlepage
|
@titlepage
|
||||||
@title %(title)s
|
@title %(title)s
|
||||||
@author %(author)s
|
@insertcopying
|
||||||
@end titlepage
|
@end titlepage
|
||||||
@contents
|
@contents
|
||||||
|
|
||||||
@ -48,6 +63,7 @@ Generated by Sphinx
|
|||||||
@ifnottex
|
@ifnottex
|
||||||
@node Top
|
@node Top
|
||||||
@top %(title)s
|
@top %(title)s
|
||||||
|
@insertcopying
|
||||||
@end ifnottex
|
@end ifnottex
|
||||||
|
|
||||||
@c %%**start of body
|
@c %%**start of body
|
||||||
@ -160,13 +176,18 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
|||||||
ignore_missing_images = False
|
ignore_missing_images = False
|
||||||
|
|
||||||
default_elements = {
|
default_elements = {
|
||||||
'filename': '',
|
'author': '',
|
||||||
'title': '',
|
|
||||||
'paragraphindent': 2,
|
|
||||||
'exampleindent': 4,
|
|
||||||
'direntry': '',
|
|
||||||
'preamble': '',
|
|
||||||
'body': '',
|
'body': '',
|
||||||
|
'copying': '',
|
||||||
|
'date': '',
|
||||||
|
'direntry': '',
|
||||||
|
'exampleindent': 4,
|
||||||
|
'filename': '',
|
||||||
|
'paragraphindent': 2,
|
||||||
|
'preamble': '',
|
||||||
|
'project': '',
|
||||||
|
'release': '',
|
||||||
|
'title': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, document, builder):
|
def __init__(self, document, builder):
|
||||||
@ -224,9 +245,15 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
|||||||
elements.update({
|
elements.update({
|
||||||
# if empty, the title is set to the first section title
|
# if empty, the title is set to the first section title
|
||||||
'title': settings.title,
|
'title': settings.title,
|
||||||
'author': escape_arg(settings.author),
|
'author': settings.author,
|
||||||
# if empty, use basename of input file
|
# if empty, use basename of input file
|
||||||
'filename': settings.texinfo_filename,
|
'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
|
||||||
title = elements['title']
|
title = elements['title']
|
||||||
@ -242,14 +269,16 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
|||||||
elements['filename'] += '.info'
|
elements['filename'] += '.info'
|
||||||
# Direntry
|
# Direntry
|
||||||
if settings.texinfo_dir_entry:
|
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'
|
elements['direntry'] = ('@dircategory %s\n'
|
||||||
'@direntry\n'
|
'@direntry\n'
|
||||||
'* %s: (%s). %s\n'
|
'%s'
|
||||||
'@end direntry\n') % (
|
'@end direntry\n') % (
|
||||||
escape_id(settings.texinfo_dir_category),
|
escape_id(settings.texinfo_dir_category), entry)
|
||||||
escape_id(settings.texinfo_dir_entry),
|
elements['copying'] = COPYING % elements
|
||||||
elements['filename'],
|
|
||||||
escape_arg(settings.texinfo_dir_description))
|
|
||||||
# allow the user to override them all
|
# allow the user to override them all
|
||||||
elements.update(settings.texinfo_elements)
|
elements.update(settings.texinfo_elements)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user