2022-10-16 22:41:12 +00:00
|
|
|
Class {
|
|
|
|
#name : #MiniDocs,
|
|
|
|
#superclass : #Object,
|
|
|
|
#category : #MiniDocs
|
|
|
|
}
|
|
|
|
|
2023-01-06 15:31:39 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> altKeys [
|
|
|
|
^ BlAlternativeCombination new
|
|
|
|
with: (BlSingleKeyCombination key:BlKeyboardKey altLeft);
|
|
|
|
with: (BlSingleKeyCombination key:BlKeyboardKey altRight);
|
|
|
|
yourself.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> altShiftLeftCombo [
|
|
|
|
^ BlCompulsoryCombination new
|
|
|
|
with: self altKeys;
|
|
|
|
with: self shiftKeys;
|
|
|
|
with: (BlSingleKeyCombination key: BlKeyboardKey arrowLeft);
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> altShiftRightCombo [
|
|
|
|
^ BlCompulsoryCombination new
|
|
|
|
with: self altKeys;
|
|
|
|
with: self shiftKeys;
|
|
|
|
with: (BlSingleKeyCombination key: BlKeyboardKey arrowRight);
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
|
2022-10-16 22:41:12 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> appFolder [
|
2022-11-04 01:08:33 +00:00
|
|
|
| tempFolder userDataFolder |
|
|
|
|
userDataFolder := Smalltalk os isWindows
|
|
|
|
ifTrue: [ FileLocator home / 'AppData' / 'Local' ]
|
|
|
|
ifFalse: [ FileLocator userData ].
|
|
|
|
tempFolder := userDataFolder / 'Mutabit' / 'MiniDocs'.
|
2022-10-16 22:41:12 +00:00
|
|
|
tempFolder exists ifFalse: [ tempFolder ensureCreateDirectory ].
|
|
|
|
^ tempFolder
|
|
|
|
]
|
2022-10-16 23:52:07 +00:00
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> installYamlToJson [
|
2022-10-21 23:47:37 +00:00
|
|
|
"For the moment, only Gnu/Linux and Mac are supported.
|
2022-10-16 23:52:07 +00:00
|
|
|
IMPORTANT: Nimble, Nim's package manager should be installed, as this process doesn't verify its proper installation."
|
|
|
|
self yamlToJsonBinary exists ifTrue: [ ^ MiniDocs appFolder ].
|
|
|
|
Nimble install: 'commandeer'.
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'nim';
|
|
|
|
arguments: {'c'. self yamlToJsonSourceCode fullName};
|
|
|
|
runAndWaitOnExitDo: [ :process :outString |
|
2022-10-17 00:10:37 +00:00
|
|
|
(self yamlToJsonSourceCode parent / self yamlToJsonSourceCode basenameWithoutExtension) moveTo: MiniDocs appFolder asFileReference.
|
2022-10-16 23:52:07 +00:00
|
|
|
^ MiniDocs appFolder ]
|
|
|
|
]
|
|
|
|
|
2023-01-06 15:31:39 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> keyboardShortcutsRemapping [
|
|
|
|
| primaryNewLine secondaryNewLine |
|
|
|
|
primaryNewLine := LeSnippetElement keyboardShortcuts at: #NewLine.
|
|
|
|
secondaryNewLine := LeSnippetElement keyboardShortcuts at: #SecondaryNewLine.
|
|
|
|
^ LeSnippetElement keyboardShortcuts
|
|
|
|
at: #NewLine put: secondaryNewLine;
|
|
|
|
at: #SecondaryNewLine put: primaryNewLine;
|
|
|
|
at: #IndentSnippet put: self altShiftRightCombo;
|
|
|
|
at: #UnindentSnippet put: self altShiftLeftCombo;
|
|
|
|
yourself
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> shiftKeys [
|
|
|
|
^ BlAlternativeCombination new
|
|
|
|
with: (BlSingleKeyCombination key:BlKeyboardKey shiftLeft);
|
|
|
|
with: (BlSingleKeyCombination key:BlKeyboardKey shiftRight);
|
|
|
|
yourself.
|
|
|
|
]
|
|
|
|
|
2022-10-16 23:52:07 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> yamlToJson: yamlString [
|
2022-10-21 23:47:37 +00:00
|
|
|
"This method uses a external binary written in Nim, as the native Pharo parser for YAML, written in PetitParser,
|
|
|
|
was less robust and unable to parse correctly the same strings as the external one."
|
2022-10-16 23:52:07 +00:00
|
|
|
self yamlToJsonBinary exists ifFalse: [ self installYamlToJson ].
|
|
|
|
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: self yamlToJsonBinary fullName;
|
2022-10-17 00:10:37 +00:00
|
|
|
arguments: {yamlString};
|
|
|
|
redirectStdout;
|
|
|
|
runAndWaitOnExitDo: [ :process :outString |
|
|
|
|
^ (STONJSON fromString: outString allButFirst) first
|
|
|
|
]
|
2022-10-16 23:52:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> yamlToJsonBinary [
|
|
|
|
^ self appFolder / 'yamlToJson'
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
MiniDocs class >> yamlToJsonSourceCode [
|
2022-10-17 00:10:37 +00:00
|
|
|
^ FileLocator image parent / 'pharo-local/iceberg/Offray/MiniDocs/src/yamlToJson.nim'
|
2022-10-16 23:52:07 +00:00
|
|
|
]
|