Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/Microdown-BookTester/MicAbstractResult.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Class {
#name : 'MicAbstractResult',
#superclass : 'MicResult',
#instVars : [
'micElement',
'fileReference'
],
#category : 'Microdown-BookTester-Checker-LastPeriod',
#package : 'Microdown-BookTester',
#tag : 'Checker-LastPeriod'
}

{ #category : 'accessing' }
MicAbstractResult >> fileReference [

^ fileReference
]

{ #category : 'accessing' }
MicAbstractResult >> fileReference: anObject [

fileReference := anObject
]

{ #category : 'accessing' }
MicAbstractResult >> inFile: aFileReference [
fileReference := aFileReference
]

{ #category : 'accessing' }
MicAbstractResult >> micElement [

^ micElement
]

{ #category : 'accessing' }
MicAbstractResult >> micElement: aMicElement [
micElement := aMicElement
]

{ #category : 'accessing' }
MicAbstractResult >> sourceFileReference [
^ fileReference
]
4 changes: 2 additions & 2 deletions src/Microdown-BookTester/MicAnchorResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MicAnchorResult >> anchorLabel: anObject [
{ #category : 'accessing' }
MicAnchorResult >> explanation [

^ 'Anchor ', anchorLabel, ' is ', self isWhat, ' in file: ', fileReference fullName
^ 'Anchor ', anchorLabel, ' is ', self isWhat, ' in file: ', source fullName

]

Expand All @@ -46,6 +46,6 @@ MicAnchorResult >> isWhat [
{ #category : 'accessing' }
MicAnchorResult >> stonFormatExplanation [

^ Association new key: anchorLabel value: fileReference
^ Association new key: anchorLabel value: source

]
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ MicAnchoredSectionTableFigureChecker >> addErrorDetail: detailString on: aTextBl
yourself)
]

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> analyzeWords: words inTextBlock: aTextBlock inParagraph: aParagraph anchorBlock: anchorBlock [

anchoredElements do: [ :ref |
self checkNamingFor: words
reference: ref
anchorBlock: anchorBlock
inTextBlock: aTextBlock
inParagraph: aParagraph.
self checkMissingAnchorsFor: words
reference: ref
anchorBlock: anchorBlock
inTextBlock: aTextBlock
inParagraph: aParagraph ]
]

{ #category : 'accessing' }
MicAnchoredSectionTableFigureChecker >> anchoredElements [

Expand All @@ -75,7 +59,6 @@ MicAnchoredSectionTableFigureChecker >> anchoredElements [

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> checkMissingAnchorsFor: words reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph [

| lastWord |
lastWord := words last.
words do: [ :word |
Expand All @@ -85,30 +68,25 @@ MicAnchoredSectionTableFigureChecker >> checkMissingAnchorsFor: words reference:

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> checkNamingFor: words reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph [

| lastWord anchorString |
anchorBlock ifNil: [ ^ self ].
lastWord := words last.
lastWord asLowercase = ref ifFalse: [ ^ self ].

(words size > 1 and: [
(words at: words size - 1) asLowercase = 'the' ])
(words size > 1 and: [ (words at: words size - 1) asLowercase = 'the' ])
ifTrue: [
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ])
, '@*'.
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ]) , '@*'.
self
addErrorDetail: (words at: words size - 1) , ' ' , lastWord , anchorString
on: aTextBlock
inParagraph: aParagraph ]
ifFalse: [
lastWord = ref ifTrue: [
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ]) , '@*'.
self
addErrorDetail:
(words at: words size - 1) , ' ' , lastWord , anchorString
addErrorDetail: lastWord , anchorString
on: aTextBlock
inParagraph: aParagraph ]
ifFalse: [
lastWord = ref ifTrue: [
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ])
, '@*'.
self
addErrorDetail: lastWord , anchorString
on: aTextBlock
inParagraph: aParagraph ] ]
inParagraph: aParagraph ] ]
]

{ #category : 'configuration' }
Expand All @@ -132,13 +110,17 @@ MicAnchoredSectionTableFigureChecker >> initialize [
{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> processTextBlock: aTextBlock atIndex: index withChildren: children inParagraph: aParagraph [
| words anchorBlock |

words := aTextBlock bodyString substrings.
words isEmpty ifTrue: [ ^ self ].
anchorBlock := (index < children size and: [ (children at: index + 1) isKindOf: MicAnchorReferenceBlock ])

anchorBlock := (index < children size and: [ (children at: index + 1) isAnchorReferenceBlock ])
ifTrue: [ children at: index + 1 ]
ifFalse: [ nil ].

self analyzeWords: words inTextBlock: aTextBlock inParagraph: aParagraph anchorBlock: anchorBlock
anchoredElements do: [ :ref |
self checkNamingFor: words reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph.
self checkMissingAnchorsFor: words reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph ]
]

{ #category : 'visiting' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Class {
#superclass : 'TestCase',
#instVars : [
'fileSystem',
'checker'
'checker',
'inFile'
],
#category : 'Microdown-BookTester-Checker-BookTester',
#package : 'Microdown-BookTester',
Expand Down
6 changes: 3 additions & 3 deletions src/Microdown-BookTester/MicBookTestResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ MicBookTestResult >> explanation [
self text ,
String cr ,
'from the source file: ' ,
self inFile fullName
self sourceFileReference fullName


]
Expand Down Expand Up @@ -117,7 +117,7 @@ MicBookTestResult >> initialize [
isExpectedFailure := false.
message := 'Test failed without raising an exception'.
text := 'here we should get an expression'.
fileReference := '' asFileReference.
source := '' asFileReference.
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -160,7 +160,7 @@ MicBookTestResult >> stonFormatExplanation [
self text , '",',
String cr ,
'"sourceFile" : "' ,
self inFile fullname , '"',
self sourceFileReference fullname , '"',
String cr , '}'


Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicCheckerHTMLReporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MicCheckerHTMLReporter >> buildResultsOn: aStream [
nextPutAll: '<div class="section err-section"><div class="section-header" onclick="toggle(this)"><span class="section-badge badge-error">' , count printString , ' error' , (count = 1 ifTrue: [''] ifFalse: ['s']) , '</span><span class="section-title">' , (self htmlEscape: header) , '</span><span class="chevron open">&#9660;</span></div><div class="section-body">'.
errorList do: [ :r |
| lineNum srcFile searchText fullPath shortMsg context |
srcFile := r inFile ifNil: [ fileReference ].
srcFile := r sourceFileReference ifNil: [ fileReference ].
searchText := ((r class methodDict includesKey: #what) and: [ r what notNil and: [ r what notEmpty ] ])
ifTrue: [ r what ]
ifFalse: [
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicCodeIndentationResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MicCodeIndentationResult >> detail: anObject [
{ #category : 'accessing' }
MicCodeIndentationResult >> explanation [
^ 'Text: "' , micElement body
, '" in file' , self inFile fullName
, '" in file' , fileReference fullName
, ' contains a mistake: line ['
, detail
, '] should use tabs instead of spaces for indentation.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MicDesynchronizedCodeResult >> bookContents: aString [
{ #category : 'accessing' }
MicDesynchronizedCodeResult >> explanation [

^ 'The code block body of ', originString , ' is not in sync with the version in Pharo ', pharoVersion, 'in file: ', self inFile fullName
^ 'The code block body of ', originString , ' is not in sync with the version in Pharo ', pharoVersion, 'in file: ', source fullName
]

{ #category : 'accessing' }
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicDoublePeriodResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Class {
{ #category : 'accessing' }
MicDoublePeriodResult >> explanation [

^ 'Text: "' , micElement text , '" in file' , self inFile fullName , ' contains two periods.'
^ 'Text: "' , micElement text , '" in file' , fileReference fullName , ' contains two periods.'
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Class {

{ #category : 'accessing' }
MicElementAfterColonIsNotCapitalizedResult >> explanation [
^ 'Header: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: ', detail , ' as first letter after a colon should be uppercased.'
^ 'Header: "' , micElement text , '" in file' , fileReference fullName , ' contains a mistake: ', detail , ' as first letter after a colon should be uppercased.'
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Class {

{ #category : 'accessing' }
MicElementOfHeaderIsNotCapitalizedResult >> explanation [
^ 'Header: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: ' , detail , ' should be capitalized.'
^ 'Header: "' , micElement text , '" in file' , fileReference fullName , ' contains a mistake: ' , detail , ' should be capitalized.'
]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MicEnglishTypographyResult >> explanation [
self flag: #todo.
"this looks like a bug or hidden a bug!"

^ 'Text: "' , text , '" in file' , self inFile fullName , ' contains a mistake: ', detail
^ 'Text: "' , text , '" in file' , fileReference fullName , ' contains a mistake: ', detail
]

{ #category : 'kinds' }
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicExampleTesterStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ MicExampleTesterStrategy >> verify: aCodeBlock [
| result |
result := MicBookTestResult new.
result text: aCodeBlock code.
result inFile: aCodeBlock fromFile.
result sourceFileReference: aCodeBlock fromFile.
results add: result.
self executeAndReportIn: result.
aCodeBlock isExpectedFailure
Expand Down
25 changes: 0 additions & 25 deletions src/Microdown-BookTester/MicFileNameWithSpaceChecker.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,3 @@ Class {
#package : 'Microdown-BookTester',
#tag : 'FilesWithSpace'
}

{ #category : 'accessing' }
MicFileNameWithSpaceChecker >> errors [
^ errors ifNil: [ errors := OrderedCollection new ]
]

{ #category : 'accessing' }
MicFileNameWithSpaceChecker >> proposedNameFor: aFigure [
^ aFigure url copyReplaceAll: ' ' with: '-'
]

{ #category : 'accessing' }
MicFileNameWithSpaceChecker >> renameFileOnDiskFor: aFigure [
| oldFile newName |
oldFile := aFigure url asFileReference.
newName := self proposedNameFor: aFigure.
oldFile exists ifTrue: [ oldFile renameTo: newName ]
]

{ #category : 'accessing' }
MicFileNameWithSpaceChecker >> visitFigure: aFigure [
(aFigure url includes: $ ) ifTrue: [
self errors add: aFigure ].
super visitFigure: aFigure
]
4 changes: 2 additions & 2 deletions src/Microdown-BookTester/MicFileResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Class {
{ #category : 'accessing' }
MicFileResult >> explanation [

^ 'File input ', self what,' (in file ', fileReference fullName , ') does not exist.'
^ 'File input ', self what,' (in file ', source fullName , ') does not exist.'

]

{ #category : 'accessing' }
MicFileResult >> stonFormatExplanation [

^ '"', self what,'" : "', fileReference , '"'
^ '"', self what,'" : "', source , '"'

]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Class {
MicFirstElementOfHeaderIsNotCapitalizedResult >> explanation [


^ 'Header: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: ', detail, ' as first word of the header should be uppercased.'
^ 'Header: "' , micElement text , '" in file' , fileReference fullName , ' contains a mistake: ', detail, ' as first word of the header should be uppercased.'

]
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ MicFrenchTypographyResult >> explanation [
| text |
text := micElement bodyString ifNil: [ '' ].
^ 'Text: "' , text
, '" in file' , self inFile fullName
, '" in file' , fileReference fullName
, ' contains a mistake: ' , detail
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Class {
MicHeaderWronglyLowercasedResult >> explanation [


^ 'Header: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: ', detail, ' should not be lowercased.'
^ 'Header: "' , micElement text , '" in file' , fileReference fullName , ' contains a mistake: ', detail, ' should not be lowercased.'

]
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Class {
MicHeaderWronglyUppercasedResult >> explanation [


^ 'Header: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: ', detail, ' should not be uppercased.'
^ 'Header: "' , micElement text , '" in file' , fileReference fullName , ' contains a mistake: ', detail, ' should not be uppercased.'

]
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicMethodReferenceResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ MicMethodReferenceResult >> detail: aString [
{ #category : 'accessing' }
MicMethodReferenceResult >> explanation [
^ 'Text: "' , micElement bodyString
, '" in file' , self inFile fullName
, '" in file' , fileReference fullName
, ' contains a mistake: method references must be consistent, either always with # or always without #.'
]
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicMethodStructureResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MicMethodStructureResult >> detail: aString [
{ #category : 'accessing' }
MicMethodStructureResult >> explanation [
^ 'Text: "' , micElement body
, '" in file' , self inFile fromFile fullName
, '" in file' , fileReference fromFile fullName
, ' contains a mistake: method ['
, detail
, '] should have an empty line after the selector when is no comment.'
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicParagraphLabelResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MicParagraphLabelResult >> detail: aString [
{ #category : 'accessing' }
MicParagraphLabelResult >> explanation [
^ 'Paragraph: "' , micElement text
, '" in file ' , self inFile fullName
, '" in file ' , fileReference fullName
, ' contains a mistake: label should'
, (labelShouldEndWithPeriod
ifTrue: [ ' ' ]
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicPeriodInCaptionResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MicPeriodInCaptionResult >> explanation [
"not sure that text is ok
we should have a common way to express caption between block, figure, and math"

^ 'Text: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: Captions should'
^ 'Text: "' , micElement text , '" in file' , fileReference fullName , ' contains a mistake: Captions should'
, (codeShouldEndWithPeriod
ifFalse: [ ' not ' ]
ifTrue: [ ' ' ]) , 'be terminated with a period (.).'
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicPeriodInCodeResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {
{ #category : 'explanation' }
MicPeriodInCodeResult >> explanation [

^ 'Text: "' , micElement body , '" in file' , self inFile fullName , ' contains a mistake: It should'
^ 'Text: "' , micElement body , '" in file' , fileReference fullName , ' contains a mistake: It should'
, (codeShouldEndWithPeriod
ifFalse: [ ' not ' ]
ifTrue: [ ' ' ]) , 'be terminated with a period (.).'
Expand Down
Loading
Loading