Skip to content

Commit

Permalink
Merge pull request #820 from pillar-markup/betterReporting
Browse files Browse the repository at this point in the history
Better reporting
  • Loading branch information
Ducasse authored Aug 3, 2024
2 parents 16716ae + a2e95c2 commit 391409e
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Microdown-BookTester/MicDuplicatedAnchorResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicDuplicatedAnchorResult class >> headerString [

^ 'Duplicated Anchors:'
]

{ #category : 'accessing' }
MicDuplicatedAnchorResult >> isWhat [
^ 'duplicated'
Expand Down
3 changes: 2 additions & 1 deletion src/Microdown-BookTester/MicFileCollector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Class {
{ #category : 'accessing' }
MicFileCollector >> fileSystem [

^ fileSystem ifNil: [ FileSystem disk ]
^ fileSystem
]

{ #category : 'accessing' }
Expand All @@ -38,6 +38,7 @@ MicFileCollector >> fileSystem: aFileSystem [
MicFileCollector >> initialize [

super initialize.
fileSystem := FileSystem disk.
visited := Set new.
unexistingFiles := Set new.
]
Expand Down
38 changes: 33 additions & 5 deletions src/Microdown-BookTester/MicReferenceChecker.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,26 @@ MicReferenceChecker >> addDuplicatedAnchor: anAnchor [
results add: micResultInstance
]

{ #category : 'reporting' }
MicReferenceChecker >> buildReport: str [

| dict |
dict := results groupedBy: [ :each | each class ].
dict keysAndValuesDo: [ :k :v |
str nextPutAll: '## ' ;nextPutAll: k headerString; cr; cr.
self reportElementsOn: str.
str cr; cr.
]
]

{ #category : 'main API' }
MicReferenceChecker >> checkDirectory: aDir [
"Take the directory, parse all its children with microdown file parser and let the visitor visit each time then return visitor is ok which should be true if every thing is okay, the visitor turned out to treat the many documents that it visits as one, so if anchor is duplicated in another file it will detect that . "

self checkList: aDir allFiles
]

{ #category : 'main API' }
{ #category : 'internal' }
MicReferenceChecker >> checkList: aCollection [
"Pay attention checking a file in isolation is DIFFERENT from a list, because a document can have references between them and the checker should be shared amongst the documents since it collects the references."

Expand Down Expand Up @@ -98,7 +110,7 @@ MicReferenceChecker >> collectBadReferences [
badReference do: [ :each | self addBadReferenceAnchor: each ]
]

{ #category : 'reporting' }
{ #category : 'internal' }
MicReferenceChecker >> duplicatedAnchors [

^ duplicatedAnchors
Expand All @@ -123,7 +135,7 @@ MicReferenceChecker >> handleAnchorOf: anElement [

]

{ #category : 'main API' }
{ #category : 'internal' }
MicReferenceChecker >> handleUndefinedFilesFrom: collector [

collector unexistingFiles do: [ :each |
Expand All @@ -147,7 +159,8 @@ MicReferenceChecker >> hasAlreadyDefinedAs: anAnchor [
MicReferenceChecker >> initialize [

super initialize.


fileSystem := FileSystem disk.
results := OrderedCollection new.
references := OrderedCollection new.
anchors := OrderedCollection new.
Expand All @@ -169,13 +182,28 @@ MicReferenceChecker >> isOkay [
^ results isEmpty
]

{ #category : 'reporting' }
MicReferenceChecker >> report [

^ String streamContents: [ :str |
self buildReport: str
]
]

{ #category : 'reporting' }
MicReferenceChecker >> reportElementsOn: aStream [

results do: [ :each | aStream tab; nextPutAll: each explanation ] separatedBy: [ aStream cr ]

]

{ #category : 'accessing' }
MicReferenceChecker >> results [

^ results
]

{ #category : 'reporting' }
{ #category : 'internal' }
MicReferenceChecker >> unknownAnchors [

| unknown ref |
Expand Down
6 changes: 6 additions & 0 deletions src/Microdown-BookTester/MicResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicResult class >> headerString [

^ self subclassResponsibility
]

{ #category : 'accessing' }
MicResult >> explanation [

Expand Down
6 changes: 6 additions & 0 deletions src/Microdown-BookTester/MicUndefinedAnchorResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicUndefinedAnchorResult class >> headerString [

^ 'Undefined Anchors:'
]

{ #category : 'accessing' }
MicUndefinedAnchorResult >> isWhat [
^ 'undefined'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicUndefinedFigureFileResult class >> headerString [

^ 'Undefined figure files:'
]

{ #category : 'accessing' }
MicUndefinedFigureFileResult >> figureFileString: aString [

Expand Down
6 changes: 6 additions & 0 deletions src/Microdown-BookTester/MicUndefinedInputFileResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicUndefinedInputFileResult class >> headerString [

^ 'Undefined input files:'
]

{ #category : 'inputFileBlock:' }
MicUndefinedInputFileResult >> inputFile [

Expand Down

0 comments on commit 391409e

Please sign in to comment.