diff options
| author | smerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-07-03 16:30:52 +0000 |
|---|---|---|
| committer | smerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-07-03 16:30:52 +0000 |
| commit | 83f505337c1876d210166fa02a90025ce2dd337c (patch) | |
| tree | d1201dbf9f4b2af9351aed9f09b6c1613148036e /sandbox/rstdiff | |
| parent | d508c69b562791b9683a6df9324fd5c4c2c73c33 (diff) | |
| download | docutils-83f505337c1876d210166fa02a90025ce2dd337c.tar.gz | |
All unit tests run.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6352 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/rstdiff')
| -rw-r--r-- | sandbox/rstdiff/global.log | 44 | ||||
| -rwxr-xr-x | sandbox/rstdiff/rstdiff.py | 26 | ||||
| -rw-r--r-- | sandbox/rstdiff/tag.log | 2 | ||||
| -rw-r--r-- | sandbox/rstdiff/tests/simple/expected/section.xml | 16 | ||||
| -rw-r--r-- | sandbox/rstdiff/tests/simple/input/section.new.rst | 9 | ||||
| -rw-r--r-- | sandbox/rstdiff/tests/simple/input/section.old.rst | 9 | ||||
| -rw-r--r-- | sandbox/rstdiff/tests/simple/source/section.rst | 13 |
7 files changed, 97 insertions, 22 deletions
diff --git a/sandbox/rstdiff/global.log b/sandbox/rstdiff/global.log index e2e476d6d..dc7013a96 100644 --- a/sandbox/rstdiff/global.log +++ b/sandbox/rstdiff/global.log @@ -1,4 +1,48 @@ ************************************** +Date: Sat Jul 3 18:30:23 CEST 2010 +Author: stefan +Tag: rstdiff_1_50 + +-------------------------------------- +Update of /home/stefan/vault/sm/rstdiff +In directory rosalu:/home/stefan/free/rstdiff + +Modified Files: + rstdiff.py + +-------------------------------------- +Log Message: +Comparsion as child corrected. All unit tests run. +************************************** +Date: Sat Jul 3 18:09:59 CEST 2010 +Author: stefan +Tag: rstdiff_1_49 + +-------------------------------------- +Update of /home/stefan/vault/sm/rstdiff +In directory rosalu:/home/stefan/free/rstdiff + +Modified Files: + rstdiff.py + +-------------------------------------- +Update of /home/stefan/vault/sm/rstdiff/tests/simple/input +In directory rosalu:/home/stefan/free/rstdiff/tests/simple/input + +Modified Files: + section.new.rst section.old.rst + +-------------------------------------- +Update of /home/stefan/vault/sm/rstdiff/tests/simple/source +In directory rosalu:/home/stefan/free/rstdiff/tests/simple/source + +Modified Files: + section.rst + +-------------------------------------- +Log Message: +Improved debugging. +************************************** Date: Sat Jul 3 13:24:31 CEST 2010 Author: stefan Tag: rstdiff_1_48 diff --git a/sandbox/rstdiff/rstdiff.py b/sandbox/rstdiff/rstdiff.py index 1a56f1476..ceb944bdd 100755 --- a/sandbox/rstdiff/rstdiff.py +++ b/sandbox/rstdiff/rstdiff.py @@ -336,7 +336,12 @@ class DocutilsDispatcher(HashableNodeImpl): print("*** %s(%s)" % ( name, ", ".join([ arg.__class__.__name__ for arg in ( node, ) + args ]), )) - return method(node, *args) + for arg in ( node, ) + args: + print(" %s" % ( arg, )) + result = method(node, *args) + if self.debug: + print(" %s" % ( result, )) + return result ########################################################################### ########################################################################### @@ -388,8 +393,8 @@ class DocutilsDispatcher(HashableNodeImpl): return self.dispatchClass('childEq', node, other) def childEq_UNKNOWN(self, node, other): - # We don't know how to compare two nodes of same type as children - return False + # By default compare as a child by comparing children + return self.childrenEq(node, other) def getChildren(self, node): """Return the children of `node` as a list. Subclasses must override @@ -661,7 +666,16 @@ def createDiff(oldTree, newTree): dispatcher = DocutilsDispatcher() #dispatcher.debug = True opcodes = doDiff(dispatcher, oldTree, newTree) + if dispatcher.debug: + from pprint import pprint + print(oldTree.asdom().toprettyxml()) + print(newTree.asdom().toprettyxml()) + pprint(opcodes, sys.stdout, 2, 40, None) + print("^^^ Before cleaning vvv After cleaning") cleanOpcodes(opcodes) + if dispatcher.debug: + from pprint import pprint + pprint(opcodes, sys.stdout, 2, 40, None) if len(opcodes) != 1: raise TypeError("Don't how to merge documents which are not rootEq") opcode = Opcode(opcodes[0]) @@ -669,12 +683,6 @@ def createDiff(oldTree, newTree): raise TypeError("Don't how to merge top level opcode of type %r" % ( opcode.getCommand(), )) - if dispatcher.debug: - from pprint import pprint - print(oldTree.asdom().toprettyxml()) - print(newTree.asdom().toprettyxml()) - pprint(opcodes, sys.stdout, 2, 40, None) - diffDoc = buildDocument(oldTree, newTree, opcodes, pub.settings) if opcode.getCommand() == Opcode.Equal: # TODO Equality should be reported somehow diff --git a/sandbox/rstdiff/tag.log b/sandbox/rstdiff/tag.log index 6c3618b06..d152b5ae8 100644 --- a/sandbox/rstdiff/tag.log +++ b/sandbox/rstdiff/tag.log @@ -1 +1 @@ -rstdiff_1_48 +rstdiff_1_50 diff --git a/sandbox/rstdiff/tests/simple/expected/section.xml b/sandbox/rstdiff/tests/simple/expected/section.xml index 3bff8fd2b..871401c2e 100644 --- a/sandbox/rstdiff/tests/simple/expected/section.xml +++ b/sandbox/rstdiff/tests/simple/expected/section.xml @@ -9,9 +9,9 @@ This is text in the first section. </paragraph> </section> - <section classes="change-added" ids="second-section" names="second\ section"> + <section classes="change-added" ids="section-two" names="section\ two"> <title> - Second section + Section two </title> <paragraph> This was missing. @@ -25,9 +25,17 @@ Text in third section. </paragraph> </section> - <section classes="change-removed" ids="obsolete-section" names="obsolete\ section"> + <section ids="anchor" names="anchor"> <title> - Obsolete section + Anchor + </title> + <paragraph> + Don't reuse words! + </paragraph> + </section> + <section classes="change-removed" ids="obsolete-part" names="obsolete\ part"> + <title> + Obsolete part </title> <paragraph> Obsolete text. diff --git a/sandbox/rstdiff/tests/simple/input/section.new.rst b/sandbox/rstdiff/tests/simple/input/section.new.rst index 76c90ef8d..9052f6e68 100644 --- a/sandbox/rstdiff/tests/simple/input/section.new.rst +++ b/sandbox/rstdiff/tests/simple/input/section.new.rst @@ -3,8 +3,8 @@ First section This is text in the first section. -Second section -============== +Section two +=========== This was missing. @@ -13,6 +13,11 @@ Third section Text in third section. +Anchor +====== + +Don't reuse words! + Fourth section ============== diff --git a/sandbox/rstdiff/tests/simple/input/section.old.rst b/sandbox/rstdiff/tests/simple/input/section.old.rst index 63fd8670b..44a017147 100644 --- a/sandbox/rstdiff/tests/simple/input/section.old.rst +++ b/sandbox/rstdiff/tests/simple/input/section.old.rst @@ -8,8 +8,13 @@ Third section Text in third section. -Obsolete section -================ +Anchor +====== + +Don't reuse words! + +Obsolete part +============= Obsolete text. diff --git a/sandbox/rstdiff/tests/simple/source/section.rst b/sandbox/rstdiff/tests/simple/source/section.rst index 53eef089c..8a7d03ed0 100644 --- a/sandbox/rstdiff/tests/simple/source/section.rst +++ b/sandbox/rstdiff/tests/simple/source/section.rst @@ -5,8 +5,8 @@ This is text in the first section. .. class:: change-added -Second section -============== +Section two +=========== This was missing. @@ -15,10 +15,15 @@ Third section Text in third section. +Anchor +====== + +Don't reuse words! + .. class:: change-removed -Obsolete section -================ +Obsolete part +============= Obsolete text. |
