diff --git a/src/MiniDocs/GrafoscopioNode.class.st b/src/MiniDocs/GrafoscopioNode.class.st index 7e9274b..e248ab0 100644 --- a/src/MiniDocs/GrafoscopioNode.class.st +++ b/src/MiniDocs/GrafoscopioNode.class.st @@ -17,11 +17,26 @@ Class { #category : #MiniDocs } +{ #category : #accessing } +GrafoscopioNode >> ancestors [ + "I return a collection of all the nodes wich are ancestors of the receiver node" + | currentNode ancestors | + + currentNode := self. + ancestors := OrderedCollection new. + [ currentNode parent notNil and: [ currentNode level > 0 ] ] + whileTrue: [ + ancestors add: currentNode parent. + currentNode := currentNode parent]. + ancestors := ancestors reversed. + ^ ancestors +] + { #category : #accessing } GrafoscopioNode >> asLePage [ | page | page := LePage new - title: 'Grafoscopio Notebook (imported)'. + initializeTitle: 'Grafoscopio Notebook (imported)'. self nodesInPreorder allButFirst do: [:node | page addSnippet: node asSnippet . ]. @@ -119,6 +134,16 @@ GrafoscopioNode >> header: anObject [ header := anObject ] +{ #category : #accessing } +GrafoscopioNode >> latestEditionDate [ + | latest | + + latest := self nodesWithEditionDates first edited. + self nodesWithEditionDates do: [:node | + node edited >= latest ifTrue: [ latest := node edited ] ]. + ^ latest +] + { #category : #accessing } GrafoscopioNode >> level [ ^ level @@ -171,12 +196,31 @@ GrafoscopioNode >> parent: anObject [ { #category : #accessing } GrafoscopioNode >> populateTimestamps [ - + | adhocCreationMarker adhocEditionMarker | + adhocCreationMarker := 'adhoc creation timestamp'. + adhocEditionMarker := 'adhoc edition timestamp'. (self nodesInPreorder size = self nodesWithCreationDates size and: [ self nodesInPreorder size = self nodesWithEditionDates size ]) ifTrue: [ ^ self nodesInPreorder ]. - ^ { self nodesWithCreationDates. - self nodesWithEditionDates} + self nodesInPreorder allButFirst doWithIndex: [:node :i | + node created ifNil: [ + node created: self earliestCreationDate + i. + node tags add: adhocCreationMarker. + ]. + node edited ifNil: [ + node edited: self earliestCreationDate + i + 1. + node tags add: 'adhoc edition timestamp' + ]. + ]. + self root created ifNil: [ + self root created: self earliestCreationDate - 1. + self root tags add: adhocCreationMarker. + ]. + self root edited ifNil: [ + self root edited: self latestEditionDate. + self root tags add: adhocEditionMarker. + ]. + ^ self nodesInPreorder ] { #category : #accessing } @@ -186,6 +230,12 @@ GrafoscopioNode >> printOn: aStream [ nextPutAll: '( ', self header, ' )' ] +{ #category : #accessing } +GrafoscopioNode >> root [ + self level = 0 ifTrue: [ ^ self ]. + ^ self ancestors first. +] + { #category : #accessing } GrafoscopioNode >> selected [ ^ selected