SF.net SVN: docutils:[9565] trunk/sandbox/manpage-writer
grubert--- via Docutils-checkins <[email protected]>
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 9565
http://sourceforge.net/p/docutils/code/9565
Author: grubert
Date: 2024-03-15 12:50:33 +0000 (Fri, 15 Mar 2024)
Log Message:
-----------
compare output to expected files (pseudoxmal and man)
Modified Paths:
--------------
trunk/sandbox/manpage-writer/multiple_definition_list_terms.py
Added Paths:
-----------
trunk/sandbox/manpage-writer/expected/termtest-manpage.man
trunk/sandbox/manpage-writer/expected/termtest-pseudoxml.txt
Added: trunk/sandbox/manpage-writer/expected/termtest-manpage.man
===================================================================
--- trunk/sandbox/manpage-writer/expected/termtest-manpage.man (rev 0)
+++ trunk/sandbox/manpage-writer/expected/termtest-manpage.man 2024-03-15 12:50:33 UTC (rev 9565)
@@ -0,0 +1,51 @@
+.\" Man page generated from reStructuredText.
+.
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.TH "" "" ""
+.SH NAME
+ \-
+.INDENT 0.0
+.TP
+.B term 1
+definition 1
+.TP
+.B term 2a
+.TQ
+
+.B term 2b
+definition 2
+.TP
+.B term 3a
+classifier 3aclassifier 3aa
+.B term 3b
+classifier 3b
+definition 3
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
Added: trunk/sandbox/manpage-writer/expected/termtest-pseudoxml.txt
===================================================================
--- trunk/sandbox/manpage-writer/expected/termtest-pseudoxml.txt (rev 0)
+++ trunk/sandbox/manpage-writer/expected/termtest-pseudoxml.txt 2024-03-15 12:50:33 UTC (rev 9565)
@@ -0,0 +1,30 @@
+<document source="<string>">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph classes="first last first last">
+ definition 1
+ <definition_list_item>
+ <term>
+ term 2a
+ <term>
+ term 2b
+ <definition>
+ <paragraph classes="first last first last">
+ definition 2
+ <definition_list_item>
+ <term>
+ term 3a
+ <classifier>
+ classifier 3a
+ <classifier>
+ classifier 3aa
+ <term>
+ term 3b
+ <classifier>
+ classifier 3b
+ <definition>
+ <paragraph classes="first last first last">
+ definition 3
Property changes on: trunk/sandbox/manpage-writer/expected/termtest-pseudoxml.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/sandbox/manpage-writer/multiple_definition_list_terms.py
===================================================================
--- trunk/sandbox/manpage-writer/multiple_definition_list_terms.py 2024-03-15 12:20:47 UTC (rev 9564)
+++ trunk/sandbox/manpage-writer/multiple_definition_list_terms.py 2024-03-15 12:50:33 UTC (rev 9565)
@@ -34,6 +34,9 @@
# document tree programatically and exports it with the writers defined in
# Docutils to temporary files.
+import difflib
+import os.path
+
from docutils.core import publish_doctree, publish_from_doctree
from docutils.nodes import term, classifier
@@ -110,7 +113,7 @@
'html5': 'html',
'latex': 'tex',
'xetex': 'tex',
- 'manpage': 'troff',
+ 'manpage': 'man',
'odt': 'odt',
'xml': 'xml',
'pseudoxml': 'txt',
@@ -120,11 +123,17 @@
output = publish_from_doctree(doctree, writer_name=format,
settings_overrides=settings)
- # print(output.decode())
- filename = f'/tmp/termtest-{format}.{extensions[format]}'
- with open(filename, 'bw') as outfile:
+ filename = f'termtest-{format}.{extensions[format]}'
+ outf = f'output/{filename}'
+ with open(outf, 'bw') as outfile:
outfile.write(output)
- print(f'output written to /tmp/{filename}')
+ print(f'output written to {outf}')
+ expf = f'expected/{filename}'
+ if os.path.exists(expf):
+ d = difflib.unified_diff(open(expf).readlines(),
+ open(outf).readlines(),
+ fromfile=expf, tofile=outf)
+ print("".join(list(d)))
# output = publish_from_doctree(doctree, writer_name='odf')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.