Adding rubric to the loop. And pillar

This commit is contained in:
Santiago Bragagnolo 2020-03-30 17:02:46 +00:00 committed by Offray Luna
parent 146d54363a
commit a1820c43a3
14 changed files with 682 additions and 0 deletions

View File

@ -44,6 +44,7 @@ GfWorldMenu class >> helpMenuOn: aBuilder [
{ #category : #'world menu' }
GfWorldMenu class >> launchCompatibilityMenuOn: aBuilder [
<worldMenu>
(aBuilder item: #'New notebook')
label: 'New notebook';
order: 1;

View File

@ -0,0 +1,122 @@
"
This abstract class works for defining the basic type required by Rubric
"
Class {
#name : #GrafoscopioAbstractText,
#superclass : #Object,
#category : 'Grafoscopio-Pillar'
}
{ #category : #converting }
GrafoscopioAbstractText >> asText [
^ self
]
{ #category : #accessing }
GrafoscopioAbstractText >> at: anIndex [
^ self subclassResponsibility
]
{ #category : #accessing }
GrafoscopioAbstractText >> attributesAt: characterIndex [
"Answer the code for characters in the run beginning at characterIndex."
"NB: no senders any more (supplanted by #attributesAt:forStyle: but retained for the moment in order not to break user code that may exist somewhere that still calls this"
| attributes |
" self size = 0
ifTrue: [^ Array with: (TextFontChange new fontNumber: 1)]."
self size = 0 ifTrue: [ ^#()].
attributes := self runs at: characterIndex.
^ attributes
]
{ #category : #accessing }
GrafoscopioAbstractText >> attributesAt: anInteger forStyle: aTextStyle [
| attributes |
self size = 0
ifTrue: [^ Array with: (TextFontChange new fontNumber: aTextStyle defaultFontIndex)]. "null text tolerates access"
attributes := self runs at: anInteger.
^ attributes
]
{ #category : #copying }
GrafoscopioAbstractText >> copy [
^ self
]
{ #category : #copying }
GrafoscopioAbstractText >> copyFrom: start to: stop [
^ self subclassResponsibility
]
{ #category : #testing }
GrafoscopioAbstractText >> ifNotEmpty: isNotEmptyBlock ifEmpty: isEmptyBlock [
^ self isEmpty
ifTrue: [ isEmptyBlock value ]
ifFalse: [ isNotEmptyBlock value ]
]
{ #category : #testing }
GrafoscopioAbstractText >> isEmpty [
^ self size = 0
]
{ #category : #testing }
GrafoscopioAbstractText >> isText [
^ true
]
{ #category : #accessing }
GrafoscopioAbstractText >> last [
^ self at: self size
]
{ #category : #copying }
GrafoscopioAbstractText >> notEmpty [
^ self isEmpty not
]
{ #category : #removing }
GrafoscopioAbstractText >> removeAttribute: anAttr [
^ self removeAttribute: anAttr from: 1 to: self size
]
{ #category : #removing }
GrafoscopioAbstractText >> removeAttribute: att from: start to: stop [
self subclassResponsibility
]
{ #category : #editing }
GrafoscopioAbstractText >> replaceFrom: anInteger to: anInteger2 with: aCollection [
self subclassResponsibility
]
{ #category : #emphasis }
GrafoscopioAbstractText >> runLengthFor: characterIndex [
^ self runs runLengthAt: characterIndex
]
{ #category : #accessing }
GrafoscopioAbstractText >> runs [
self subclassResponsibility
]
{ #category : #accessing }
GrafoscopioAbstractText >> runs: anArray [
self subclassResponsibility "runs := RunArray new: self size withAll: anArray . "
]
{ #category : #accessing }
GrafoscopioAbstractText >> size [
^ self string size
]
{ #category : #accessing }
GrafoscopioAbstractText >> string [
^ self subclassResponsibility
]
{ #category : #accessing }
GrafoscopioAbstractText >> text: aParam [
self subclassResponsibility
]

View File

@ -0,0 +1,5 @@
Class {
#name : #GrafoscopioComposer,
#superclass : #Object,
#category : 'Grafoscopio-Rub'
}

View File

@ -0,0 +1,20 @@
Class {
#name : #GrafoscopioEditingArea,
#superclass : #RubEditingArea,
#category : 'Grafoscopio-Rub'
}
{ #category : #private }
GrafoscopioEditingArea >> newParagraph [
| newParagraph |
newParagraph := self privateInstantiateParagraphObject.
newParagraph textArea: self.
newParagraph container: self compositionRectangle.
^ newParagraph
]
{ #category : #private }
GrafoscopioEditingArea >> privateInstantiateParagraphObject [
^ RubOpeningClosingDelimiterDecorator next: GrafoscopioParagraph new.
]

View File

@ -0,0 +1,10 @@
Class {
#name : #GrafoscopioParagraph,
#superclass : #RubParagraph,
#category : 'Grafoscopio-Rub'
}
{ #category : #'accessing composer' }
GrafoscopioParagraph >> newComposer [
^ GrafoscopioComposer new
]

View File

@ -0,0 +1,162 @@
"
Pillar ASText delegates the text behavior into a pillar AST .
"
Class {
#name : #GrafoscopioPillarASText,
#superclass : #GrafoscopioAbstractText,
#instVars : [
'ast',
'stringDecorator',
'lastNode'
],
#category : 'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText class >> openExample [
^ self new
ast: self pillarExample;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText class >> pillarExample [
^ PRPillarParser
parse:
'!! About Pillar
!!
Pillar is a system to manage documents (books, presentations, and web sites). From a common format, it is able to generate documents in multiple formats (html, markdown, latex, AsciiDoc).
It is composed of several modules such as importers, transformers, document model and outputers.
This book describes Pillar in its current version 7.0. Pillar is currently developed and masintained by Stéphane Ducasse and Guillermo Polito.
The original author of Pillar was Damien Cassou. Many people have also contributed to Pillar: Ben Coman, Guillermo Polito, Lukas Renggli (original author of the PierCMS from which a first version of Pillar has been extracted), Benjamin van Ryseghem, Cyril Ferlicot-Delbecque, Thibault Arloing, Yann Dubois, Quentin Ducasse and Asbathou Sama Biyalou. Special thanks to Asbathou Sama Biyalou!
This book adapts, extends, and clarifies the chapter explaining Pillar in the ''Enterprise Pharo: a Web Perspective'' book.
Pillar was sponsored by *ESUG>http://www.esug.org*.
!!!Introduction
Pillar (hosted at *http://github.com/pillar-markup*) is a markup language and associated tools to write and generate documentation, books (such as this one), web sites, and slide-based presentations. The Pillar screenshot in Figure *@voyageDocExample* shows the HTML version of chapter Voyage.
+An example Pillar output>file://figures/voyageDocExample-small.png|label=voyageDocExample|width=60+
Pillar has many features, helpful tools, and documentation:
- simple markup syntax with references, tables, pictures, captions, syntax-highlighted code blocks;
- export documents to HTML, LaTeX, Markdown, AsciiDoc, ePuB and Pillar itself, and presentations to Beamer and Deck.js;
%- customization of the export through a dedicated STON configuration file (see chapter Missing Chapter *@cha:ston*) and Mustache templates (see chapter *@templating*).
- many tests with good coverage (94% with more than a 2100 executed tests), which are regularly run by a *continuous integration job>https://ci.inria.fr/pharo-contribution/job/Pillar*
- a command-line interface and dedicated plugins for several text editors: *Emacs>https://github.com/pillar-markup/pillar-mode*, *Vim>https://github.com/cdlm/vim-pillar*, *TextMate>https://github.com/Uko/Pillar.tmbundle*, and *Atom>https://github.com/Uko/language-pillar*
- a cheat sheet (see Chapter *@chacheat*).
!!!Pillar users
@pillarUSERS
This book was written in Pillar itself. If you want to see how Pillar is used, have a look at its source code (*http://github.com/SquareBracketAssociates/Booklet-PublishingAPillarBooklet*), or check the following other real-world projects:
- the Updated Pharo by Example book (*https://github.com/SquareBracketAssociates/UpdatedPharoByExample*),
- the Pharo MOOC - Massive open online course (*https://github.com/SquareBracketAssociates/PharoMooc*,
- Any of the Pharo booklets (*https://github.com/SquareBracketAssociates/Booklet-XXXX*,
- the PillarHub open-access shared blog (*http://pillarhub.pharocloud.com*).
!!! Pillar future features
Pillar 70 saw some major refactorings and cleaning: it does not rely on Grease and Magritte anymore.
Its architecture is a lot cleaner.
Still some issues are missing. Here is a little list of features that we are working on or will soon:
- Incremental recompilation. Since we remove the use of make (so that Windows users can use Pillar) we should introduce a way to avoid to recompile complete book when just one chapter changed.
- Markdown syntax.
- Release of Ecstatic. Pillar supports the deployment of web sites named Ecstatic and we are working on a second version of Ecstatic.
- Better table support.
!!! Conclusion
Pillar is still in active development: maintainers keep improving its implementation. The current version of Pillar is Pillar 70. This booklet only documents Pillar 70. This booklet will be synchronised with future enhancements.'
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> allRangesOfSubstring: aString [
^ { }
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> ast: aPRDocument [
ast := aPRDocument.
aPRDocument accept: GrafoscopioPillarTextAnnotator new.
ast start: aPRDocument children first start.
ast stop: aPRDocument children last stop.
stringDecorator := GrafoscopioPillarASTextStringDecorator new
text: self;
yourself
]
{ #category : #accessing }
GrafoscopioPillarASText >> at: anInteger [
| node |
(anInteger > self size or: [ anInteger < 1 ])
ifTrue: [ ^ self errorSubscriptBounds: anInteger ].
node := self detectAstNodeFor: anInteger in: ast.
^ node text at: anInteger - node textStart +1
]
{ #category : #copying }
GrafoscopioPillarASText >> copyFrom: from to: to [
^ (ast textStart = from and: [ ast textStop = (to + 1) ])
ifTrue: [ self ]
ifFalse: [ GrafoscopioPillarASTextStringProjectionDecorator new
text: self;
from: from;
to: to;
yourself ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> detectAstNodeFor: anInteger in: aNode [
(lastNode isNotNil
and: [ anInteger between: lastNode textStart and: lastNode textStop ])
ifTrue: [ ^ lastNode ].
(anInteger between: aNode textStart and: aNode textStop)
ifFalse: [ self error: 'Cannot find a node for ' , anInteger asString ].
^ aNode hasChildren
ifTrue: [ aNode children
detect: [ :c | anInteger between: c textStart and: c textStop ]
ifFound: [ :n | self detectAstNodeFor: anInteger in: n ]
ifNone: [ self error: 'whut?' ] ]
ifFalse: [ lastNode := aNode ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> removeAttribute: att from: start to: stop [
]
{ #category : #editing }
GrafoscopioPillarASText >> replaceFrom: start to: stop with: aCollection [
" Here we should be managing insertion and adding of text. "
self assert: aCollection isEmpty.
]
{ #category : #accessing }
GrafoscopioPillarASText >> runs [
^ RunArray
new: self size
withAll: (Array with: (TextFontChange fontNumber: 1))
]
{ #category : #accessing }
GrafoscopioPillarASText >> size [
^ ast textSize
]
{ #category : #accessing }
GrafoscopioPillarASText >> string [
^ stringDecorator
]

View File

@ -0,0 +1,43 @@
Class {
#name : #GrafoscopioPillarASTextStringDecorator,
#superclass : #Object,
#instVars : [
'text'
],
#category : 'Grafoscopio-Pillar'
}
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> at: aNumber [
^ text at: aNumber
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> at: aNumber put: aChar [
self halt
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> copyFrom: one to: two [
^ text copyFrom: one to: two
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> isByteString [
^ true
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> notEmpty [
^ text notEmpty
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> size [
^ text size
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> text: aGFPText [
text := aGFPText
]

View File

@ -0,0 +1,44 @@
Class {
#name : #GrafoscopioPillarASTextStringProjectionDecorator,
#superclass : #GrafoscopioPillarASTextStringDecorator,
#instVars : [
'from',
'to'
],
#category : 'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> allRangesOfSubstring: aString [
^ { }
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionDecorator >> at: anInteger [
from + anInteger > to ifTrue: [ ^ self error: ' out of bounds ' ].
^ super at: from + anInteger
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> copyFrom: one to: two [
^ self class new
text: text;
from: from + one;
to: from + two;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> from: anInteger [
from := anInteger
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionDecorator >> size [
^ to - from
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> to: anInteger [
to := anInteger
]

View File

@ -0,0 +1,86 @@
Class {
#name : #GrafoscopioPillarTextAnnotator,
#superclass : #PRVisitor,
#instVars : [
'texts',
'lastStop',
'stack'
],
#category : 'Grafoscopio-Pillar'
}
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> initialize [
super initialize.
texts := OrderedCollection new
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> populateParentsOf: aSetOfParents [
| parents |
parents := Set new.
aSetOfParents do: [ : n |
parents add: n parent.
n parent propertyAt: #textStart ifAbsent: [
n parent propertyAt: #textStart put: (n parent children first propertyAt: #textStart).
n parent propertyAt: #textStop put: (n parent children last propertyAt: #textStop).
]
].
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitCodeblock: aTextObject [
self visitText: aTextObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitCommentedLine: aTextObject [
self visitText: aTextObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitDocument: aDoc [
lastStop := 1 .
super visitDocument: aDoc.
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitDocumentGroup: aGroup [
super visitDocumentGroup: aGroup.
"aGroup
propertyAt: #textStart
ifAbsent: [
aGroup hasChildren
ifTrue: [ aGroup
propertyAt: #textStart
put: (aGroup children first propertyAt: #textStart).
aGroup
propertyAt: #textStop
put: (aGroup children last propertyAt: #textStop) ]
ifFalse: [
aGroup propertyAt: #textStart put: 0 .
aGroup propertyAt: #textStop put: 0
]
]"
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitLineBreak: anObject [
^ self visitText: anObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitRaw: aTextObject [
self visitText: aTextObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitText: aTextObject [
texts add: aTextObject.
aTextObject propertyAt: #textStart put: lastStop.
aTextObject propertyAt: #textStop put: lastStop + aTextObject text size - 1.
lastStop := lastStop + aTextObject text size.
]

View File

@ -0,0 +1,97 @@
Class {
#name : #GrafoscopioPillarUIBuilder,
#superclass : #PRVisitor,
#instVars : [
'stack',
'document'
],
#category : 'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarUIBuilder class >> openExample [
^ self new
build: self pillarExample;
openWithSpec
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarUIBuilder class >> pillarExample [
^ PRPillarParser
parse:
'!! About Pillar
!!
Pillar is a system to manage documents (books, presentations, and web sites). From a common format, it is able to generate documents in multiple formats (html, markdown, latex, AsciiDoc).
It is composed of several modules such as importers, transformers, document model and outputers.
This book describes Pillar in its current version 7.0. Pillar is currently developed and masintained by Stéphane Ducasse and Guillermo Polito.
The original author of Pillar was Damien Cassou. Many people have also contributed to Pillar: Ben Coman, Guillermo Polito, Lukas Renggli (original author of the PierCMS from which a first version of Pillar has been extracted), Benjamin van Ryseghem, Cyril Ferlicot-Delbecque, Thibault Arloing, Yann Dubois, Quentin Ducasse and Asbathou Sama Biyalou. Special thanks to Asbathou Sama Biyalou!
This book adapts, extends, and clarifies the chapter explaining Pillar in the ''Enterprise Pharo: a Web Perspective'' book.
Pillar was sponsored by *ESUG>http://www.esug.org*.
!!!Introduction
Pillar (hosted at *http://github.com/pillar-markup*) is a markup language and associated tools to write and generate documentation, books (such as this one), web sites, and slide-based presentations. The Pillar screenshot in Figure *@voyageDocExample* shows the HTML version of chapter Voyage.
+An example Pillar output>file://figures/voyageDocExample-small.png|label=voyageDocExample|width=60+
Pillar has many features, helpful tools, and documentation:
- simple markup syntax with references, tables, pictures, captions, syntax-highlighted code blocks;
- export documents to HTML, LaTeX, Markdown, AsciiDoc, ePuB and Pillar itself, and presentations to Beamer and Deck.js;
%- customization of the export through a dedicated STON configuration file (see chapter Missing Chapter *@cha:ston*) and Mustache templates (see chapter *@templating*).
- many tests with good coverage (94% with more than a 2100 executed tests), which are regularly run by a *continuous integration job>https://ci.inria.fr/pharo-contribution/job/Pillar*
- a command-line interface and dedicated plugins for several text editors: *Emacs>https://github.com/pillar-markup/pillar-mode*, *Vim>https://github.com/cdlm/vim-pillar*, *TextMate>https://github.com/Uko/Pillar.tmbundle*, and *Atom>https://github.com/Uko/language-pillar*
- a cheat sheet (see Chapter *@chacheat*).
!!!Pillar users
@pillarUSERS
This book was written in Pillar itself. If you want to see how Pillar is used, have a look at its source code (*http://github.com/SquareBracketAssociates/Booklet-PublishingAPillarBooklet*), or check the following other real-world projects:
- the Updated Pharo by Example book (*https://github.com/SquareBracketAssociates/UpdatedPharoByExample*),
- the Pharo MOOC - Massive open online course (*https://github.com/SquareBracketAssociates/PharoMooc*,
- Any of the Pharo booklets (*https://github.com/SquareBracketAssociates/Booklet-XXXX*,
- the PillarHub open-access shared blog (*http://pillarhub.pharocloud.com*).
!!! Pillar future features
Pillar 70 saw some major refactorings and cleaning: it does not rely on Grease and Magritte anymore.
Its architecture is a lot cleaner.
Still some issues are missing. Here is a little list of features that we are working on or will soon:
- Incremental recompilation. Since we remove the use of make (so that Windows users can use Pillar) we should introduce a way to avoid to recompile complete book when just one chapter changed.
- Markdown syntax.
- Release of Ecstatic. Pillar supports the deployment of web sites named Ecstatic and we are working on a second version of Ecstatic.
- Better table support.
!!! Conclusion
Pillar is still in active development: maintainers keep improving its implementation. The current version of Pillar is Pillar 70. This booklet only documents Pillar 70. This booklet will be synchronised with future enhancements.'
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarUIBuilder >> build: aPRDocument [
stack := Stack new.
aPRDocument accept: self.
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarUIBuilder >> openWithSpec [
document openWithSpec.
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarUIBuilder >> visitDocument: aDocument [
document ifNotNil: [ self error: 'whut?' ].
document := SpTextPresenter new.
super visitDocument: aDocument
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarUIBuilder >> visitHeader: aHeader [
aHeader level
]

View File

@ -0,0 +1,18 @@
Class {
#name : #GrafoscopioScrolledTextMorph,
#superclass : #RubScrolledTextMorph,
#instVars : [
'textAreaClass'
],
#category : 'Grafoscopio-Rub'
}
{ #category : #initialization }
GrafoscopioScrolledTextMorph >> textAreaClass [
^ textAreaClass ifNil: [ GrafoscopioEditingArea ]
]
{ #category : #initialization }
GrafoscopioScrolledTextMorph >> textAreaClass: aClass [
textAreaClass := aClass.
]

View File

@ -0,0 +1,24 @@
Extension { #name : #PRDocumentItem }
{ #category : #'*Grafoscopio' }
PRDocumentItem >> textSize [
^ self textStop - self textStart
]
{ #category : #'*Grafoscopio' }
PRDocumentItem >> textStart [
^ self
propertyAt: #textStart
ifAbsent: [ self hasChildren
ifTrue: [ self children first textStart ]
ifFalse: [ 0 ] ]
]
{ #category : #'*Grafoscopio' }
PRDocumentItem >> textStop [
^ self
propertyAt: #textStop
ifAbsent: [ self hasChildren
ifTrue: [ self children last textStop ]
ifFalse: [ 0 ] ]
]

View File

@ -0,0 +1,11 @@
Class {
#name : #SpGrafoscopioTextPresenter,
#superclass : #SpTextPresenter,
#category : 'Grafoscopio-Rub'
}
{ #category : #specs }
SpGrafoscopioTextPresenter class >> adapterName [
^ #SpMorphicGrafoscopioTextAdapter
]

View File

@ -0,0 +1,39 @@
Class {
#name : #SpMorphicGrafoscopioTextAdapter,
#superclass : #SpMorphicTextAdapter,
#category : 'Grafoscopio-Rub'
}
{ #category : #factory }
SpMorphicGrafoscopioTextAdapter >> buildWidget [
| newWidget |
newWidget := (self widgetClass on: self)
getTextSelector: #getText;
setTextSelector: #accept:notifying:;
getSelectionSelector: #readSelection;
menuProvider: self selector: #codePaneMenu:shifted:;
setSelectionSelector: #setSelection:;
ghostText: self placeholder;
beWrapped;
enabled: self enabled;
askBeforeDiscardingEdits: self askBeforeDiscardingEdits;
autoAccept: self autoAccept;
vResizing: #spaceFill;
hResizing: #spaceFill;
setBalloonText: self help;
dragEnabled: self dragEnabled;
dropEnabled: self dropEnabled;
registerScrollChanges: #scrollValueChanged:;
yourself.
self setEditingModeFor: newWidget.
self presenter
whenTextChangedDo: [ :text | self setText: text to: newWidget ].
self presenter
whenPlaceholderChangedDo: [ :text | self setGhostText: text to: newWidget ].
^ newWidget
]
{ #category : #factory }
SpMorphicGrafoscopioTextAdapter >> widgetClass [
^ GrafoscopioScrolledTextMorph
]