Skip to content

Commit

Permalink
Acquire all the buildMicroDownUsing: aBuilder withComment: aString me…
Browse files Browse the repository at this point in the history
…thods from Microdown.

It should not be packaged in Microdown but with BeautifulComment. 
We have old issues about this method in BC so I have no idea why they ended up in Microdown
  • Loading branch information
Ducasse committed Feb 4, 2024
1 parent 2f22501 commit adc2440
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/BeautifulComments/BaselineOf.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Extension { #name : 'BaselineOf' }

{ #category : '*BeautifulComments' }
BaselineOf class >> buildMicroDownUsing: aBuilder withComment: aString [
aBuilder
header: [ aBuilder text: self name ] withLevel: 1;
horizontalLine;
text: 'A baseline is a kind of map to load project.';
newLine;
header: [ aBuilder text: 'Description' ] withLevel: 3;
text: aString;
newLine;
header: [ aBuilder text: 'Dependencies' ] withLevel: 3.

(self instanceSide includesLocalSelector: #baseline:)
ifTrue: [ aBuilder
codeblockTag: 'pharo'
withBody: (self instanceSide sourceCodeAt: #baseline:) ]
]
18 changes: 18 additions & 0 deletions src/BeautifulComments/Class.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Extension { #name : 'Class' }

{ #category : '*BeautifulComments' }
Class >> buildMicroDownUsing: aBuilder withComment: aString [

aBuilder
header: [ aBuilder text: 'Class: '.
aBuilder text: self name ] withLevel: 1;
horizontalLine;
text: aString.

self addDocumentSectionExampleCodeTo: aBuilder.

self
addDocumentSectionTo: aBuilder
label: 'Examples'
methods: (self class methods select: [ :each | each protocol = self documentExamplesProtocol ])
]
8 changes: 8 additions & 0 deletions src/BeautifulComments/MicAnnotationBlock.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : 'MicAnnotationBlock' }

{ #category : '*BeautifulComments' }
MicAnnotationBlock class >> buildMicroDownUsing: aBuilder withComment: aString [

super buildMicroDownUsing: aBuilder withComment: aString.
self addDocumentDefinedAnnotations: aBuilder
]
23 changes: 23 additions & 0 deletions src/BeautifulComments/MicElement.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Extension { #name : 'MicElement' }

{ #category : '*BeautifulComments' }
MicElement class >> buildMicroDownUsing: aBuilder withComment: aComment [
| visitSelector visitors |
super buildMicroDownUsing: aBuilder withComment: aComment.
visitSelector := ('visit',
((self name withoutSuffix: 'Block')
copyWithoutFirst trimLeft: [ :char | char isLowercase ] ),
':' ) asSymbol.
visitors := MicrodownVisitor allSubclasses
select: [ :class | class includesSelector: visitSelector ].
aBuilder newLine.
aBuilder header: [ aBuilder text:'Visitors using me:' ] withLevel: 2.
visitors
ifEmpty: [
aBuilder text: 'I found no one implementing a ',
visitSelector,
' - perhaps I am abstract or the visitor is unconventionally named' ]
ifNotEmpty: [
aBuilder unorderedListDuring: [
visitors do: [:class | aBuilder item: [ aBuilder monospace: (class name, '>>#', visitSelector ) ]]]]
]
8 changes: 8 additions & 0 deletions src/BeautifulComments/MicEnvironmentBlock.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : 'MicEnvironmentBlock' }

{ #category : '*BeautifulComments' }
MicEnvironmentBlock class >> buildMicroDownUsing: aBuilder withComment: aString [

super buildMicroDownUsing: aBuilder withComment: aString.
self addDocumentDefinedEnvironments: aBuilder
]
16 changes: 16 additions & 0 deletions src/BeautifulComments/MicRichTextCodeBlockStyler.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Extension { #name : 'MicRichTextCodeBlockStyler' }

{ #category : '*BeautifulComments' }
MicRichTextCodeBlockStyler class >> buildMicroDownUsing: aBuilder withComment: aComment [
super buildMicroDownUsing: aBuilder withComment: aComment.
"Only add this list here, not in my subclasses"
self = MicRichTextCodeBlockStyler ifFalse: [ ^ self ].
aBuilder newLine.
aBuilder header: [ aBuilder text: 'Subclasses implementing stylers:' ] withLevel: 2.
aBuilder unorderedListDuring: [
self allSubclasses do: [ :class |
aBuilder item: [
aBuilder text: (class styleTags joinUsing: ', ' last: ' and '), ' is implemented by ' .
aBuilder monospace: (class name)]
]]
]
32 changes: 32 additions & 0 deletions src/BeautifulComments/Package.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Extension { #name : 'Package' }

{ #category : '*BeautifulComments' }
Package >> buildMicroDownUsing: aBuilder withComment: aString [

"I'm on a package and the package is a baseline package."
self class environment
at: self name
ifPresent: [ :cls |
aBuilder
header: [ aBuilder text: self name ] withLevel: 1;
horizontalLine;
text: 'A baseline is a kind of map to load project.';
newLine;
header: [ aBuilder text: 'Description' ] withLevel: 3;
text: aString;
newLine;
header: [ aBuilder text: 'Dependencies' ] withLevel: 3;
codeblockTag: 'pharo'
withBody:
(cls
sourceCodeAt: #baseline:
ifAbsent: [ 'No baseline! Houston we have a problem' ]) ]
ifAbsent: [ aBuilder
header: [
aBuilder
text: 'Package: ';
text: self name ]
withLevel: 1;
horizontalLine;
text: aString ]
]
11 changes: 11 additions & 0 deletions src/BeautifulComments/RGBehavior.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : 'RGBehavior' }

{ #category : '*BeautifulComments' }
RGBehavior >> buildMicroDownUsing: aMicMicrodownTextualBuilder withComment: aString [

aMicMicrodownTextualBuilder
header: [ aMicMicrodownTextualBuilder text: 'Class: '.
aMicMicrodownTextualBuilder text: self name ] withLevel: 1;
horizontalLine;
text: aString
]
11 changes: 11 additions & 0 deletions src/BeautifulComments/RGPackage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : 'RGPackage' }

{ #category : '*BeautifulComments' }
RGPackage >> buildMicroDownUsing: aMicMicrodownTextualBuilder withComment: aString [

aMicMicrodownTextualBuilder
header: [ aMicMicrodownTextualBuilder text: 'Class: '.
aMicMicrodownTextualBuilder text: self name ] withLevel: 1;
horizontalLine;
text: aString
]
29 changes: 29 additions & 0 deletions src/BeautifulComments/TestCase.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Extension { #name : 'TestCase' }

{ #category : '*BeautifulComments' }
TestCase class >> buildMicroDownUsing: aBuilder withComment: aString [

| number |
number := self allTestSelectors size.
aBuilder
header: [ aBuilder text: self name ] withLevel: 1;
horizontalLine;
header: [ aBuilder text: 'Description' ] withLevel: 3;
text: aString;
newLine;
header: [ aBuilder text: 'Tests' ] withLevel: 3;
text: 'This test suite '.
number isZero
ifTrue: [ ^ aBuilder text: 'has no test methods.'].

aBuilder
text: 'defines ', number asString, ' test method'.
number = 1
ifFalse: [ aBuilder text: 's' ].
aBuilder text: ':'.

aBuilder
newLine;
unorderedListDuring: [ self testSelectors
do: [ :each | aBuilder item: [ aBuilder monospace: (self class instanceSide name , '>>#' , each) asString ] ]]
]

0 comments on commit adc2440

Please sign in to comment.