Update templates.md
Script to generate `mysources.list`
MODIFY
docs/templates.md
docs/templates.md
@@ -37,10 +37,31 @@ There are different ways:
You can create your own templates from Pharo Launcher. From any image in the image list, right-click and select `Create template` or `Create template and delete image`. It will create a zip file from the selected image and put it in the Templates category under the provided name.
## Create your own list of template categories
-Pharo already provides a wide range of templates but you can provide your own categories. It is useful to add templates that are private (e.g. private jenkins instance) or only of interest for you. It is doable thanks to the `mysources.list` file located in the Pharo folder. If present, this file defines additional template sources to the official list of templates. At this time, there is no UI to add them but you can take inspiration from the following examples.
-Warning: take care to separate each template category by a comma. All categories should be enclosed inside `[]`.
+Pharo already provides a wide range of templates but you can provide your own categories. It is useful to add templates that are private (e.g. private jenkins instance) or only of interest for you. It is doable thanks to the `mysources.list` file located in the `PhLUserTemplateSources sourcesFile` folder. If present, this file defines additional template sources beyond the official list of templates. At this time, there is no UI to add them but you can take inspiration from the following examples.
-Here is an example of a `mysources.list` file:
+Here is a Pharo script to generate an example file:
+```smalltalk
+| sources |
+ sources := {
+ PhLTemplateSource new
+ type: #HttpListing;
+ name: 'User-defined http listing';
+ url: 'http://myserver.org/myimages/'.
+ PhLTemplateSource new
+ type: #JenkinsServer;
+ name: 'My Jenkins server';
+ url: 'https://jenkins.mycompany.org';
+ username: 'john';
+ password: 'doefkwoiekfdoekdw2302ek349039e' }.
+
+ PhLUserTemplateSources sourcesFile writeStreamDo: [ :s |
+ (STON writer on: s)
+ newLine: String lf;
+ prettyPrint: true;
+ nextPut: sources ]
+```
+
+You can also edit the file directly if you are comfortable with JSON. Warning: take care to separate each template category by a comma. All categories should be enclosed inside `[]`. Here is the `mysources.list` file generated by the above script:
```json
[
PhLTemplateSource {

Update templates.md

Script to generate `mysources.list`