From 4f6d0dce65cfefd62a7216045b39a335a303c89b Mon Sep 17 00:00:00 2001 From: grubert Date: Mon, 27 Jul 2009 10:07:28 +0000 Subject: [PATCH] Doctest Blocks. git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk@6064 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- sandbox/manpage-writer/README.txt | 1 + sandbox/manpage-writer/docutils/writers/manpage.py | 7 ++++--- sandbox/manpage-writer/expected/test.latin1 | 7 +++++++ sandbox/manpage-writer/expected/test.man | 12 +++++++++++- sandbox/manpage-writer/input/test.txt | 9 +++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sandbox/manpage-writer/README.txt b/sandbox/manpage-writer/README.txt index 0c22a1230..b56a42504 100644 --- a/sandbox/manpage-writer/README.txt +++ b/sandbox/manpage-writer/README.txt @@ -158,6 +158,7 @@ Change log * Images print *alt* and *uri*. * Definition lists print also th eclassifier and are more compact. * Figures. + * Doctest Blocks. - 2009-07-26: diff --git a/sandbox/manpage-writer/docutils/writers/manpage.py b/sandbox/manpage-writer/docutils/writers/manpage.py index 7c842c7ad..9676256e4 100644 --- a/sandbox/manpage-writer/docutils/writers/manpage.py +++ b/sandbox/manpage-writer/docutils/writers/manpage.py @@ -547,11 +547,12 @@ class Translator(nodes.NodeVisitor): self.append_header() def visit_doctest_block(self, node): - self.document.reporter.warning('"doctest_block" not supported', - base_node=node) + self.body.append(self.defs['literal_block'][0]) + self._in_literal = True def depart_doctest_block(self, node): - pass + self._in_literal = False + self.body.append(self.defs['literal_block'][1]) def visit_document(self, node): # no blank line between comment and header. diff --git a/sandbox/manpage-writer/expected/test.latin1 b/sandbox/manpage-writer/expected/test.latin1 index 1422269ae..35ccd0f50 100644 --- a/sandbox/manpage-writer/expected/test.latin1 +++ b/sandbox/manpage-writer/expected/test.latin1 @@ -121,10 +121,17 @@ EEXXAAMMPPLLEESS ddeeffiinniittiioonn ttoooo :: with the colon. + DDoocctteesstt BBlloocckkss + >>> print ´Python-specific usage examples; begun with ">>>"´ + Python-specific usage examples; begun with ">>>" + >>> print ´(cut and pasted from interactive Python sessions)´ + (cut and pasted from interactive Python sessions) + TTaabblleess +----------------+-------+ |single | frame | +----------------+-------+ + |no table header | | +----------------+-------+ diff --git a/sandbox/manpage-writer/expected/test.man b/sandbox/manpage-writer/expected/test.man index f817c0731..964681898 100644 --- a/sandbox/manpage-writer/expected/test.man +++ b/sandbox/manpage-writer/expected/test.man @@ -219,6 +219,16 @@ are also a valuable option and simple nonintrusive formatting . with the colon. .UNINDENT +.SS Doctest Blocks +.sp +.nf +.ft C +>>> print \'Python\-specific usage examples; begun with ">>>"\' +Python\-specific usage examples; begun with ">>>" +>>> print \'(cut and pasted from interactive Python sessions)\' +(cut and pasted from interactive Python sessions) +.ft P +.fi .SS Tables .TS center; @@ -450,6 +460,6 @@ Version: 0.0.1 .SH COPYRIGHT public domain Behave responsible. -.\" Generated by docutils manpage writer on 2009-07-27 11:02. +.\" Generated by docutils manpage writer on 2009-07-27 12:07. .\" . diff --git a/sandbox/manpage-writer/input/test.txt b/sandbox/manpage-writer/input/test.txt index 9a29a47f0..95de87396 100644 --- a/sandbox/manpage-writer/input/test.txt +++ b/sandbox/manpage-writer/input/test.txt @@ -138,6 +138,15 @@ definition lists definition too : with the colon. +Doctest Blocks +-------------- + +>>> print 'Python-specific usage examples; begun with ">>>"' +Python-specific usage examples; begun with ">>>" +>>> print '(cut and pasted from interactive Python sessions)' +(cut and pasted from interactive Python sessions) + + Tables ------ -- 2.11.4.GIT