47 lines
1.1 KiB
Smalltalk
47 lines
1.1 KiB
Smalltalk
Extension { #name : #DataFrame }
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
DataFrame >> asMarkdown [
|
|
| response |
|
|
response := '' writeStream.
|
|
self columnNames do: [ :name | response nextPutAll: '| ' , name , ' ' ].
|
|
response
|
|
nextPutAll: '|';
|
|
cr.
|
|
self columns size timesRepeat: [ response nextPutAll: '|---' ].
|
|
response
|
|
nextPutAll: '|';
|
|
cr.
|
|
self asArrayOfRows
|
|
do: [ :row |
|
|
row do: [ :cell | response nextPutAll: '| ' , cell asString , ' ' ].
|
|
response
|
|
nextPutAll: '|';
|
|
cr ].
|
|
^ response contents accentedCharactersCorrection withInternetLineEndings.
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
DataFrame >> viewDataFor: aView [
|
|
<gtView>
|
|
| columnedList |
|
|
self numberOfRows >= 1 ifFalse: [ ^ aView empty ].
|
|
columnedList := aView columnedList
|
|
title: 'Data';
|
|
items: [ self transposed columns ];
|
|
priority: 40.
|
|
self columnNames
|
|
withIndexDo: [:aName :anIndex |
|
|
columnedList
|
|
column: aName
|
|
text: [:anItem | anItem at: anIndex ]
|
|
].
|
|
^ columnedList
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
DataFrame >> webView [
|
|
|
|
^ Pandoc convertString: self asMarkdown from: 'markdown' to: 'html'
|
|
]
|