diff options
author | Grant Goodyear <g2boojum@gentoo.org> | 2004-07-20 18:23:59 +0000 |
---|---|---|
committer | Grant Goodyear <g2boojum@gentoo.org> | 2004-07-20 18:23:59 +0000 |
commit | f10dcac49f75819f216ac7a929968ee1ba179d3a (patch) | |
tree | e943ae5c69147a3600b8675c954db9b1de07a124 /dev-python | |
parent | "x86" stabilization - should solve bug #52098. (Manifest recommit) (diff) | |
download | gentoo-2-f10dcac49f75819f216ac7a929968ee1ba179d3a.tar.gz gentoo-2-f10dcac49f75819f216ac7a929968ee1ba179d3a.tar.bz2 gentoo-2-f10dcac49f75819f216ac7a929968ee1ba179d3a.zip |
GLEP fixos
Diffstat (limited to 'dev-python')
-rw-r--r-- | dev-python/docutils/ChangeLog | 10 | ||||
-rw-r--r-- | dev-python/docutils/Manifest | 9 | ||||
-rw-r--r-- | dev-python/docutils/docutils-0.3.3-r1.ebuild (renamed from dev-python/docutils/docutils-0.3.3.ebuild) | 12 | ||||
-rw-r--r-- | dev-python/docutils/files/digest-docutils-0.3.3-r1 (renamed from dev-python/docutils/files/digest-docutils-0.3.3) | 0 | ||||
-rw-r--r-- | dev-python/docutils/files/glep-0.3.3/glep.py | 27 | ||||
-rw-r--r-- | dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py | 94 | ||||
-rw-r--r-- | dev-python/docutils/files/glep-0.3.3/glepread.py | 61 | ||||
-rw-r--r-- | dev-python/docutils/files/glep-0.3.3/glepstrans.py | 303 |
8 files changed, 508 insertions, 8 deletions
diff --git a/dev-python/docutils/ChangeLog b/dev-python/docutils/ChangeLog index 1892f59c7587..59dbeb6fc0fb 100644 --- a/dev-python/docutils/ChangeLog +++ b/dev-python/docutils/ChangeLog @@ -1,6 +1,14 @@ # ChangeLog for dev-python/docutils # Copyright 2000-2004 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/docutils/ChangeLog,v 1.11 2004/06/25 01:28:18 agriffis Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/docutils/ChangeLog,v 1.12 2004/07/20 18:23:59 g2boojum Exp $ + +*docutils-0.3.3-r1 (20 Jul 2004) + + 20 Jul 2004; Grant Goodyear <g2boojum@gentoo.org> +files/glep-0.3.3/glep.py, + +files/glep-0.3.3/glep_htmlwrite.py, +files/glep-0.3.3/glepread.py, + +files/glep-0.3.3/glepstrans.py, +docutils-0.3.3-r1.ebuild, + -docutils-0.3.3.ebuild: + kloeri broke GLEP stuff w/ 0.3.3; bad boy! *docutils-0.3.3 (12 Jun 2004) diff --git a/dev-python/docutils/Manifest b/dev-python/docutils/Manifest index 64102649892e..932ff47ff5c5 100644 --- a/dev-python/docutils/Manifest +++ b/dev-python/docutils/Manifest @@ -1,12 +1,15 @@ +MD5 1adb353fc60aa2907a41321afe506f94 .docutils-0.3.3.ebuild.swp 12288 MD5 9e8690bd45caee3e3705442c994c1832 docutils-0.3-r1.ebuild 1769 -MD5 8dc99fc674656430788cddd0d5cabf6f docutils-0.3.3.ebuild 1782 +MD5 604482ce0fc9779a272b4ffb44a4b576 docutils-0.3.3.ebuild 1893 MD5 380659477c39ea21d58e46ad227aa743 docutils-0.3_pre20030530-r3.ebuild 1535 MD5 caa2e1245dda46f521d1643db7cbad30 ChangeLog 2447 MD5 71c4638c9c88af75b58e5f5cb54fe008 metadata.xml 159 +MD5 604482ce0fc9779a272b4ffb44a4b576 docutils-0.3.3-r1.ebuild 1893 MD5 fded948d9eac24154eab24b2b56d15d6 files/glepstrans.py 10420 MD5 0a2c7c1478f8b72f97b3d12534b4159e files/glepread.py 1647 MD5 fd7797bcc6dfaac58ec5408e4e3dac99 files/docutils-0.3.3-extramodules.patch 1159 MD5 694b883b9a8f714dc375a547cdf62b1d files/digest-docutils-0.3-r1 64 +MD5 d30e8a9c7f49c164696893c2f39f41ee files/digest-docutils-0.3.3-r1 72 MD5 e3fa7c72245aae7d90beef3bf411583b files/glep_htmlwrite.py 4162 MD5 7c025532adb8b09116980747be7ccc61 files/docutils-0.3-extramodules.patch 1155 MD5 d30e8a9c7f49c164696893c2f39f41ee files/digest-docutils-0.3.3 72 @@ -16,3 +19,7 @@ MD5 52f6ec87bfa6c5c8ec86c85e2a2ed58a files/glep-0.3-r1/glepstrans.py 10428 MD5 d6fc669e125324930e72f2421779a5c2 files/glep-0.3-r1/glepread.py 1647 MD5 a273d63de34b5da93a15764998c054d2 files/glep-0.3-r1/glep_htmlwrite.py 4168 MD5 770e48a59980bce89ab956ab96396a7c files/glep-0.3-r1/glep.py 699 +MD5 32b511950eab0c3e2d8b05818d2f1be2 files/glep-0.3.3/glepstrans.py 10899 +MD5 2beb3a7248f37f2179bd2ec8edd2a40c files/glep-0.3.3/glepread.py 1834 +MD5 e46f32892b6770983b79e2b7ea25b105 files/glep-0.3.3/glep_htmlwrite.py 3247 +MD5 770e48a59980bce89ab956ab96396a7c files/glep-0.3.3/glep.py 699 diff --git a/dev-python/docutils/docutils-0.3.3.ebuild b/dev-python/docutils/docutils-0.3.3-r1.ebuild index 029dbe43497f..b26999769b76 100644 --- a/dev-python/docutils/docutils-0.3.3.ebuild +++ b/dev-python/docutils/docutils-0.3.3-r1.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/docutils/docutils-0.3.3.ebuild,v 1.2 2004/06/25 01:28:18 agriffis Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/docutils/docutils-0.3.3-r1.ebuild,v 1.1 2004/07/20 18:23:59 g2boojum Exp $ inherit distutils eutils @@ -16,7 +16,7 @@ IUSE="" DEPEND=">=dev-lang/python-2.1" # GLEP version -GLEP_SRC=${FILESDIR}/glep-${PVR} +GLEP_SRC=${FILESDIR}/glep-${PV} src_unpack() { unpack ${A} @@ -59,11 +59,11 @@ src_install() { # installing Gentoo GLEP tools. Uses versioned GLEP distribution distutils_python_version - newbin ${GLEP_SRC}/glep.py docutils-glep.py + newbin ${GLEP_SRC}/glep.py docutils-glep.py || die "newbin failed" insinto /usr/lib/python${PYVER}/site-packages/docutils/readers - newins ${GLEP_SRC}/glepread.py glep.py + newins ${GLEP_SRC}/glepread.py glep.py || die "newins reader failed" insinto /usr/lib/python${PYVER}/site-packages/docutils/transforms - newins ${GLEP_SRC}/glepstrans.py gleps.py + newins ${GLEP_SRC}/glepstrans.py gleps.py || "newins transform failed" insinto /usr/lib/python${PYVER}/site-packages/docutils/writers - newins ${GLEP_SRC}/glep_htmlwrite.py glep_html.py + newins ${GLEP_SRC}/glep_htmlwrite.py glep_html.py || die "newins writer failed" } diff --git a/dev-python/docutils/files/digest-docutils-0.3.3 b/dev-python/docutils/files/digest-docutils-0.3.3-r1 index 6fd639a7f34c..6fd639a7f34c 100644 --- a/dev-python/docutils/files/digest-docutils-0.3.3 +++ b/dev-python/docutils/files/digest-docutils-0.3.3-r1 diff --git a/dev-python/docutils/files/glep-0.3.3/glep.py b/dev-python/docutils/files/glep-0.3.3/glep.py new file mode 100644 index 000000000000..e3fb18848833 --- /dev/null +++ b/dev-python/docutils/files/glep-0.3.3/glep.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision: 1.1 $ +# Date: $Date: 2004/07/20 18:23:59 $ +# Copyright: This module has been placed in the public domain. + +""" +A minimal front end to the Docutils Publisher, producing HTML from PEP +(Python Enhancement Proposal) documents. +""" + +import locale +try: + locale.setlocale(locale.LC_ALL, '') +except: + pass + +from docutils.core import publish_cmdline, default_description + + +description = ('Generates (X)HTML from reStructuredText-format PEP files. ' + + default_description) + +publish_cmdline(reader_name='glep', writer_name='glep_html', + description=description) diff --git a/dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py b/dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py new file mode 100644 index 000000000000..710c9d2264fa --- /dev/null +++ b/dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py @@ -0,0 +1,94 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision: 1.1 $ +# Date: $Date: 2004/07/20 18:23:59 $ +# Copyright: This module has been placed in the public domain. + +""" +PEP HTML Writer. +""" + +__docformat__ = 'reStructuredText' + + +import sys +import docutils +from docutils import frontend, nodes, utils +from docutils.writers import html4css1 + + +class Writer(html4css1.Writer): + + settings_spec = html4css1.Writer.settings_spec + ( + 'PEP/HTML-Specific Options', + """The HTML --footnote-references option's default is set to """ + '"brackets".', + (('Specify a template file. Default is "pep-html-template".', + ['--template'], + {'default': 'pep-html-template', 'metavar': '<file>'}), + ('Python\'s home URL. Default is ".." (parent directory).', + ['--python-home'], + {'default': '..', 'metavar': '<URL>'}), + ('Home URL prefix for PEPs. Default is "." (current directory).', + ['--pep-home'], + {'default': '.', 'metavar': '<URL>'}), + # Workaround for SourceForge's broken Python + # (``import random`` causes a segfault). + (frontend.SUPPRESS_HELP, + ['--no-random'], + {'action': 'store_true', 'validator': frontend.validate_boolean}),)) + + settings_default_overrides = {'footnote_references': 'brackets'} + + relative_path_settings = (html4css1.Writer.relative_path_settings + + ('template',)) + + config_section = 'pep_html writer' + config_section_dependencies = ('writers', 'html4css1 writer') + + def __init__(self): + html4css1.Writer.__init__(self) + self.translator_class = HTMLTranslator + + def translate(self): + html4css1.Writer.translate(self) + settings = self.document.settings + template = open(settings.template).read() + # Substitutions dict for template: + subs = {} + subs['encoding'] = settings.output_encoding + subs['version'] = docutils.__version__ + subs['stylesheet'] = ''.join(self.stylesheet) + pyhome = settings.python_home + subs['pyhome'] = pyhome + subs['pephome'] = settings.pep_home + if pyhome == '..': + subs['pepindex'] = '.' + else: + subs['pepindex'] = 'http://www.gentoo.org/proj/en/glep' + index = self.document.first_child_matching_class(nodes.field_list) + header = self.document[index] + pepnum = header[0][1].astext() + subs['pep'] = pepnum + if settings.no_random: + subs['banner'] = 0 + else: + import random + subs['banner'] = random.randrange(64) + try: + subs['pepnum'] = '%04i' % int(pepnum) + except: + subs['pepnum'] = pepnum + subs['title'] = header[1][1].astext() + subs['body'] = ''.join( + self.body_pre_docinfo + self.docinfo + self.body) + subs['body_suffix'] = ''.join(self.body_suffix) + self.output = template % subs + + +class HTMLTranslator(html4css1.HTMLTranslator): + + def depart_field_list(self, node): + html4css1.HTMLTranslator.depart_field_list(self, node) + if node.get('class') == 'rfc2822': + self.body.append('<hr />\n') diff --git a/dev-python/docutils/files/glep-0.3.3/glepread.py b/dev-python/docutils/files/glep-0.3.3/glepread.py new file mode 100644 index 000000000000..807c13161839 --- /dev/null +++ b/dev-python/docutils/files/glep-0.3.3/glepread.py @@ -0,0 +1,61 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision: 1.1 $ +# Date: $Date: 2004/07/20 18:23:59 $ +# Copyright: This module has been placed in the public domain. + +""" +Gentoo Linux Enhancement Proposal (GLEP) Reader. +""" + +__docformat__ = 'reStructuredText' + + +from docutils.readers import standalone +from docutils.transforms import gleps, references +from docutils.parsers import rst + + +class Inliner(rst.states.Inliner): + + """ + Extend `rst.Inliner` for local PEP references. + """ + + pep_url = rst.states.Inliner.pep_url_local + + +class Reader(standalone.Reader): + + supported = ('glep',) + """Contexts this reader supports.""" + + settings_spec = ( + 'PEP Reader Option Defaults', + 'The --pep-references and --rfc-references options (for the ' + 'reStructuredText parser) are on by default.', + ()) + + config_section = 'pep reader' + config_section_dependencies = ('readers', 'standalone reader') + + default_transforms = (references.Substitutions, + gleps.Headers, + gleps.Contents, + references.ChainedTargets, + references.AnonymousHyperlinks, + references.IndirectHyperlinks, + gleps.TargetNotes, + references.Footnotes, + references.ExternalTargets, + references.InternalTargets,) + + settings_default_overrides = {'pep_references': 1, 'rfc_references': 1} + + inliner_class = Inliner + + def __init__(self, parser=None, parser_name=None): + """`parser` should be ``None``.""" + if parser is None: + parser = rst.Parser(rfc2822=1, inliner=self.inliner_class()) + standalone.Reader.__init__(self, parser, '') diff --git a/dev-python/docutils/files/glep-0.3.3/glepstrans.py b/dev-python/docutils/files/glep-0.3.3/glepstrans.py new file mode 100644 index 000000000000..64dafd174b03 --- /dev/null +++ b/dev-python/docutils/files/glep-0.3.3/glepstrans.py @@ -0,0 +1,303 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision: 1.1 $ +# Date: $Date: 2004/07/20 18:23:59 $ +# Copyright: This module has been placed in the public domain. + +""" +Transforms for PEP processing. + +- `Headers`: Used to transform a PEP's initial RFC-2822 header. It remains a + field list, but some entries get processed. +- `Contents`: Auto-inserts a table of contents. +- `PEPZero`: Special processing for PEP 0. +""" + +__docformat__ = 'reStructuredText' + +import sys +import os +import re +import time +from docutils import nodes, utils, languages +from docutils import ApplicationError, DataError +from docutils.transforms import Transform, TransformError +from docutils.transforms import parts, references, misc + + +class Headers(Transform): + + """ + Process fields in a GLEP's initial RFC-2822 header. + """ + + default_priority = 360 + + pep_url = 'glep-%04d.html' + pep_cvs_url = ('http://www.gentoo.org/cgi-bin/viewcvs/' + 'xml/htdocs/proj/en/glep/glep-%04d.txt?cvsroot=gentoo') + rcs_keyword_substitutions = ( + (re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'), + (re.compile(r'\$[a-zA-Z]+: (.+) \$$'), r'\1'),) + + def apply(self): + if not len(self.document): + # @@@ replace these DataErrors with proper system messages + raise DataError('Document tree is empty.') + header = self.document[0] + if not isinstance(header, nodes.field_list) or \ + header.get('class') != 'rfc2822': + raise DataError('Document does not begin with an RFC-2822 ' + 'header; it is not a GLEP.') + pep = None + for field in header: + if field[0].astext().lower() == 'glep': # should be the first field + value = field[1].astext() + try: + pep = int(value) + cvs_url = self.pep_cvs_url % pep + except ValueError: + pep = value + cvs_url = None + msg = self.document.reporter.warning( + '"GLEP" header must contain an integer; "%s" is an ' + 'invalid value.' % pep, base_node=field) + msgid = self.document.set_id(msg) + prb = nodes.problematic(value, value or '(none)', + refid=msgid) + prbid = self.document.set_id(prb) + msg.add_backref(prbid) + if len(field[1]): + field[1][0][:] = [prb] + else: + field[1] += nodes.paragraph('', '', prb) + break + if pep is None: + raise DataError('Document does not contain an RFC-2822 "GLEP" ' + 'header.') + if pep == 0: + # Special processing for PEP 0. + pending = nodes.pending(PEPZero) + self.document.insert(1, pending) + self.document.note_pending(pending) + if len(header) < 2 or header[1][0].astext().lower() != 'title': + raise DataError('No title!') + for field in header: + name = field[0].astext().lower() + body = field[1] + if len(body) > 1: + raise DataError('GLEP header field body contains multiple ' + 'elements:\n%s' % field.pformat(level=1)) + elif len(body) == 1: + if not isinstance(body[0], nodes.paragraph): + raise DataError('GLEP header field body may only contain ' + 'a single paragraph:\n%s' + % field.pformat(level=1)) + elif name == 'last-modified': + date = time.strftime( + '%d-%b-%Y', + time.localtime(os.stat(self.document['source'])[8])) + if cvs_url: + body += nodes.paragraph( + '', '', nodes.reference('', date, refuri=cvs_url)) + else: + # empty + continue + para = body[0] + if name == 'author': + for node in para: + if isinstance(node, nodes.reference): + node.parent.replace(node, mask_email(node)) + elif name == 'discussions-to': + for node in para: + if isinstance(node, nodes.reference): + node.parent.replace(node, mask_email(node, pep)) + elif name in ('replaces', 'replaced-by', 'requires'): + newbody = [] + space = nodes.Text(' ') + for refpep in re.split(',?\s+', body.astext()): + pepno = int(refpep) + newbody.append(nodes.reference( + refpep, refpep, refuri=self.pep_url % pepno)) + newbody.append(space) + para[:] = newbody[:-1] # drop trailing space + elif name == 'last-modified': + utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions) + if cvs_url: + date = para.astext() + para[:] = [nodes.reference('', date, refuri=cvs_url)] + elif name == 'content-type': + pep_type = para.astext() + uri = self.pep_url % 12 + para[:] = [nodes.reference('', pep_type, refuri=uri)] + elif name == 'version' and len(body): + utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions) + + +class Contents(Transform): + + """ + Insert an empty table of contents topic and a transform placeholder into + the document after the RFC 2822 header. + """ + + default_priority = 380 + + def apply(self): + language = languages.get_language(self.document.settings.language_code) + name = language.labels['contents'] + title = nodes.title('', name) + topic = nodes.topic('', title, CLASS='contents') + name = nodes.fully_normalize_name(name) + if not self.document.has_name(name): + topic['name'] = name + self.document.note_implicit_target(topic) + pending = nodes.pending(parts.Contents) + topic += pending + self.document.insert(1, topic) + self.document.note_pending(pending) + + +class TargetNotes(Transform): + + """ + Locate the "References" section, insert a placeholder for an external + target footnote insertion transform at the end, and schedule the + transform to run immediately. + """ + + default_priority = 520 + + def apply(self): + doc = self.document + i = len(doc) - 1 + refsect = copyright = None + while i >= 0 and isinstance(doc[i], nodes.section): + title_words = doc[i][0].astext().lower().split() + if 'references' in title_words: + refsect = doc[i] + break + elif 'copyright' in title_words: + copyright = i + i -= 1 + if not refsect: + refsect = nodes.section() + refsect += nodes.title('', 'References') + doc.set_id(refsect) + if copyright: + # Put the new "References" section before "Copyright": + doc.insert(copyright, refsect) + else: + # Put the new "References" section at end of doc: + doc.append(refsect) + pending = nodes.pending(references.TargetNotes) + refsect.append(pending) + self.document.note_pending(pending, 0) + pending = nodes.pending(misc.CallBack, + details={'callback': self.cleanup_callback}) + refsect.append(pending) + self.document.note_pending(pending, 1) + + def cleanup_callback(self, pending): + """ + Remove an empty "References" section. + + Called after the `references.TargetNotes` transform is complete. + """ + if len(pending.parent) == 2: # <title> and <pending> + pending.parent.parent.remove(pending.parent) + + +class PEPZero(Transform): + + """ + Special processing for PEP 0. + """ + + default_priority =760 + + def apply(self): + visitor = PEPZeroSpecial(self.document) + self.document.walk(visitor) + self.startnode.parent.remove(self.startnode) + + +class PEPZeroSpecial(nodes.SparseNodeVisitor): + + """ + Perform the special processing needed by PEP 0: + + - Mask email addresses. + + - Link PEP numbers in the second column of 4-column tables to the PEPs + themselves. + """ + + pep_url = Headers.pep_url + + def unknown_visit(self, node): + pass + + def visit_reference(self, node): + node.parent.replace(node, mask_email(node)) + + def visit_field_list(self, node): + if node.hasattr('class') and node['class'] == 'rfc2822': + raise nodes.SkipNode + + def visit_tgroup(self, node): + self.pep_table = node['cols'] == 4 + self.entry = 0 + + def visit_colspec(self, node): + self.entry += 1 + if self.pep_table and self.entry == 2: + node['class'] = 'num' + + def visit_row(self, node): + self.entry = 0 + + def visit_entry(self, node): + self.entry += 1 + if self.pep_table and self.entry == 2 and len(node) == 1: + node['class'] = 'num' + p = node[0] + if isinstance(p, nodes.paragraph) and len(p) == 1: + text = p.astext() + try: + pep = int(text) + ref = self.pep_url % pep + p[0] = nodes.reference(text, text, refuri=ref) + except ValueError: + pass + + +non_masked_addresses = ('peps@python.org', + 'python-list@python.org', + 'python-dev@python.org') + +def mask_email(ref, pepno=None): + """ + Mask the email address in `ref` and return a replacement node. + + `ref` is returned unchanged if it contains no email address. + + For email addresses such as "user@host", mask the address as "user at + host" (text) to thwart simple email address harvesters (except for those + listed in `non_masked_addresses`). If a PEP number (`pepno`) is given, + return a reference including a default email subject. + """ + if ref.hasattr('refuri') and ref['refuri'].startswith('mailto:'): + if ref['refuri'][8:] in non_masked_addresses: + replacement = ref[0] + else: + replacement_text = ref.astext().replace('@', ' at ') + replacement = nodes.raw('', replacement_text, format='html') + if pepno is None: + return replacement + else: + ref['refuri'] += '?subject=PEP%%20%s' % pepno + ref[:] = [replacement] + return ref + else: + return ref |