Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 813 use fileReference in fromfile #885

Merged
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
4 changes: 2 additions & 2 deletions src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ MicSingleSummarizerTest >> testWithFromFileNil [

micSingleSummarizer verifyFromFile: root.

self assert: root fromFile equals: 'fakedFile'
self assert: root fromFile base equals: 'fakedFile'
]

{ #category : 'tests' }
Expand Down Expand Up @@ -271,7 +271,7 @@ MicSingleSummarizerTest >> testWithoutFromFile [

micSingleSummarizer verifyFromFile: root.

self assert: root fromFile equals: 'fakedFile'
self assert: root fromFile basename equals: 'fakedFile'
]

{ #category : 'tests' }
Expand Down
13 changes: 5 additions & 8 deletions src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,7 @@ MicReferenceCheckerTest >> testDefFig1AndRefToAncS0UnknowAnchor [
visitor checkProject: defFig1AndRefToAnsC0.
self deny: visitor isOkay.
self assert: visitor results first anchorLabel equals: 'ancS0'.
self
assert: visitor results first source
equals: '/defFig1AndRefToAncS0.md'
self assert: visitor results first source equals: '/defFig1AndRefToAncS0.md'
]

{ #category : 'tests - single file ok references' }
Expand Down Expand Up @@ -398,9 +396,8 @@ MicReferenceCheckerTest >> testDefS1ButRefersToS0UnknownAnchor [
self deny: visitor isOkay.
self assert: visitor results size equals: 1.
self assert: visitor results first anchorLabel equals: 'ancS0'.
self
assert: visitor results first source
equals: '/fileDefAncS1UndAncS0.md'
self assert: visitor results first source equals: '/fileDefAncS1UndAncS0.md'

]

{ #category : 'tests - directory api' }
Expand Down Expand Up @@ -503,7 +500,7 @@ MicReferenceCheckerTest >> testDuplicatedAnchorInDifferentFilesOfTheSameDir [
equals: 'ancS1'.
dict := visitor results groupedBy: [ :each | each class ].
duplicated := (dict at: MicDuplicatedAnchorResult) first.
self assert: duplicated source equals: '/myDirectory/file2.md'.
self assert: visitor results first source equals: '/myDirectory/file2.md'.
self assert: duplicated anchorLabel equals: 'ancS1'


Expand Down Expand Up @@ -729,7 +726,7 @@ MicReferenceCheckerTest >> testRefersToUnkAncS1 [
self deny: visitor isOkay.
self assert: visitor results size equals: 1.
self assert: visitor results first anchorLabel equals: 'ancS1'.
self assert: visitor results first source equals: '/fileRefAncS1.md'
self assert: visitor results first source equals: '/fileRefAncS1.md'.
]

{ #category : 'tests - duplicated' }
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: ', source fromFile
^ '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/MicExampleTesterStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MicExampleTesterStrategy >> verify: aCodeBlock [
| result |
result := MicBookTestResult new.
result text: aCodeBlock code.
[ result source: aCodeBlock fromFile ]
[ result source: aCodeBlock fromFile fullName]
on: Error
do: [ result source: nil ].
results add: result.
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicFileCollector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ MicFileCollector >> visitRoot: micDocument [
[ worklist isEmpty ] whileFalse: [
| currentDocument |
currentDocument := worklist removeFirst.
visitedFileStrings add: currentDocument fromFile.
visitedFileStrings add: currentDocument fromFile fullName.
currentDocument resolveYourself.
visitedFiles add: currentDocument.

Expand Down
6 changes: 3 additions & 3 deletions src/Microdown-BookTester/MicReferenceChecker.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ MicReferenceChecker >> addBadReferenceAnchor: anAnchorReference [
micResultInstance := MicUndefinedAnchorResult new.
micResultInstance
anchorLabel: anAnchorReference anchorLabel;
source: anAnchorReference fromFile.
source: anAnchorReference fromFile fullName.
results add: micResultInstance
]

Expand All @@ -55,7 +55,7 @@ MicReferenceChecker >> addDuplicatedAnchor: anAnchor [
micResultInstance := MicDuplicatedAnchorResult new.
micResultInstance
anchorLabel: anAnchor anchorLabel;
source: anAnchor fromFile.
source: anAnchor fromFile fullName.
results add: micResultInstance
]

Expand Down Expand Up @@ -133,7 +133,7 @@ MicReferenceChecker >> handleAnchorOf: anElement [
MicReferenceChecker >> handleUndefinedFilesFrom: collector [

collector unexistingFiles do: [ :each |
results add: (MicUndefinedInputFileResult new inputFileBlock: each ; source: each fromFile ; yourself )
results add: (MicUndefinedInputFileResult new inputFileBlock: each ; source: each fromFile fullName; yourself )

]
]
Expand Down
14 changes: 7 additions & 7 deletions src/Microdown-Tests/MicFileResourceReferenceTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ MicFileResourceReferenceTest >> testContentsOfDirectory [
MicFileResourceReferenceTest >> testContentsSet [
|ref header |
ref := (MicResourceReference fromUri: 'file:/example.md')
filesystem: filesystem.
fileSystem: filesystem.
ref contents: '### Super cool header'.
header := ref loadMicrodown children first.
self assert: header level equals: 3.
Expand Down Expand Up @@ -216,7 +216,7 @@ MicFileResourceReferenceTest >> testLoadImage [

| ref image |
ref := (MicResourceReference fromUri: 'file:/toplevel.png')
filesystem: filesystem.
fileSystem: filesystem.
image := ref loadImage.
self assert: image isNotNil.
self assert: image height equals: 90.
Expand All @@ -227,7 +227,7 @@ MicFileResourceReferenceTest >> testLoadImage [
MicFileResourceReferenceTest >> testLoadMicrodown [
| ref doc |
ref := (MicResourceReference fromUri: 'file:/readme.md')
filesystem: filesystem.
fileSystem: filesystem.
doc := ref loadMicrodown.
self assert: doc children first class equals: MicHeaderBlock.
self assert: doc children first text equals: 'Test documents'
Expand All @@ -238,7 +238,7 @@ MicFileResourceReferenceTest >> testLoadMicrodown [
MicFileResourceReferenceTest >> testLoadNotCorrectImage [
| ref |
ref := (MicResourceReference fromUri: 'file:/readme.md')
filesystem: filesystem .
fileSystem: filesystem .
self
should: [ref loadImage]
raise: UnrecognizedImageFormatError
Expand All @@ -249,7 +249,7 @@ MicFileResourceReferenceTest >> testLoadNotCorrectMicrodown [

| ref |
ref := (MicResourceReference fromUri: 'file:///toplevel.png')
filesystem: filesystem.
fileSystem: filesystem.
self
should: [ ref loadMicrodown ]
raise: ZnInvalidUTF8
Expand All @@ -259,7 +259,7 @@ MicFileResourceReferenceTest >> testLoadNotCorrectMicrodown [
MicFileResourceReferenceTest >> testLoadNotFoundImage [

| ref |
ref := (MicResourceReference fromUri: 'file:///readme.md') filesystem: emptyFilesystem.
ref := (MicResourceReference fromUri: 'file:///readme.md') fileSystem: emptyFilesystem.
[
ref loadImage.
self fail
Expand All @@ -271,7 +271,7 @@ MicFileResourceReferenceTest >> testLoadNotFoundImage [
MicFileResourceReferenceTest >> testLoadNotFoundMicrodown [
| uri ref |
uri := 'file:///readme.md'.
ref := (MicResourceReference fromUri: uri) filesystem: emptyFilesystem.
ref := (MicResourceReference fromUri: uri) fileSystem: emptyFilesystem.

[
ref loadMicrodown.
Expand Down
4 changes: 2 additions & 2 deletions src/Microdown-Tests/MicZincPathResolverTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ MicZincPathResolverTest >> testVisitFileImage [
self assert: imageNode reference isRelative.
self assert: imageNode reference relativePath equals: 'images/pharo.png'.
absoluteFile := (MicResourceReference fromUri: 'file:/my/deep/directory/sourceFile.md')
filesystem: #Bogus;
fileSystem: #Bogus;
yourself.

MicZincPathResolver resolve: doc withBase: absoluteFile.
self assert: imageNode reference isRelative not.
self assert: imageNode reference uriString equals: 'file:///my/deep/directory/images/pharo.png'.
self assert: imageNode reference filesystem equals: #Bogus
self assert: imageNode reference fileSystem equals: #Bogus
]

{ #category : 'tests' }
Expand Down
4 changes: 2 additions & 2 deletions src/Microdown-Tests/MicrodownTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ MicrodownTest >> testFromFileInAnyElement [

| root |
root := Microdown parseFile: filesystem workingDirectory / 'anExample1.md'.
self assert: root children first children first fromFile equals: (filesystem workingDirectory / 'anExample1.md') fullName .
self assert: root children first children first fromFile fullName equals: (filesystem workingDirectory / 'anExample1.md') fullName .

]

Expand All @@ -85,7 +85,7 @@ MicrodownTest >> testFromFileInRootDocument [

| root |
root := Microdown parseFile: filesystem workingDirectory / 'anExample1.md'.
self assert: root fromFile equals: (filesystem workingDirectory / 'anExample1.md') fullName
self assert: root fromFile fullName equals: (filesystem workingDirectory / 'anExample1.md') fullName


]
Expand Down
14 changes: 7 additions & 7 deletions src/Microdown-Transformer-Tests/MicFileIncluderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ MicFileIncluderTest >> testBeforeIncludingTheInputFile [
setStream: stream;
inputFile: 'anExample1.md' ].

reference := (MicResourceReference fromUri: 'file:///test.md') filesystem: filesystem .
reference := (MicResourceReference fromUri: 'file:///test.md') fileSystem: filesystem .
root := reference loadMicrodown.

self assert: root children first class equals: MicInputfileBlock.
Expand Down Expand Up @@ -111,7 +111,7 @@ MicFileIncluderTest >> testHandleNestedFileResolution [
header: [ builder text: 'Example2' ] withLevel: 1 ].

reference := (MicResourceReference fromUri:
'file:///Chapters/SUnit.md') filesystem: filesystem.
'file:///Chapters/SUnit.md') fileSystem: filesystem.

includer topFile: reference fileReference parent.
includer visit: (root := reference loadMicrodown).
Expand Down Expand Up @@ -158,7 +158,7 @@ MicFileIncluderTest >> testHandleNestedFileResolutionOnDifferentLevel [
header: [ builder text: 'Example2' ] withLevel: 1 ].

reference := (MicResourceReference fromUri:
'file:///Chapters/SUnit.md') filesystem: filesystem.
'file:///Chapters/SUnit.md') fileSystem: filesystem.

includer topFile: reference fileReference parent.
includer visit: (root := reference loadMicrodown).
Expand Down Expand Up @@ -198,7 +198,7 @@ MicFileIncluderTest >> testIncluderIncludesInputFileFromTheSameLevel [
inputfile: 'anExample1.md' ].

reference := (MicResourceReference fromUri:
'file:///Chapters/SUnit/SUnit.md') filesystem:
'file:///Chapters/SUnit/SUnit.md') fileSystem:
filesystem.
root := reference loadMicrodown.

Expand Down Expand Up @@ -228,7 +228,7 @@ MicFileIncluderTest >> testIncluderIncludesInputFilesWithinTheSameParagraph [
inputfile: 'anExample1.md';
inputfile: 'anExample2.md' ].
reference := (MicResourceReference fromUri: 'file:///test.md')
filesystem: filesystem.
fileSystem: filesystem.
root := reference loadMicrodown.
includer visit: root.

Expand Down Expand Up @@ -259,7 +259,7 @@ MicFileIncluderTest >> testIncluderJustReturnInputFileBlockWhenIncludedFileDoesN
setStream: stream;
inputfile: 'anExample3.md'].

reference := (MicResourceReference fromUri: 'file:///test.md') filesystem: filesystem.
reference := (MicResourceReference fromUri: 'file:///test.md') fileSystem: filesystem.
root := reference loadMicrodown.

includer beRelaxed.
Expand All @@ -279,7 +279,7 @@ MicFileIncluderTest >> testMicFileInclusionTransformMicInputFiles [
inputfile: 'anExample1.md';
paragraph: '';
inputfile: 'anExample2.md' ].
reference := (MicResourceReference fromUri: 'file:///test.md') filesystem: filesystem.
reference := (MicResourceReference fromUri: 'file:///test.md') fileSystem: filesystem.
root := reference loadMicrodown.
includer visit: root.

Expand Down
16 changes: 8 additions & 8 deletions src/Microdown/MicFileResourceReference.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Class {
#name : 'MicFileResourceReference',
#superclass : 'MicAbsoluteResourceReference',
#instVars : [
'filesystem'
'fileSystem'
],
#category : 'Microdown-Core',
#package : 'Microdown',
Expand All @@ -36,7 +36,7 @@ MicFileResourceReference class >> fromFileRef: aFileReference [
ifTrue: [ znUrl addPathSegment: $/ "Yes, a Character not a string" ].
^ self new
uri: znUrl;
filesystem: aFileReference fileSystem
fileSystem: aFileReference fileSystem
]

{ #category : 'instance creation' }
Expand Down Expand Up @@ -77,18 +77,18 @@ MicFileResourceReference >> contents: aString [

{ #category : 'accessing' }
MicFileResourceReference >> fileReference [
^ self filesystem referenceTo: self path
^ self fileSystem referenceTo: self path
]

{ #category : 'accessing' }
MicFileResourceReference >> filesystem [
^ filesystem
MicFileResourceReference >> fileSystem [
^ fileSystem
]

{ #category : 'accessing' }
MicFileResourceReference >> filesystem: anObject [
MicFileResourceReference >> fileSystem: anObject [

filesystem := anObject
fileSystem := anObject
]

{ #category : 'accessing' }
Expand All @@ -99,7 +99,7 @@ MicFileResourceReference >> fullName [
{ #category : 'initialization' }
MicFileResourceReference >> initialize [
super initialize.
filesystem := FileSystem disk.
fileSystem := FileSystem disk.
]

{ #category : 'accessing' }
Expand Down
4 changes: 2 additions & 2 deletions src/Microdown/MicRootBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ MicRootBlock >> fromFile [
]

{ #category : 'accessing' }
MicRootBlock >> fromFile: aFile [
MicRootBlock >> fromFile: aFileReference [
"Store the file from which the document was built"

self propertyAt: #file put: aFile
self propertyAt: #file put: (aFileReference ifNotNil: [aFileReference asFileReference])
]

{ #category : 'accessing' }
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown/MicZincPathResolver.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ MicZincPathResolver >> resolveReferenceIn: aNode [
aNode reference isRelative ifFalse: [ ^ self ].
resolvedUri := absoluteReference uri withRelativeReference: aNode reference relativePath.
resolvedReference := MicResourceReference fromUri: resolvedUri printString.
resolvedReference isMicrodownResourceFileReference ifTrue: [ resolvedReference filesystem: absoluteReference filesystem ].
resolvedReference isMicrodownResourceFileReference ifTrue: [ resolvedReference fileSystem: absoluteReference fileSystem ].
aNode reference: resolvedReference
]

Expand Down
2 changes: 1 addition & 1 deletion src/Microdown/Microdown.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Microdown >> parseFile: aFile [

|root|
root := MicrodownParser parse: aFile contents.
root fromFile: aFile fullName.
root fromFile: aFile.
^ root

]
Expand Down
Loading