Skip to content

Revisit architecture to be able to call Microdown related command without a dependency from MD to Pillar #621

@Ducasse

Description

@Ducasse

Most of the old commands that we removed were using old code but I removed one that I should not

ClapMicrodownBookReferenceCheckerCommand was inside the Pillar-ExporterMicrodown (which contained many classes to convert from Pillar to Microdown.

So it is good example how we want to describe checker in Microdown but expose them as command line in Pillar.

ClapMicrodownBookReferenceCheckerCommand >> execute
	| file |
	file :=  self requestedFile asString asFileReference. 
	file exists 
		ifTrue: [ 
			| reporter  parent exampleChecker checker collector |
			parent := self project baseDirectory.

			reporter := MicAnalysisReportWriter new.
			checker := MicReferenceChecker new.
			checker fileSystem: parent.
			checker checkProject: file.

			reporter addResults: checker results.
			
			collector := MicFileCollector new.
			collector 
				rootDirectory: parent;
				visit: (Microdown parseFile: file).
			
			exampleChecker := MicCodeBlockValidator new.
			
			collector visitedFiles do: [ :each |
				exampleChecker start: each ].
			reporter addResults: exampleChecker results. 
				
			reporter isOkay
					ifTrue: [ 
						self outputStreamDo: 
									[ :str | str 
											cr;
											nextPutAll:  'File ' ; 
											nextPutAll: (self relativePathStringOf: file) ; 
											nextPutAll: ' does not have reference problems.' ]]
					ifFalse: [ 
						self outputStreamDo: 
									[ :str | 
										str 
											cr; 
											nextPutAll: 'File ' ; 
											nextPutAll: (self relativePathStringOf: file) ; 
											nextPutAll: ' has reference problems.'; cr.
										reporter buildReportOn: str ] ] ]
		ifFalse: [ 
				self outputStreamDo: [ :str | 
					str 
						cr; 
						nextPutAll: 'File ' ; 
						nextPutAll: file fullName ; 
						nextPutAll: ' does not exist.'  ] ]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions