diff --git a/src/Microdown-BookTester/MicDuplicatedAnchorResult.class.st b/src/Microdown-BookTester/MicDuplicatedAnchorResult.class.st index 63fa3d34..29c91f98 100644 --- a/src/Microdown-BookTester/MicDuplicatedAnchorResult.class.st +++ b/src/Microdown-BookTester/MicDuplicatedAnchorResult.class.st @@ -5,6 +5,12 @@ Class { #package : 'Microdown-BookTester' } +{ #category : 'kinds' } +MicDuplicatedAnchorResult class >> headerString [ + + ^ 'Duplicated Anchors:' +] + { #category : 'accessing' } MicDuplicatedAnchorResult >> isWhat [ ^ 'duplicated' diff --git a/src/Microdown-BookTester/MicFileCollector.class.st b/src/Microdown-BookTester/MicFileCollector.class.st index 223426a4..a5e3a083 100644 --- a/src/Microdown-BookTester/MicFileCollector.class.st +++ b/src/Microdown-BookTester/MicFileCollector.class.st @@ -25,7 +25,7 @@ Class { { #category : 'accessing' } MicFileCollector >> fileSystem [ - ^ fileSystem ifNil: [ FileSystem disk ] + ^ fileSystem ] { #category : 'accessing' } @@ -38,6 +38,7 @@ MicFileCollector >> fileSystem: aFileSystem [ MicFileCollector >> initialize [ super initialize. + fileSystem := FileSystem disk. visited := Set new. unexistingFiles := Set new. ] diff --git a/src/Microdown-BookTester/MicReferenceChecker.class.st b/src/Microdown-BookTester/MicReferenceChecker.class.st index b7e7256d..98b96831 100644 --- a/src/Microdown-BookTester/MicReferenceChecker.class.st +++ b/src/Microdown-BookTester/MicReferenceChecker.class.st @@ -53,6 +53,18 @@ 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 . " @@ -60,7 +72,7 @@ MicReferenceChecker >> checkDirectory: aDir [ 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." @@ -98,7 +110,7 @@ MicReferenceChecker >> collectBadReferences [ badReference do: [ :each | self addBadReferenceAnchor: each ] ] -{ #category : 'reporting' } +{ #category : 'internal' } MicReferenceChecker >> duplicatedAnchors [ ^ duplicatedAnchors @@ -123,7 +135,7 @@ MicReferenceChecker >> handleAnchorOf: anElement [ ] -{ #category : 'main API' } +{ #category : 'internal' } MicReferenceChecker >> handleUndefinedFilesFrom: collector [ collector unexistingFiles do: [ :each | @@ -147,7 +159,8 @@ MicReferenceChecker >> hasAlreadyDefinedAs: anAnchor [ MicReferenceChecker >> initialize [ super initialize. - + + fileSystem := FileSystem disk. results := OrderedCollection new. references := OrderedCollection new. anchors := OrderedCollection new. @@ -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 | diff --git a/src/Microdown-BookTester/MicResult.class.st b/src/Microdown-BookTester/MicResult.class.st index 0ad36942..99c8f08b 100644 --- a/src/Microdown-BookTester/MicResult.class.st +++ b/src/Microdown-BookTester/MicResult.class.st @@ -23,6 +23,12 @@ Class { #package : 'Microdown-BookTester' } +{ #category : 'kinds' } +MicResult class >> headerString [ + + ^ self subclassResponsibility +] + { #category : 'accessing' } MicResult >> explanation [ diff --git a/src/Microdown-BookTester/MicUndefinedAnchorResult.class.st b/src/Microdown-BookTester/MicUndefinedAnchorResult.class.st index fe5b1b1d..2d09e914 100644 --- a/src/Microdown-BookTester/MicUndefinedAnchorResult.class.st +++ b/src/Microdown-BookTester/MicUndefinedAnchorResult.class.st @@ -5,6 +5,12 @@ Class { #package : 'Microdown-BookTester' } +{ #category : 'kinds' } +MicUndefinedAnchorResult class >> headerString [ + + ^ 'Undefined Anchors:' +] + { #category : 'accessing' } MicUndefinedAnchorResult >> isWhat [ ^ 'undefined' diff --git a/src/Microdown-BookTester/MicUndefinedFigureFileResult.class.st b/src/Microdown-BookTester/MicUndefinedFigureFileResult.class.st index 75a914ad..bac5e8e2 100644 --- a/src/Microdown-BookTester/MicUndefinedFigureFileResult.class.st +++ b/src/Microdown-BookTester/MicUndefinedFigureFileResult.class.st @@ -8,6 +8,12 @@ Class { #package : 'Microdown-BookTester' } +{ #category : 'kinds' } +MicUndefinedFigureFileResult class >> headerString [ + + ^ 'Undefined figure files:' +] + { #category : 'accessing' } MicUndefinedFigureFileResult >> figureFileString: aString [ diff --git a/src/Microdown-BookTester/MicUndefinedInputFileResult.class.st b/src/Microdown-BookTester/MicUndefinedInputFileResult.class.st index 93ff6411..170a435e 100644 --- a/src/Microdown-BookTester/MicUndefinedInputFileResult.class.st +++ b/src/Microdown-BookTester/MicUndefinedInputFileResult.class.st @@ -8,6 +8,12 @@ Class { #package : 'Microdown-BookTester' } +{ #category : 'kinds' } +MicUndefinedInputFileResult class >> headerString [ + + ^ 'Undefined input files:' +] + { #category : 'inputFileBlock:' } MicUndefinedInputFileResult >> inputFile [