docstring-checkins Mailing List for Docstring Processing System (Page 14)
Status: Pre-Alpha
Brought to you by:
goodger
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(53) |
Sep
(54) |
Oct
(26) |
Nov
(27) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(60) |
Feb
(85) |
Mar
(94) |
Apr
(40) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: David G. <go...@us...> - 2001-10-20 03:04:40
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv18177/dps/spec Added Files: doctree.txt Log Message: DPS Document Tree Structure --- NEW FILE: doctree.txt --- ============================= DPS Document Tree Structure ============================= :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/10/20 03:04:37 $ This document describes the internal data structure representing document trees in the Python Docstring Processing System. The data structure is defined by classes in the ``dps.nodes`` module. It is also formally described by the `Generic Plaintext Document Interface DTD`_ XML document type definition, gpdi.dtd_, which is the definitive source for element hierarchy details. Below is a simplified diagram of the hierarchy of element types in the DPS document tree structure. An element may contain any other elements immediately below it in the diagram. Note text is in square brackets. Element types in parentheses indicate recursive or one-to-many relationships; sections may contain (sub)sections, tables contain further body elements, etc. :: +--------------------------------------------------------------------+ | document [may begin with a title, subtitle, docinfo] | | +--------------------------------------+ | | sections [each begins with a title] | +-----------------------------+-------------------------+------------+ | divisions | (sections) | +-------------------------------------------------------+------------+ | [body elements:] | | | - literal | - lists | | - hyperlink | | | blocks | - tables | | targets | | para- | - doctest | - block | foot- | - directives | | graphs | blocks | quotes | notes | - comments | +---------+-----------+----------+-------+--------------+ | [text]+ | [text] | (body elements) | [text] | | (inline +-----------+------------------+--------------+ | markup) | +---------+ Representation of Horizontal Rules ================================== Having added the "horizontal rule" construct to the reStructuredText_ spec, a decision had to be made as to how to reflect the construct in the implementation of the document tree. Given this source:: Document ======== Paragraph -------- Paragraph The horizontal rule indicates a "transition" (in prose terms) or the start of a new "division". Before implementation, the parsed document tree would be:: <document> <section name="document"> <title> Document <paragraph> Paragraph -------- <--- error here <paragraph> Paragraph There are several possibilities for the implementation. Solution #2 was chosen. 1. Implement horizontal rules as "divisions" or segments. A "division" is a title-less, non-hierarchical section. The first try at an implementation looked like this:: <document> <section name="document"> <title> Document <paragraph> Paragraph <division> <paragraph> Paragraph But the two paragraphs are really at the same level; they shouldn't appear to be at different levels. There's really an invisible "first division". The horizontal rule splits the document body into two segments, which should be treated uniformly. 2. Treating "divisions" uniformly brings us to the second possibility:: <document> <section name="document"> <title> Document <division> <paragraph> Paragraph <division> <paragraph> Paragraph With this change, documents and sections will directly contain divisions and sections, but not body elements. Only divisions will directly contain body elements. Even without a horizontal rule anywhere, the body elements of a document or section would be contained within a division element. This makes the document tree deeper. This is similar to the way HTML treats document contents: grouped within a <BODY> element. This solution has been chosen. 3. Implement them as "transitions", empty elements:: <document> <section name="document"> <title> Document <paragraph> Paragraph <transition> <paragraph> Paragraph A transition would be a "point element", not containing anything, only identifying a point within the document structure. This keeps the document tree flatter, but the idea of a "point element" like "transition" smells bad. A transition isn't a thing itself, it's the space between two divisions. .. _Generic Plaintext Document Interface DTD: .. _gpdi.dtd: http://docstring.sourceforge.net/spec/gpdi.dtd .. _reStructuredText: http://structuredtext.sourceforge.net/spec/reStructuredText.txt .. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: |
From: David G. <go...@us...> - 2001-10-20 03:02:08
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv17830/dps/spec Modified Files: gpdi.dtd Log Message: - Separated out %link.atts into constituent parts. - Changed %structure.model for mandatory divisions. - Added "refname" and "anonymous" attrbites to "target". - Added "anonymous" attribute to "link". Index: gpdi.dtd =================================================================== RCS file: /cvsroot/docstring/dps/spec/gpdi.dtd,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** gpdi.dtd 2001/10/18 03:32:58 1.17 --- gpdi.dtd 2001/10/20 03:02:05 1.18 *************** *** 36,39 **** --- 36,42 ---- ================================================================== --> + <!-- Boolean: no if zero(s), yes if any other value. --> + <!ENTITY % yesorno "NMTOKEN"> + <!ENTITY % additional.basic.atts ""> <!-- *************** *** 52,77 **** %additional.basic.atts; "> ! <!ENTITY % additional.link.atts ""> ! <!-- ! Hyperlink attributes. ! - `refuri` is used to refer to an external URI/URL. ! - `refid` is used to refer to the `id` attribute of another element. ! - `refname` is used to refer to the `name` attribute of another ! element. ! --> <!ENTITY % link.atts ! " refuri CDATA #IMPLIED ! refid IDREF #IMPLIED ! refname CDATA #IMPLIED %additional.link.atts; "> <!-- XML standard attribute for whitespace-preserving elements. --> <!ENTITY % fixedspace.att " xml:space (default | preserve) #FIXED 'preserve' "> - <!-- Boolean: no if zero(s), yes if any other value. --> - <!ENTITY % yesorno 'NMTOKEN'> - <!-- Element OR-Lists --- 55,86 ---- %additional.basic.atts; "> ! <!-- Reference to an external URI/URL. --> ! <!ENTITY % refuri.att ! " refuri CDATA #IMPLIED "> ! <!-- Reference to the `id` attribute of another element. --> ! <!ENTITY % refid.att ! " refid IDREF #IMPLIED "> ! ! <!-- Reference to the `name` attribute of another element. --> ! <!ENTITY % refname.att ! " refname CDATA #IMPLIED "> ! ! <!ENTITY % additional.link.atts ""> ! <!-- Collected hyperlink attributes. --> <!ENTITY % link.atts ! " %refuri.att; ! %refid.att; ! %refname.att; %additional.link.atts; "> + <!-- Unnamed hyperlink. --> + <!ENTITY % anonymous.att + " anonymous %yesorno; #IMPLIED "> + <!-- XML standard attribute for whitespace-preserving elements. --> <!ENTITY % fixedspace.att " xml:space (default | preserve) #FIXED 'preserve' "> <!-- Element OR-Lists *************** *** 110,115 **** <!ENTITY % structure.model ! " ( ((%body.elements;)+, division*, (%structural.elements;)*) ! | (division+, (%structural.elements;)*) | (%structural.elements;)+ ) "> --- 119,123 ---- <!ENTITY % structure.model ! " ( (division+, (%structural.elements;)*) | (%structural.elements;)+ ) "> *************** *** 340,344 **** <!ELEMENT target (#PCDATA)> ! <!ATTLIST target %basic.atts;> <!ELEMENT directive (%body.elements;)*> --- 348,355 ---- <!ELEMENT target (#PCDATA)> ! <!ATTLIST target ! %basic.atts; ! %refname.att; ! %anonymous.att;> <!ELEMENT directive (%body.elements;)*> *************** *** 400,404 **** <!ATTLIST link %basic.atts; ! %link.atts;> <!ELEMENT footnote_reference (#PCDATA)> --- 411,416 ---- <!ATTLIST link %basic.atts; ! %link.atts; ! %anonymous.att;> <!ELEMENT footnote_reference (#PCDATA)> |
From: David G. <go...@us...> - 2001-10-18 03:36:16
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv16531/dps/spec Modified Files: dps-notes.txt Log Message: updated Index: dps-notes.txt =================================================================== RCS file: /cvsroot/docstring/dps/spec/dps-notes.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dps-notes.txt 2001/09/26 03:33:21 1.13 --- dps-notes.txt 2001/10/18 03:36:12 1.14 *************** *** 51,55 **** - Resolving auto-numbered footnotes & references. - Resolving internal cross-references and indirect hyperlinks. ! These transformations may be turned on or off by individual modes. --- 51,56 ---- - Resolving auto-numbered footnotes & references. - Resolving internal cross-references and indirect hyperlinks. ! - Propagating URIs to chained hyperlink targets. ! These transformations may be turned on or off by individual modes. |
From: David G. <go...@us...> - 2001-10-18 03:35:52
|
Update of /cvsroot/docstring/dps In directory usw-pr-cvs1:/tmp/cvs-serv16453/dps Modified Files: HISTORY.txt Log Message: updated Index: HISTORY.txt =================================================================== RCS file: /cvsroot/docstring/dps/HISTORY.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** HISTORY.txt 2001/09/26 03:33:06 1.19 --- HISTORY.txt 2001/10/18 03:35:50 1.20 *************** *** 143,146 **** --- 143,147 ---- - Added 'error' admonishment element. - Added 'docinfo' as container for bibliographic elements. + - Added 'division'. * spec/pdpi.dtd: *************** *** 149,154 **** - Moved option_list and doctest_block from gpdi.dtd. ! * spec/python-docstring-mode.txt: Added to project (from ! reStructuredText). --- 150,154 ---- - Moved option_list and doctest_block from gpdi.dtd. ! * spec/pysource-reader.txt: Added to project (from reStructuredText). |
From: David G. <go...@us...> - 2001-10-18 03:35:34
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv16398/dps/spec Removed Files: python-docstring-mode.txt Log Message: Renamed to pysource-reader.txt. --- python-docstring-mode.txt DELETED --- |
From: David G. <go...@us...> - 2001-10-18 03:35:24
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv16350/dps/spec Added Files: pysource-reader.txt Log Message: Renamed from python-docstring-mode.txt. --- NEW FILE: pysource-reader.txt --- ====================== Python Source Reader ====================== :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/10/18 03:35:21 $ This document details Python-specific interpretations of the `reStructuredText Markup Specification`_, part of the reStructuredText_ project, in the context of the `Python Docstring Processing System`_. For definitive element hierarchy details, see the "Python Plaintext Document Interface DTD" XML document type definition, ppdi.dtd_ (which modifies the generic gpdi.dtd_). Descriptions below list 'DTD elements' (XML 'generic identifiers' or tag names) corresponding to syntax constructs. Interpreted Text ================ DTD elements: package, module, class, method, function, module_attribute, class_attribute, instance_attribute, variable, parameter, type, exception_class, warning_class. In Python docstrings, interpreted text is used to classify and mark up program identifiers, such as the names of variables, functions, classes, and modules. If the identifier alone is given, its role is inferred implicitly according to the Python namespace lookup rules. For functions and methods (even when dynamically assigned), parentheses ('()') may be included:: This function uses `another()` to do its work. For class, instance and module attributes, dotted identifiers are used when necessary:: class Keeper(Storer): """ Extend `Storer`. Class attribute `instances` keeps track of the number of `Keeper` objects instantiated. """ instances = 0 """How many `Keeper` objects are there?""" def __init__(self): """ Extend `Storer.__init__()` to keep track of instances. Keep count in `self.instances` and data in `self.data`. """ Storer.__init__(self) self.instances += 1 self.data = [] """Store data in a list, most recent last.""" def storedata(self, data): """ Extend `Storer.storedata()`; append new `data` to a list (in `self.data`). """ self.data = data To classify identifiers explicitly, the role is given along with the identifier in either prefix or suffix form:: Use method:`Keeper.storedata` to store the object's data in the `Keeper.data`:instance_attribute. The role may be one of 'package', 'module', 'class', 'method', 'function', 'module_attribute', 'class_attribute', 'instance_attribute', 'variable', 'parameter', 'type', 'exception_class', 'exception', 'warning_class', or 'warning'. Other roles may be defined. .. _reStructuredText Markup Specification: http://structuredtext.sourceforge.net/spec/reStructuredText.txt .. _reStructuredText: http://structuredtext.sourceforge.net .. _Python Docstring Processing System: http://docstring.sourceforge.net .. _ppdi.dtd: http://docstring.sourceforge.net/spec/ppdi.dtd .. _gpdi.dtd: http://docstring.sourceforge.net/spec/gpdi.dtd Local Variables: mode: indented-text indent-tabs-mode: nil fill-column: 70 End: |
From: David G. <go...@us...> - 2001-10-18 03:33:02
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv15853/dps/spec Modified Files: gpdi.dtd Log Message: - Added "division" element. Index: gpdi.dtd =================================================================== RCS file: /cvsroot/docstring/dps/spec/gpdi.dtd,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** gpdi.dtd 2001/09/26 03:21:15 1.16 --- gpdi.dtd 2001/10/18 03:32:58 1.17 *************** *** 110,114 **** <!ENTITY % structure.model ! " ( ((%body.elements;)+, (%structural.elements;)*) | (%structural.elements;)+ ) "> --- 110,115 ---- <!ENTITY % structure.model ! " ( ((%body.elements;)+, division*, (%structural.elements;)*) ! | (division+, (%structural.elements;)*) | (%structural.elements;)+ ) "> *************** *** 208,211 **** --- 209,215 ---- <!ELEMENT section (title, %structure.model;)> <!ATTLIST section %basic.atts;> + + <!ELEMENT division (%body.elements;)+> + <!ATTLIST division %basic.atts;> |
From: David G. <go...@us...> - 2001-09-26 03:33:23
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv11489/dps/spec Modified Files: dps-notes.txt Log Message: updated Index: dps-notes.txt =================================================================== RCS file: /cvsroot/docstring/dps/spec/dps-notes.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dps-notes.txt 2001/09/13 02:16:38 1.12 --- dps-notes.txt 2001/09/26 03:33:21 1.13 *************** *** 31,35 **** - Modules. ! - DTD element semantics. - Get cracking on the DPS itself! --- 31,40 ---- - Modules. ! ! - DPS nodes (DTD element) semantics: ! ! - External (public) attributes (node.attributes). ! - Internal attributes (node.*). ! - Linking mechanism. - Get cracking on the DPS itself! |
From: David G. <go...@us...> - 2001-09-26 03:33:09
|
Update of /cvsroot/docstring/dps In directory usw-pr-cvs1:/tmp/cvs-serv11226/dps Modified Files: HISTORY.txt Log Message: updated Index: HISTORY.txt =================================================================== RCS file: /cvsroot/docstring/dps/HISTORY.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** HISTORY.txt 2001/09/25 03:09:01 1.18 --- HISTORY.txt 2001/09/26 03:33:06 1.19 *************** *** 61,64 **** --- 61,65 ---- - Moved 'abstract' into bibliographic elements section. - Changed 'graphic' to 'image'. + - Added 'docinfo', container for bibliographic elements. * dps/roman.py: Added to project. Written by and courtesy of Mark *************** *** 141,144 **** --- 142,146 ---- - Moved 'caption' to after 'image' in 'figure'. - Added 'error' admonishment element. + - Added 'docinfo' as container for bibliographic elements. * spec/pdpi.dtd: |
From: David G. <go...@us...> - 2001-09-26 03:32:14
|
Update of /cvsroot/docstring/dps/dps In directory usw-pr-cvs1:/tmp/cvs-serv10377/dps/dps Modified Files: nodes.py Log Message: - Added 'docinfo', container for bibliographic elements. Index: nodes.py =================================================================== RCS file: /cvsroot/docstring/dps/dps/nodes.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** nodes.py 2001/09/13 02:12:55 1.10 --- nodes.py 2001/09/26 03:32:11 1.11 *************** *** 408,411 **** --- 408,412 ---- class title(_TextElement): pass class subtitle(_TextElement): pass + class docinfo(_Element): pass class author(_TextElement): pass class authors(_Element): pass |
From: David G. <go...@us...> - 2001-09-26 03:21:18
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv1175/dps/spec Modified Files: gpdi.dtd Log Message: - Added 'docinfo' as container for bibliographic elements. Index: gpdi.dtd =================================================================== RCS file: /cvsroot/docstring/dps/spec/gpdi.dtd,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** gpdi.dtd 2001/09/25 03:02:55 1.15 --- gpdi.dtd 2001/09/26 03:21:15 1.16 *************** *** 148,154 **** <!-- Optional elements may be generated by internal processing. --> ! <!ELEMENT document ! ((title, subtitle?)?, (%bibliographic.elements;)*, abstract?, ! %structure.model;)> <!ATTLIST document %basic.atts;> --- 148,152 ---- <!-- Optional elements may be generated by internal processing. --> ! <!ELEMENT document ((title, subtitle?)?, docinfo?, %structure.model;)> <!ATTLIST document %basic.atts;> *************** *** 165,168 **** --- 163,171 ---- <!ELEMENT subtitle %text.model;> <!ATTLIST subtitle %basic.atts;> + + <!-- Container for bibliographic elements. May not be empty. --> + <!ELEMENT docinfo + (((%bibliographic.elements;)+, abstract?) | abstract)> + <!ATTLIST docinfo %basic.atts;> <!ELEMENT author %text.model;> |
From: David G. <go...@us...> - 2001-09-25 03:09:04
|
Update of /cvsroot/docstring/dps In directory usw-pr-cvs1:/tmp/cvs-serv1245/dps Modified Files: HISTORY.txt Log Message: updated Index: HISTORY.txt =================================================================== RCS file: /cvsroot/docstring/dps/HISTORY.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** HISTORY.txt 2001/09/18 04:34:35 1.17 --- HISTORY.txt 2001/09/25 03:09:01 1.18 *************** *** 127,130 **** --- 127,131 ---- - Fixed typos & omissions; now validates. + - Added 'source' to basic.atts; removed 'rawtext'. - Changed field_argument's model to PCDATA. - Added option_list and doctest_block from ppdi.dtd. |
From: David G. <go...@us...> - 2001-09-25 03:02:57
|
Update of /cvsroot/docstring/dps/spec In directory usw-pr-cvs1:/tmp/cvs-serv32453/dps/spec Modified Files: gpdi.dtd Log Message: - Added 'source' to basic.atts; removed 'rawtext'. Index: gpdi.dtd =================================================================== RCS file: /cvsroot/docstring/dps/spec/gpdi.dtd,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** gpdi.dtd 2001/09/12 03:39:23 1.14 --- gpdi.dtd 2001/09/25 03:02:55 1.15 *************** *** 42,46 **** - `id` is a unique identifier, typically assigned by the system. - `name` is an identifier assigned in the markup. ! - `rawdata` contains the unprocessed text that produced the element. --> <!ENTITY % basic.atts --- 42,47 ---- - `id` is a unique identifier, typically assigned by the system. - `name` is an identifier assigned in the markup. ! - `dupname` is the same as `name`, used when it's a duplicate. ! - `source` is the name of the source of this document or fragment. --> <!ENTITY % basic.atts *************** *** 48,52 **** name CDATA #IMPLIED dupname CDATA #IMPLIED ! rawtext CDATA #IMPLIED %additional.basic.atts; "> --- 49,53 ---- name CDATA #IMPLIED dupname CDATA #IMPLIED ! source CDATA #IMPLIED %additional.basic.atts; "> |
From: David G. <go...@us...> - 2001-09-20 02:57:49
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv4133/dps/test Modified Files: UnitTestFolder.py Log Message: comment correction Index: UnitTestFolder.py =================================================================== RCS file: /cvsroot/docstring/dps/test/UnitTestFolder.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UnitTestFolder.py 2001/09/17 04:12:13 1.1 --- UnitTestFolder.py 2001/09/20 02:57:46 1.2 *************** *** 15,19 **** # So that individual test modules can share a bit of state, ! # `UnitTestPackage` acts as an intermediary for the following # variables: debug = 0 --- 15,19 ---- # So that individual test modules can share a bit of state, ! # `UnitTestFolder` acts as an intermediary for the following # variables: debug = 0 |
From: David G. <go...@us...> - 2001-09-18 04:34:38
|
Update of /cvsroot/docstring/dps In directory usw-pr-cvs1:/tmp/cvs-serv27272/dps Modified Files: HISTORY.txt Log Message: updated Index: HISTORY.txt =================================================================== RCS file: /cvsroot/docstring/dps/HISTORY.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** HISTORY.txt 2001/09/17 04:15:23 1.16 --- HISTORY.txt 2001/09/18 04:34:35 1.17 *************** *** 84,88 **** --- 84,91 ---- - Added named methods (aliases to numbered system_warning calls) to Reporter. + - Removed Reporter.strong_system_warning (not needed). - Added some docstrings. + + * dps/test_*.py: Moved to new test/ directory. * dps/parsers/model.py: |
From: David G. <go...@us...> - 2001-09-18 04:32:15
|
Update of /cvsroot/docstring/dps/dps In directory usw-pr-cvs1:/tmp/cvs-serv26792/dps/dps Modified Files: utils.py Log Message: - Removed Reporter.strong_system_warning as unneeded. Index: utils.py =================================================================== RCS file: /cvsroot/docstring/dps/dps/utils.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** utils.py 2001/09/17 03:54:29 1.6 --- utils.py 2001/09/18 04:32:12 1.7 *************** *** 58,68 **** def severe(self, comment=None, children=[]): return self.system_warning(3, comment, children) - - def strong_system_warning(self, admonition, comment, sourcetext=None): - p = nodes.paragraph() - p += nodes.strong('', admonition) - p += nodes.Text(': ' + comment) - children = [p] - if sourcetext: - children.append(nodes.literal_block('', sourcetext)) - return self.system_warning(3, children=children) --- 58,59 ---- |
From: David G. <go...@us...> - 2001-09-17 04:15:25
|
Update of /cvsroot/docstring/dps In directory usw-pr-cvs1:/tmp/cvs-serv15282/dps Modified Files: HISTORY.txt Log Message: updated Index: HISTORY.txt =================================================================== RCS file: /cvsroot/docstring/dps/HISTORY.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** HISTORY.txt 2001/09/13 02:16:24 1.15 --- HISTORY.txt 2001/09/17 04:15:23 1.16 *************** *** 75,83 **** - Added StateMachine.nextlineblank(). - Added 'nestedSM' and 'nestedSMkwargs' to State. * dps/utils.py: - Added named methods (aliases to numbered system_warning calls) to ! Errorist. * dps/parsers/model.py: --- 75,88 ---- - Added StateMachine.nextlineblank(). - Added 'nestedSM' and 'nestedSMkwargs' to State. + - Added 'uptoblank' optional argument to 'getindented', + 'getknownindented', and 'getfirstknownindented' methods of + StateWS, and to 'extractindented' function. * dps/utils.py: + - Renamed error reporter class to 'Reporter' from 'Errorist'. - Added named methods (aliases to numbered system_warning calls) to ! Reporter. ! - Added some docstrings. * dps/parsers/model.py: *************** *** 95,98 **** --- 100,108 ---- - Changed node class names to node classes. - Removed parser-specific data. + + * test: Subdirectory added. The top-level consists of a modular test + framework begun by Garth Kidd. + + * test/test_utils.py: Converted from doctest to unittest & updated. * spec/pep-0256.txt: |
From: David G. <go...@us...> - 2001-09-17 04:12:16
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv14792/dps/test Added Files: UnitTestFolder.py Log Message: Copy of restructuredtext's test/UnitTestFolder.py --- NEW FILE: UnitTestFolder.py --- #! /usr/bin/env python """ :Author: Garth Kidd :Contact: ga...@de... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/09/17 04:12:13 $ :Copyright: This module has been placed in the public domain. """ import sys, os, getopt, types, unittest, re __all__ = ( 'debug', 'verbosity', 'main' ) # So that individual test modules can share a bit of state, # `UnitTestPackage` acts as an intermediary for the following # variables: debug = 0 verbosity = 1 USAGE = """\ Usage: test_whatever [options] Options: -h, --help Show this message -v, --verbose Verbose output -q, --quiet Minimal output -d, --debug Debug mode """ def usageExit(msg=None): """Print usage and exit.""" if msg: print msg print USAGE sys.exit(2) def parseArgs(argv=sys.argv): """Parse command line arguments and set TestFramework state. State is to be acquired by test_* modules by a grotty hack: ``from TestFramework import *``. For this stylistic transgression, I expect to be first up against the wall when the revolution comes. --Garth""" global verbosity, debug try: options, args = getopt.getopt(argv[1:], 'hHvqd', ['help', 'verbose', 'quiet', 'debug']) for opt, value in options: if opt in ('-h', '-H', '--help'): usageExit() if opt in ('-q', '--quiet'): verbosity = 0 if opt in ('-v', '--verbose'): verbosity = 2 if opt in ('-d', '--debug'): debug =1 if len(args) != 0: usageExit("No command-line arguments supported yet.") except getopt.error, msg: self.usageExit(msg) def loadModulesFromFolder(path, name='', subfolders=None): """ Return a test suite composed of all the tests from modules in a folder. Search for modules in directory `path`, beginning with `name`. If `subfolders` is true, search subdirectories (also beginning with `name`) recursively. """ testLoader = unittest.defaultTestLoader testSuite = unittest.TestSuite() testModules = [] paths = [path] while paths: p = paths.pop(0) if not p: p = os.curdir files = os.listdir(p) for filename in files: if filename.startswith(name): fullpath = os.path.join(p, filename) if filename.endswith('.py'): testModules.append(fullpath) elif subfolders and os.path.isdir(fullpath): paths.append(fullpath) sys.path.insert(0, '') # Import modules and add their tests to the suite. for modpath in testModules: if debug: print >>sys.stderr, "importing %s" % modpath sys.path[0], filename = os.path.split(modpath) modname = filename[:-3] # strip off the '.py' module = __import__(modname) # if there's a suite defined, incorporate its contents try: suite = getattr(module, 'suite') if type(suite) == types.FunctionType: testSuite.addTest(suite()) elif type(suite) == types.InstanceType \ and isinstance(suite, unittest.TestSuite): testSuite.addTest(suite) else: raise AssertionError, "don't understand suite" except AttributeError: # Look for individual tests moduleTests = testLoader.loadTestsFromModule(module) # unittest.TestSuite.addTests() doesn't work as advertised, # as it can't load tests from another TestSuite, so we have # to cheat: testSuite.addTest(moduleTests) return testSuite def main(suite=None): """ Shared `main` for any individual test_* file. suite -- TestSuite to run. If not specified, look for any globally defined tests and run them. """ parseArgs() if suite is None: # Load any globally defined tests. suite = unittest.defaultTestLoader.loadTestsFromModule(__import__('__main__')) if debug: print >>sys.stderr, "Debug: Suite=%s" % suite testRunner = unittest.TextTestRunner(verbosity=verbosity) # run suites (if we were called from test_all) or suite... if type(suite) == type([]): for s in suite: testRunner.run(s) else: testRunner.run(suite) |
From: David G. <go...@us...> - 2001-09-17 04:11:05
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv14448/dps/test Added Files: test_utils.py Log Message: from dps/test_utils.py Converted from doctest to unittest & updated. --- NEW FILE: test_utils.py --- #! /usr/bin/env python """ :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/09/17 04:11:02 $ :Copyright: This module has been placed in the public domain. Test module for utils.py. """ import unittest, StringIO from DPSTestSupport import utils try: import mypdb as pdb except: import pdb pdb.tracenow = 0 class ReporterTests(unittest.TestCase): stream = StringIO.StringIO() reporter = utils.Reporter(1, 3, stream) def setUp(self): self.stream.seek(0) self.stream.truncate() def test_level0(self): sw = self.reporter.system_warning(0, 'a little reminder') self.assertEquals(sw.pformat(), """\ <system_warning level="0"> <paragraph> a little reminder """) self.assertEquals(self.stream.getvalue(), '') def test_level1(self): sw = self.reporter.system_warning(1, 'a warning') self.assertEquals(sw.pformat(), """\ <system_warning level="1"> <paragraph> a warning """) self.assertEquals(self.stream.getvalue(), 'Warning: [level 1] a warning\n') def test_level2(self): sw = self.reporter.system_warning(2, 'an error') self.assertEquals(sw.pformat(), """\ <system_warning level="2"> <paragraph> an error """) self.assertEquals(self.stream.getvalue(), 'Warning: [level 2] an error\n') def test_level3(self): self.assertRaises(utils.SystemWarning, self.reporter.system_warning, 3, 'a severe error, raises an exception') self.assertEquals(self.stream.getvalue(), '') class QuietReporterTests(unittest.TestCase): stream = StringIO.StringIO() reporter = utils.Reporter(4, 4, stream) def setUp(self): self.stream.seek(0) self.stream.truncate() def test_information(self): sw = self.reporter.information('an informational message') self.assertEquals(sw.pformat(), """\ <system_warning level="0"> <paragraph> an informational message """) self.assertEquals(self.stream.getvalue(), '') def test_warning(self): sw = self.reporter.warning('a warning') self.assertEquals(sw.pformat(), """\ <system_warning level="1"> <paragraph> a warning """) self.assertEquals(self.stream.getvalue(), '') def test_error(self): sw = self.reporter.error('an error') self.assertEquals(sw.pformat(), """\ <system_warning level="2"> <paragraph> an error """) self.assertEquals(self.stream.getvalue(), '') def test_severe(self): sw = self.reporter.severe('a severe error') self.assertEquals(sw.pformat(), """\ <system_warning level="3"> <paragraph> a severe error """) self.assertEquals(self.stream.getvalue(), '') if __name__ == '__main__': unittest.main() |
From: David G. <go...@us...> - 2001-09-17 04:06:07
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv13672/dps/test Added Files: test_statemachine.py Log Message: from dps/test_statemachine.py --- NEW FILE: test_statemachine.py --- #! /usr/bin/env python """ :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/09/17 04:06:05 $ :Copyright: This module has been placed in the public domain. Test module for statemachine.py. """ import unittest, sys, re from DPSTestSupport import statemachine try: import mypdb as pdb except: import pdb pdb.tracenow = 0 debug = 0 testtext = statemachine.string2lines("""\ First paragraph. - This is a bullet list. First list item. Second line of first para. Second para. block quote - Second list item. Example:: a literal block Last paragraph.""") expected = ('StateMachine1 text1 blank1 bullet1 knownindent1 ' 'StateMachine2 text2 text2 blank2 text2 blank2 indent2 ' 'StateMachine3 text3 finished3 finished2 ' 'bullet1 knownindent1 ' 'StateMachine2 text2 blank2 literalblock2(4) finished2 ' 'text1 finished1').split() para1 = testtext[:2] item1 = [line[2:] for line in testtext[2:8]] item2 = [line[2:] for line in testtext[9:-2]] lbindent = 6 literalblock = [line[lbindent:] for line in testtext[11:-2]] para2 = testtext[-1] class MockState(statemachine.StateWS): patterns = {'bullet': re.compile(r'- '), 'text': ''} initialtransitions = ['bullet', ['text']] levelholder = [0] def bof(self, context): self.levelholder[0] += 1 self.level = self.levelholder[0] if self.debug: print >>sys.stderr, 'StateMachine%s' % self.level return [], ['StateMachine%s' % self.level] def blank(self, match, context, nextstate): result = ['blank%s' % self.level] if self.debug: print >>sys.stderr, 'blank%s' % self.level if context and context[-1] and context[-1][-2:] == '::': result.extend(self.literalblock()) return [], None, result def indent(self, match, context, nextstate): if self.debug: print >>sys.stderr, 'indent%s' % self.level context, nextstate, result = statemachine.StateWS.indent( self, match, context, nextstate) return context, nextstate, ['indent%s' % self.level] + result def knownindent(self, match, context, nextstate): if self.debug: print >>sys.stderr, 'knownindent%s' % self.level context, nextstate, result = statemachine.StateWS.knownindent( self, match, context, nextstate) return context, nextstate, ['knownindent%s' % self.level] + result def bullet(self, match, context, nextstate): if self.debug: print >>sys.stderr, 'bullet%s' % self.level context, nextstate, result \ = self.knownindent(match, context, nextstate) return [], nextstate, ['bullet%s' % self.level] + result def text(self, match, context, nextstate): if self.debug: print >>sys.stderr, 'text%s' % self.level return [match.string], nextstate, ['text%s' % self.level] def literalblock(self): indented, indent, offset, good = self.statemachine.getindented() if self.debug: print >>sys.stderr, 'literalblock%s(%s)' % (self.level, indent) return ['literalblock%s(%s)' % (self.level, indent)] def eof(self, context): self.levelholder[0] -= 1 if self.debug: print >>sys.stderr, 'finished%s' % self.level return ['finished%s' % self.level] class EmptySMTests(unittest.TestCase): def setUp(self): self.sm = statemachine.StateMachine( stateclasses=[], initialstate='State') self.sm.debug = debug def test_addstate(self): self.sm.addstate(statemachine.State) self.assert_(len(self.sm.states) == 1) self.assertRaises(statemachine.DuplicateStateError, self.sm.addstate, statemachine.State) self.sm.addstate(statemachine.StateWS) self.assert_(len(self.sm.states) == 2) def test_addstates(self): self.sm.addstates((statemachine.State, statemachine.StateWS)) self.assertEqual(len(self.sm.states), 2) def test_getstate(self): self.assertRaises(statemachine.UnknownStateError, self.sm.getstate) self.sm.addstates((statemachine.State, statemachine.StateWS)) self.assertRaises(statemachine.UnknownStateError, self.sm.getstate, 'unknownState') self.assert_(isinstance(self.sm.getstate('State'), statemachine.State)) self.assert_(isinstance(self.sm.getstate('StateWS'), statemachine.State)) self.assertEqual(self.sm.currentstate, 'StateWS') class EmptySMWSTests(EmptySMTests): def setUp(self): self.sm = statemachine.StateMachineWS( stateclasses=[], initialstate='State') self.sm.debug = debug class SMWSTests(unittest.TestCase): def setUp(self): self.sm = statemachine.StateMachineWS([MockState], 'MockState', debug=debug) self.sm.debug = debug self.sm.states['MockState'].levelholder[0] = 0 def tearDown(self): self.sm.unlink() def test___init__(self): self.assertEquals(self.sm.states.keys(), ['MockState']) self.assertEquals(len(self.sm.states['MockState'].transitions), 2) def test_getindented(self): self.sm.inputlines = testtext self.sm.lineoffset = -1 self.sm.nextline(3) indented, offset, good = self.sm.getknownindented(2) self.assertEquals(indented, item1) self.assertEquals(offset, len(para1)) self.failUnless(good) self.sm.nextline() indented, offset, good = self.sm.getknownindented(2) self.assertEquals(indented, item2) self.assertEquals(offset, len(para1) + len(item1) + 1) self.failUnless(good) self.sm.previousline(3) if self.sm.debug: print '\ntest_getindented: self.sm.line:\n', self.sm.line indented, indent, offset, good = self.sm.getindented() if self.sm.debug: print '\ntest_getindented: indented:\n', indented self.assertEquals(indent, lbindent) self.assertEquals(indented, literalblock) self.assertEquals(offset, (len(para1) + len(item1) + len(item2) + 1 - len(literalblock))) self.failUnless(good) def test_gettextblock(self): self.sm.inputlines = testtext self.sm.lineoffset = -1 self.sm.nextline() textblock = self.sm.gettextblock() self.assertEquals(textblock, testtext[:1]) self.sm.nextline(2) textblock = self.sm.gettextblock() self.assertEquals(textblock, testtext[2:4]) def test_getunindented(self): self.sm.inputlines = testtext self.sm.lineoffset = -1 self.sm.nextline() textblock = self.sm.getunindented() self.assertEquals(textblock, testtext[:1]) self.sm.nextline() self.assertRaises(statemachine.UnexpectedIndentationError, self.sm.getunindented) def test_run(self): self.assertEquals(self.sm.run(testtext), expected) class EmptyClass: pass class EmptyStateTests(unittest.TestCase): def setUp(self): self.state = statemachine.State(EmptyClass(), debug=debug) self.state.patterns = {'nop': 'dummy', 'nop2': 'dummy', 'nop3': 'dummy', 'bogus': 'dummy'} self.state.nop2 = self.state.nop3 = self.state.nop def test_addtransitions(self): self.assertEquals(len(self.state.transitions), 0) self.state.addtransitions(['None'], {'None': None}) self.assertEquals(len(self.state.transitions), 1) self.assertRaises(statemachine.UnknownTransitionError, self.state.addtransitions, ['bogus'], {}) self.assertRaises(statemachine.DuplicateTransitionError, self.state.addtransitions, ['None'], {'None': None}) def test_addtransition(self): self.assertEquals(len(self.state.transitions), 0) self.state.addtransition('None', None) self.assertEquals(len(self.state.transitions), 1) self.assertRaises(statemachine.DuplicateTransitionError, self.state.addtransition, 'None', None) def test_removetransition(self): self.assertEquals(len(self.state.transitions), 0) self.state.addtransition('None', None) self.assertEquals(len(self.state.transitions), 1) self.state.removetransition('None') self.assertEquals(len(self.state.transitions), 0) self.assertRaises(statemachine.UnknownTransitionError, self.state.removetransition, 'None') def test_maketransition(self): dummy = re.compile('dummy') self.assertEquals(self.state.maketransition('nop', 'bogus'), (dummy, self.state.nop, 'bogus')) self.assertEquals(self.state.maketransition('nop'), (dummy, self.state.nop, self.state.__class__.__name__)) self.assertRaises(statemachine.TransitionPatternNotFound, self.state.maketransition, 'None') self.assertRaises(statemachine.TransitionMethodNotFound, self.state.maketransition, 'bogus') def test_maketransitions(self): dummy = re.compile('dummy') self.assertEquals(self.state.maketransitions(('nop', ['nop2'], ('nop3', 'bogus'))), (['nop', 'nop2', 'nop3'], {'nop': (dummy, self.state.nop, self.state.__class__.__name__), 'nop2': (dummy, self.state.nop2, self.state.__class__.__name__), 'nop3': (dummy, self.state.nop3, 'bogus')})) class MiscTests(unittest.TestCase): s2l_string = "hello\tthere\thow are\tyou?\n\tI'm fine\tthanks.\n" s2l_expected = ['hello there how are you?', " I'm fine thanks."] indented_string = """\ a literal block""" def test_string2lines(self): self.assertEquals(statemachine.string2lines(self.s2l_string), self.s2l_expected) def test_extractindented(self): block = statemachine.string2lines(self.indented_string) self.assertEquals(statemachine.extractindented(block), ([s[6:] for s in block], 6, 1)) self.assertEquals(statemachine.extractindented(self.s2l_expected), ([], 0, 0)) if __name__ == '__main__': unittest.main() |
From: David G. <go...@us...> - 2001-09-17 04:05:02
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv13487/dps/test Added Files: test_nodes.py Log Message: from dps/test_nodes.py --- NEW FILE: test_nodes.py --- #! /usr/bin/env python """ :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/09/17 04:04:59 $ :Copyright: This module has been placed in the public domain. Test module for nodes.py. """ import unittest from DPSTestSupport import nodes debug = 0 class TextTests(unittest.TestCase): def setUp(self): self.text = nodes.Text('Line 1.\nLine 2.') def test_repr(self): self.assertEquals(repr(self.text), r"<#text: 'Line 1.\nLine 2.'>") def test_str(self): self.assertEquals(str(self.text), 'Line 1.\nLine 2.') def test_asdom(self): dom = self.text.asdom() self.assertEquals(dom.toxml(), 'Line 1.\nLine 2.') dom.unlink() def test_astext(self): self.assertEquals(self.text.astext(), 'Line 1.\nLine 2.') def test_pformat(self): self.assertEquals(self.text.pformat(), 'Line 1.\nLine 2.\n') class ElementTests(unittest.TestCase): def test_empty(self): element = nodes._Element() self.assertEquals(repr(element), '<_Element: >') self.assertEquals(str(element), '<_Element/>') dom = element.asdom() self.assertEquals(dom.toxml(), '<_Element/>') dom.unlink() element['attr'] = '1' self.assertEquals(repr(element), '<_Element: >') self.assertEquals(str(element), '<_Element attr="1"/>') dom = element.asdom() self.assertEquals(dom.toxml(), '<_Element attr="1"/>') dom.unlink() self.assertEquals(element.pformat(), '<_Element attr="1">\n') def test_withtext(self): element = nodes._Element('text\nmore', nodes.Text('text\nmore')) self.assertEquals(repr(element), r"<_Element: <#text...>>") self.assertEquals(str(element), '<_Element>text\nmore</_Element>') dom = element.asdom() self.assertEquals(dom.toxml(), '<_Element>text\nmore</_Element>') dom.unlink() element['attr'] = '1' self.assertEquals(repr(element), r"<_Element: <#text...>>") self.assertEquals(str(element), '<_Element attr="1">text\nmore</_Element>') dom = element.asdom() self.assertEquals(dom.toxml(), '<_Element attr="1">text\nmore</_Element>') dom.unlink() self.assertEquals(element.pformat(), """\ <_Element attr="1"> text more """) if __name__ == '__main__': unittest.main() |
From: David G. <go...@us...> - 2001-09-17 04:04:09
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv13371/dps/test Added Files: DPSTestSupport.py Log Message: Import & other support for tests. --- NEW FILE: DPSTestSupport.py --- #! /usr/bin/env python """ :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/09/17 04:04:07 $ :Copyright: This module has been placed in the public domain. Exports the following: :Modules: Try to import modules from the current working copy of dps first, or from the installed version. In test modules, import these modules from here: - `statemachine` is 'dps.statemachine' - `nodes` is 'dps.nodes' - `utils` is 'dps.utils' """ __docformat__ = 'reStructuredText' import UnitTestFolder import sys, os #, unittest, re, difflib, types, inspect #from pprint import pformat # try to import the current working version if possible sys.path.insert(0, os.pardir) # running in test framework dir? import dps # or restructuredtext on path? from dps import statemachine, nodes, utils try: import mypdb as pdb except: import pdb |
From: David G. <go...@us...> - 2001-09-17 04:02:28
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv12697/dps/test Added Files: alltests.py Log Message: Run all tests. --- NEW FILE: alltests.py --- #!/usr/bin/env python """ :Author: David Goodger :Contact: go...@us... :Revision: $Revision: 1.1 $ :Date: $Date: 2001/09/17 04:02:26 $ :Copyright: This module has been placed in the public domain. """ import time start = time.time() import sys, os class Tee: """Write to a file and a stream (default: stdout) simultaneously.""" def __init__(self, filename, stream=sys.__stdout__): self.file = open(filename, 'w') self.stream = stream def write(self, string): self.stream.write(string) self.file.write(string) # must redirect stderr *before* first import of unittest sys.stdout = sys.stderr = Tee('alltests.out') import UnitTestFolder if __name__ == '__main__': path, script = os.path.split(sys.argv[0]) suite = UnitTestFolder.loadModulesFromFolder(path, 'test_', subfolders=1) UnitTestFolder.main(suite) finish = time.time() print 'Elapsed time: %.3f seconds' % (finish - start) |
From: David G. <go...@us...> - 2001-09-17 03:59:34
|
Update of /cvsroot/docstring/dps/test In directory usw-pr-cvs1:/tmp/cvs-serv12211/test Log Message: Directory /cvsroot/docstring/dps/test added to the repository |
From: David G. <go...@us...> - 2001-09-17 03:59:10
|
Update of /cvsroot/docstring/dps/dps In directory usw-pr-cvs1:/tmp/cvs-serv12130/dps/dps Removed Files: test_utils.py Log Message: Moved out of DPS package into test directory. --- test_utils.py DELETED --- |