SF.net SVN: docutils:[9808 ] trunk
grubert--- via Docutils-checkins <[email protected]>
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 9808
http://sourceforge.net/p/docutils/code/9808
Author: grubert
Date: 2024-07-31 19:42:20 +0000 (Wed, 31 Jul 2024)
Log Message:
-----------
add command line option --use-reference-macros
Modified Paths:
--------------
trunk/docutils/docutils/writers/manpage.py
trunk/sandbox/manpage-writer/runtest
Added Paths:
-----------
trunk/sandbox/manpage-writer/expected/refs-urue.man
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2024-07-31 16:41:59 UTC (rev 9807)
+++ trunk/docutils/docutils/writers/manpage.py 2024-07-31 19:42:20 UTC (rev 9808)
@@ -46,7 +46,7 @@
import re
import docutils
-from docutils import nodes, writers, languages
+from docutils import frontend, nodes, writers, languages
try:
import roman
except ImportError:
@@ -116,7 +116,16 @@
supported = ('manpage',)
"""Formats this writer supports."""
- # manpage writer specfic settings. not yet
+ settings_spec = (
+ 'Manpage-Specific Options',
+ None,
+ (('Use man macros .UR/.UE and .MT/.ME for references '
+ 'or put references in plain text form.',
+ ['--use-reference-macros'],
+ {'default': False, 'action': 'store_true',
+ 'validator': frontend.validate_boolean}),
+ ),
+ )
output = None
"""Final translated form of `document`."""
@@ -203,10 +212,12 @@
def __init__(self, document):
nodes.NodeVisitor.__init__(self, document)
self.settings = settings = document.settings
- self.visit_reference = self._visit_reference_no_macro
- self.depart_reference = self._depart_reference_no_macro
- self.visit_reference = self._visit_reference_with_macro
- self.depart_reference = self._depart_reference_with_macro
+ if settings.use_reference_macros:
+ self.visit_reference = self._visit_reference_with_macro
+ self.depart_reference = self._depart_reference_with_macro
+ else:
+ self.visit_reference = self._visit_reference_no_macro
+ self.depart_reference = self._depart_reference_no_macro
lcode = settings.language_code
self.language = languages.get_language(lcode, document.reporter)
self.head = []
Added: trunk/sandbox/manpage-writer/expected/refs-urue.man
===================================================================
--- trunk/sandbox/manpage-writer/expected/refs-urue.man (rev 0)
+++ trunk/sandbox/manpage-writer/expected/refs-urue.man 2024-07-31 19:42:20 UTC (rev 9808)
@@ -0,0 +1,181 @@
+.\" Man page generated from reStructuredText by manpage writer
+.\" from docutils 0.22b.dev.
+.
+.
+.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
+ \-
+from quickref.html
+.SH Explicit Markup
+.SS Footnotes
+.sp
+Footnote references, like [5]\&.
+Note that footnotes may get
+rearranged, e.g., to the bottom of
+the \(dqpage\(dq.
+.IP [5] 5
+A numerical footnote. Note
+there\(aqs no colon after the \fB]\fP\&.
+
+.sp
+.ce
+----
+
+.ce 0
+.sp
+.sp
+Autonumbered footnotes are
+possible, like using [1] and [2]\&.
+.IP [1] 5
+This is the first one.
+.IP [2] 5
+This is the second one.
+.sp
+They may be assigned \(aqautonumber
+labels\(aq \- for instance,
+[4] and [3]\&.
+.IP [3] 5
+a.k.a.
+.UR third
+.UE
+
+.IP [4] 5
+a.k.a.
+.UR fourth
+.UE
+
+
+.sp
+.ce
+----
+
+.ce 0
+.sp
+.sp
+Auto\-symbol footnotes are also
+possible, like this: [*] and [\(dg]\&.
+.IP [*] 5
+This is the first one.
+.IP [\(dg] 5
+This is the second one.
+.SS Citations
+.sp
+Citation references, like [CIT2002]\&.
+Note that citations may get
+rearranged, e.g., to the bottom of
+the \(dqpage\(dq.
+.IP [CIT2002] 5
+A citation
+(as often used in journals).
+.sp
+Citation labels contain alphanumerics,
+underlines, hyphens and fullstops.
+Case is not significant.
+.sp
+Given a citation like [this], one
+can also refer to it like
+.UR this
+.UE
+\&.
+.IP [this] 5
+here.
+.SS External Hyperlink Targets
+.sp
+External hyperlinks, like
+.UR https://www.python.org/
+Python
+.UE
+\&.
+.sp
+embedded External hyperlinks, like
+.UR https://www.python.org/
+Python
+.UE
+\&.
+.SS Internal Hyperlink Targets
+.sp
+Internal cross\-references, like
+.UR example
+.UE
+\&.
+.sp
+This is an example cross\-reference target.
+.SS Indirect Hyperlink Targets
+.sp
+.UR https://www.python.org/
+Python
+.UE
+ is
+.UR https://www.python.org/
+my favourite
+programming language
+.UE
+\&.
+.SH Titles are targets, too
+.sp
+Implicit references, like
+.UR Titles are
+targets, too
+.UE
+\&.
+.SH and
+.sp
+See the
+.UR https://www.python.org/
+Python
+.UE
+ home page for info.
+.sp
+.UR mailto:[email protected]
+Write to me
+.UE
+ with your questions.
+.\" deduplicate _Python: https://www.python.org
+.
+.SS URIs with known schemes
+.sp
+.UR tel:+48\-816\-555\-1212
+.UE
+
+.UR urn:isbn:0\-486\-27557\-4
+.UE
+
+.UR news:comp.infosystems.www.servers.unix
+.UE
+
+.UR https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
+.UE
+
+.SS Standalone email addresses
+.sp
+like
+.UR [email protected]
+.UE
+
+.\" End of generated man page.
Modified: trunk/sandbox/manpage-writer/runtest
===================================================================
--- trunk/sandbox/manpage-writer/runtest 2024-07-31 16:41:59 UTC (rev 9807)
+++ trunk/sandbox/manpage-writer/runtest 2024-07-31 19:42:20 UTC (rev 9808)
@@ -97,5 +97,20 @@
done
done
+# reference macros
+EXT=-urue.man
+for EXP_F in $EXP_DIR/*$EXT ; do
+ BASE=`basename $EXP_F`
+ F_BASE=${BASE%$EXT}
+ OPT="--use-reference-macros"
+ $CMD $OPT $IN_DIR/$F_BASE.txt $OUT_DIR/$BASE
+ if [ $? -eq 0 ] ; then
+ diff -s -u $EXP_DIR/$BASE $OUT_DIR/$BASE
+ if [ $? -ne 0 ] ; then
+ inc_ERROR_CNT
+ fi
+ fi
+done
+
report_ERROR_CNT
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.