SF.net SVN: docutils:[9705 ] trunk/docutils

grubert--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9705
          http://sourceforge.net/p/docutils/code/9705
Author:   grubert
Date:     2024-05-16 14:26:04 +0000 (Thu, 16 May 2024)
Log Message:
-----------
Feature-request #105 more informative document comments.
docutils version in header

Modified Paths:
--------------
    trunk/docutils/HISTORY.txt
    trunk/docutils/docutils/writers/manpage.py
    trunk/docutils/test/test_writers/test_manpage.py

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-05-16 13:49:09 UTC (rev 9704)
+++ trunk/docutils/HISTORY.txt	2024-05-16 14:26:04 UTC (rev 9705)
@@ -49,6 +49,8 @@
 * docutils/writers/manpage.py
 
   - Remove code for unused emdash bullets.
+  - Feature-request #105 more informative document comments.
+    docutils version in header
 
 
 Release 0.21.2 (2024-04-23)

Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py	2024-05-16 13:49:09 UTC (rev 9704)
+++ trunk/docutils/docutils/writers/manpage.py	2024-05-16 14:26:04 UTC (rev 9705)
@@ -45,6 +45,7 @@
 
 import re
 
+import docutils
 from docutils import nodes, writers, languages
 try:
     import roman
@@ -167,8 +168,8 @@
 
     words_and_spaces = re.compile(r'\S+| +|\n')
     possibly_a_roff_command = re.compile(r'\.\w')
-    document_start = """Man page generated from reStructuredText."""
-    # TODO add "from docutils 0.21rc1."
+    document_start = ( 'Man page generated from reStructuredText by manpage writer\n'
+                      f'from docutils {docutils.__version__}.' )
 
     def __init__(self, document):
         nodes.NodeVisitor.__init__(self, document)
@@ -623,7 +624,7 @@
         if self._docinfo['copyright']:
             self.body.append('.SH COPYRIGHT\n%s\n'
                              % self._docinfo['copyright'])
-        self.body.append(self.comment('Generated by docutils manpage writer.'))
+        self.body.append(self.comment_begin('End of generated man page.'))
 
     def visit_emphasis(self, node):
         self.body.append(self.defs['emphasis'][0])

Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py	2024-05-16 13:49:09 UTC (rev 9704)
+++ trunk/docutils/test/test_writers/test_manpage.py	2024-05-16 14:26:04 UTC (rev 9705)
@@ -38,6 +38,10 @@
                         }).decode()
                     self.assertEqual(case_expected, output)
 
+document_start = r""".\" Man page generated from reStructuredText by manpage writer
+.\" from docutils 0.22b.dev.
+.
+"""
 
 indend_macros = r""".
 .nr rst2man-indent-level 0
@@ -72,13 +76,10 @@
 
 totest['blank'] = [
         ["",
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "" "" "" ""
+         document_start + indend_macros + """.TH "" "" "" ""
 .SH NAME
  \\- \n\
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
         [r"""Hello, world.
 =============
@@ -87,9 +88,8 @@
    This broke docutils-sphinx.
 
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "HELLO, WORLD." "" "" ""
+         document_start + indend_macros +
+""".TH "HELLO, WORLD." "" "" ""
 .SH NAME
 Hello, world. \\- \n\
 .sp
@@ -99,8 +99,7 @@
 This broke docutils\\-sphinx.
 .UNINDENT
 .UNINDENT
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -164,9 +163,8 @@
 and . in a line and at line start
 .in a paragraph
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """\
+         document_start + indend_macros +
+"""\
 .TH "SIMPLE" "1" "2009-08-05" "0.1" "text processing"
 .SH NAME
 simple \\- The way to go
@@ -230,8 +228,7 @@
 Arbitrary field: some text
 .SH COPYRIGHT
 public domain
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -246,9 +243,7 @@
 """,
 '''\
 \'\\" t
-.\\" Man page generated from reStructuredText.
-.
-''' + indend_macros + '''.TH "" "" "" ""
+''' + document_start + indend_macros + '''.TH "" "" "" ""
 .SH NAME
  \\- \n\
 .INDENT 0.0
@@ -276,8 +271,7 @@
 .TE
 .UNINDENT
 .UNINDENT
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 ''']
 ]
 
@@ -300,10 +294,7 @@
 ]
    bla bla bla
 """,
-        """\
-.\\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "" "" "" ""
+document_start + indend_macros + """.TH "" "" "" ""
 .SH NAME
  \\- \n\
 optin group with dot as group item
@@ -332,8 +323,7 @@
 .B ]
 bla bla bla
 .UNINDENT
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -357,10 +347,7 @@
     Description of Term 1 Description of Term 1
 
 """,
-'''\
-.\\" Man page generated from reStructuredText.
-.
-''' + indend_macros + '''.TH "DEFINITION LIST TEST" "" "" ""
+document_start + indend_macros + '''.TH "DEFINITION LIST TEST" "" "" ""
 .SH NAME
 Definition List Test \\- \n\
 ''' + '''.SS Abstract
@@ -376,8 +363,7 @@
 Description of Term 1 Description of Term 1 Description of Term 1
 Description of Term 1 Description of Term 1
 .UNINDENT
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 '''],
 ]
 
@@ -387,9 +373,7 @@
   --output FILE, -o FILE     output filename
   -i DEVICE, --input DEVICE  input device
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "" "" "" ""
+document_start + indend_macros + """.TH "" "" "" ""
 .SH NAME
  \\- \n\
 .INDENT 0.0
@@ -407,8 +391,7 @@
 input device
 .UNINDENT
 .UNINDENT
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -416,16 +399,13 @@
         [""".. [docutils] blah blah blah
 .. [empty_citation]
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "" "" "" ""
+document_start + indend_macros + """.TH "" "" "" ""
 .SH NAME
  \\- \n\
 .IP [docutils] 5
 blah blah blah
 .IP [empty_citation] 5
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -435,9 +415,7 @@
 - followed by
 - a list
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "" "" "" ""
+document_start + indend_macros + """.TH "" "" "" ""
 .SH NAME
  \\- \n\
 some rubric
@@ -447,8 +425,7 @@
 .IP \\(bu 2
 a list
 .UNINDENT
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -458,9 +435,7 @@
 
 They are "escaped" anywhere.
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + """.TH "" "" "" ""
+document_start + indend_macros + """.TH "" "" "" ""
 .SH NAME
  \\- \n\
 .INDENT 0.0
@@ -470,8 +445,7 @@
 .UNINDENT
 .sp
 They are \\(dqescaped\\(dq anywhere.
-.\\" Generated by docutils manpage writer.
-.
+.\\" End of generated man page.
 """],
 ]
 
@@ -491,15 +465,12 @@
 
 Test title, docinfo to man page header.
 """,
-        r""".\" Man page generated from reStructuredText.
-.
-""" + indend_macros + r""".TH "PAGE TITLE" "3" "3/Nov/2022" "0.0" "the books"
+document_start + indend_macros + r""".TH "PAGE TITLE" "3" "3/Nov/2022" "0.0" "the books"
 .SH NAME
 page title \- in short
 .sp
 Test title, docinfo to man page header.
-.\" Generated by docutils manpage writer.
-.
+.\" End of generated man page.
 """],
 ]
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.