Skip to content

Commit 85a8210

Browse files
FlavienVolantFlavienVolant
andauthored
start writing ### Automatically transforming scripts into debugger commands + screenshots (#4)
* start writing ### Automatically transforming scripts into debugger commands + some screenshots * improve Automatically transforming scripts into debugger commands and add How to load a scripting library --------- Co-authored-by: FlavienVolant <[email protected]>
1 parent 015c9d5 commit 85a8210

6 files changed

Lines changed: 38 additions & 11 deletions

sindarin/extending.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,36 @@ here, you can see all your saved scripts. Select 'Step Until #parseObject', then
260260

261261
### Automatically transforming scripts into debugger commands
262262

263-
(This part do Adding a new menu extending the debugger and Command for you)
263+
Previously we learned how to turn a script to a command. We had to manually extend the debugger and its toolbar and create our SindarinCommand subclasse. Theses steps are not easy and can be redundant especially if you wish to have several commands.
264264

265-
Click the "+" button (Create a command from the current debugging scripts)
266-
Then give your command a description and give it an Icon (from the pharo icon list)
267-
Restart your debuggeur to update the menus lists and theirs commands (By default your command is created in the "Scripts" menu).
268-
If you don't want this command in your group you can delete it by pressing the "x" button.
265+
Fortunately transforming a script to a debugger command make this process for you !
266+
267+
First, load or write your script and then click the "Create a command from the current debugging scripts" button:
268+
![The create a command from scripts button](graphics/sindarin-create-command-button.png)
269+
The layout should change to:
270+
![The create command layout](graphics/sindarin-create-command-layout.png)
271+
272+
The script name is used to generate the command name.
273+
You can give your command a description and select an icon (from the pharo icon list) before clicking 'Create'.
274+
275+
Restart your debuggeur to update the menus lists and theirs commands (By default your command is created in the "Scripts" menu) now you should see your command menu with yout command in it !
276+
![Your command in the Debugger toolbar](graphics/sindarin-command-in-scripts-menu-toolbar.png)
277+
278+
If you wish to find the generated code go to the package 'NewTools-Sindarin-Tools' (it's the default location):
279+
- In tag 'Scripts' you can find your command
280+
![Your generated command class](graphics/sindarin-generated-command.png)
281+
- In the tag 'Extensions', in StDebugger class side you can find the method to 'buildSindarin...ExtensionCommandsGroupWith: forRoot' that add your menu:
282+
![Your generated command group](graphics/sindarin-build-extension-generated.png)
283+
284+
If you wish to remove a command from your group, load it from the script loader and delete it by pressing the "x" button. The generated code is deleted.
269285

270286
### Build your own scripting library and make it available to the community
271287

272-
create a new class in your package, this class should extend StSindarinDebuggerScriptRepository
288+
For now every commands you create are display in the 'Scripts' group. You may be working on domain specific scripts and wish to have them in a specific group, like previously with the STON group.
289+
290+
In the package you want to save your commands, create a class wich extend StSindarinDebuggerScriptRepository
273291
```Smalltalk
274-
StSindarinDebuggerScriptRepository << #MySindarinCommandsMenu
292+
StSindarinDebuggerScriptRepositoryAbstract << #MySindarinCommandsMenu
275293
slots: {};
276294
package: 'my-sindarin-commands'
277295
```
@@ -282,14 +300,23 @@ repositoryName
282300
^ 'My Scripting Library'
283301
```
284302

285-
Now go to the debuggeur and click on the drop list next to the remove command, you should see your new Scripting Library.
286-
Select it and every command will be put in your library
303+
Now in the debuggeur, click on the drop list next to the remove command, you should see your new Scripting Library.
304+
Select it and every scripts and commands saved and created will be in your library.
287305

288-
in your package you can now see your commands as classes:
306+
Once you generate a command fron a script, your package become the corresponding class location.
289307
``` Smalltalk
290308
SindarinCommand << #SindarinMyScriptingLibraryLastUpdatedCommand
291309
slots: {};
292310
package: 'my-sindarin-commands'
293311
```
294312

295-
if you wish to share your library to the community, other only need your package and reopen their debuggeur.
313+
If you wish to share your library to the community, other only need your package. You can save it in a git repository and give acces to your code.
314+
315+
### How to load a scripting library
316+
317+
For this part we assume that the library is in a github repository.
318+
319+
Open the git repository browser "ctrl + oi", click 'Add a repository', enter the git repository credentials.
320+
Load the Pharo repository in your image and just like the scriptings library is usable in the debuger.
321+
322+
Note that only commands are shared, unlike scripts.
278 KB
Loading
57.5 KB
Loading
61.2 KB
Loading
60.1 KB
Loading
241 KB
Loading

0 commit comments

Comments
 (0)