pillar icon indicating copy to clipboard operation
pillar copied to clipboard

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

Open Ducasse opened this issue 6 months ago • 0 comments

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.'  ] ]

Ducasse avatar Aug 08 '25 19:08 Ducasse