Commits

Jon Waltman  committed 8a5d098

Add a standard @copying block in Texinfo.

  • Participants
  • Parent commits caf1fd3

Comments (0)

Files changed (1)

File sphinx/writers/texinfo.py

 
 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
 %(direntry)s
 @c %%**end of header
 
+@copying
+%(copying)s
+@end copying
+
 @titlepage
 @title %(title)s
-@author %(author)s
+@insertcopying
 @end titlepage
 @contents
 
 @ifnottex
 @node Top
 @top %(title)s
+@insertcopying
 @end ifnottex
 
 @c %%**start of body
     ignore_missing_images = False
 
     default_elements = {
+        'author': '',
+        'body': '',
+        'copying': '',
+        'date': '',
+        'direntry': '',
+        'exampleindent': 4,
         'filename': '',
+        'paragraphindent': 2,
+        'preamble': '',
+        'project': '',
+        'release': '',
         'title': '',
-        'paragraphindent': 2,
-        'exampleindent': 4,
-        'direntry': '',
-        'preamble': '',
-        'body': '',
         }
 
     def __init__(self, document, builder):
         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']
             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)