Login  Register

Making screenshots programmatically for book

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Making screenshots programmatically for book

Stephan Eggermont-3
2807 posts
What is the best way to make screenshots for documentation? In Pillar we mostly have a figures directory with pngs. With the change rate of Pharo, making them by hand seems a bad idea.

Stephan
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

laurent laffont
2013 posts
Why not putting Smalltalk code that will take the screenshot and save it in the documentation ? Makes good functionnal tests too à la Python.

Laurent

Le vendredi 2 mai 2014, 11:27:47 Stephan Eggermont a écrit :
> What is the best way to make screenshots for documentation? In Pillar we mostly have a figures directory with pngs. With the change rate of Pharo, making them by hand seems a bad idea.
>
> Stephan


Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

kilon.alios
2862 posts
Very interesting concept, it indeed could help keep the images up to date with Pharo :) 

Maybe we should agree on some convention or use a common library for them that will take these images with just a single message ? Or even make it part of Pillar syntax ?


On Fri, May 2, 2014 at 1:07 PM, Laurent Laffont <[hidden email]> wrote:
Why not putting Smalltalk code that will take the screenshot and save it in the documentation ? Makes good functionnal tests too à la Python.

Laurent

Le vendredi 2 mai 2014, 11:27:47 Stephan Eggermont a écrit :
> What is the best way to make screenshots for documentation? In Pillar we mostly have a figures directory with pngs. With the change rate of Pharo, making them by hand seems a bad idea.
>
> Stephan



Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Sergi Reyner
123 posts
In reply to this post by Stephan Eggermont-3
2014-05-02 10:27 GMT+01:00 Stephan Eggermont <[hidden email]>:
What is the best way to make screenshots for documentation? In Pillar we mostly have a figures directory with pngs. With the change rate of Pharo, making them by hand seems a bad idea.

Adapting PasteUpMorph>>#makeAScreenshot?

Cheers,
Sergi
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

stepharo
5159 posts
In reply to this post by Stephan Eggermont-3
I'm interested in the solution you propose.
To me it should
     load a package
     run some code
     open the right window and save the screenshots.

Right now working on
https://ci.inria.fr/pharo-contribution/job/PharoLaserGame/17/artifact/LaserGame.pdf


Stef
On 2/5/14 11:27, Stephan Eggermont wrote:
> What is the best way to make screenshots for documentation? In Pillar we mostly have a figures directory with pngs. With the change rate of Pharo, making them by hand seems a bad idea.
>
> Stephan
>
>


Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Damien Cassou
1829 posts
In reply to this post by laurent laffont

On Fri, May 2, 2014 at 12:07 PM, Laurent Laffont <[hidden email]> wrote:
> Why not putting Smalltalk code that will take the screenshot and save it in the documentation ? Makes good functionnal tests too à la Python.


FYI, it is possible to include Smalltalk code in Pillar files that will be executed when the Pillar file is compiled. This Smalltalk code can write to a stream in order to generate dynamic content. I use it to generate a part of Pillar documentation (https://github.com/DamienCassou/pillar-documentation#42--configuration-parameters) :


[[[language=Smalltalk|eval=true
| writeConfigurationParameter |
writeConfigurationParameter := [: pragma | | methodWithDefaultValue methodComment |
methodComment := [ :aMethod |
    aMethod comment
        ifNil: [ 'uncommented' ]
        ifNotNil: [ :comment | comment trimBoth: [ :c | c = $" ] ] ].
methodWithDefaultValue := pragma methodClass >> (#default , pragma selector capitalized) asSymbol.
stream
    nextPutAll: '!!!! ' , pragma selector;
    lf;
    nextPutAll: '@sec:confParam:', pragma selector;
    lf;
    nextPutAll: (methodComment value: pragma method);
    lf;
    lf;
    nextPutAll: ';Default value';
    lf;
    nextPutAll: ':';
    nextPutAll:
            (methodWithDefaultValue comment
                    ifNotNil: [ methodComment value: methodWithDefaultValue ]
                    ifNil: [
                        methodWithDefaultValue isQuick
                            ifTrue: [ '==', methodWithDefaultValue ast statements first value formattedCode, '==' ]
                            ifFalse: [ 'uncommented' ] ]);
    lf;
    lf
    ].

((Pragma allNamed: #pillarConfigurationParameter in: PRExportConfiguration) sort: [ :p1 :p2 | p1 selector < p2 selector ])
        do: [ :pragma | writeConfigurationParameter value: pragma ]

]]]



--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without losing enthusiasm."
Winston Churchill
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Stephan Eggermont-3
2807 posts
In reply to this post by Stephan Eggermont-3
Damien wrote:
>FYI, it is possible to include Smalltalk code in Pillar files that will be executed when the Pillar file is compiled. This Smalltalk >code can write to a stream in order to generate dynamic content. I use it to generate a part of Pillar documentation 

Ha, that sounds like exactly what I need. Thank you.

Stephan
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

kilon.alios
2862 posts
If you happen to come up with code for this , because I am updating the Pharo By Example book for Pharo 3 as you can imagine I would be super interested into looking at such code. Would make my life easier :) 


On Wed, May 7, 2014 at 6:23 PM, Stephan Eggermont <[hidden email]> wrote:
Damien wrote:
>FYI, it is possible to include Smalltalk code in Pillar files that will be executed when the Pillar file is compiled. This Smalltalk >code can write to a stream in order to generate dynamic content. I use it to generate a part of Pillar documentation 

Ha, that sounds like exactly what I need. Thank you.

Stephan

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Stephan Eggermont-3
2807 posts
In reply to this post by Stephan Eggermont-3
This code allows me to generate some screenshots.
The exporter deletes the old picture, if it exists.

|directory exporter window bounds |
directory := FileSystem workingDirectory / 'pictures' .
directory ensureCreateDirectory.
exporter := DOScreenshotExporter new.
exporter directory: directory.
exporter writeWorldAs: 'world.png'.
window := DOPartiesList new openWithSpec window.
exporter writeMorph: window value as: 'PartiesList.png'.
bounds := window fullBounds.
exporter writeMorph: window value rectangle: (bounds insetBy: 20@20) as: 'PartOfPartiesList.png'.
window close.







DOScreenshotExporter.st (1K) Download Attachment
world.png (181K) Download Attachment
PartiesList.png (12K) Download Attachment
PartOfPartiesList.png (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Ben Coman
5447 posts
Stephan Eggermont wrote:

> This code allows me to generate some screenshots.
> The exporter deletes the old picture, if it exists.
>
> |directory exporter window bounds |
> directory := FileSystem workingDirectory / 'pictures' .
> directory ensureCreateDirectory.
> exporter := DOScreenshotExporter new.
> exporter directory: directory.
> exporter writeWorldAs: 'world.png'.
> window := DOPartiesList new openWithSpec window.
> exporter writeMorph: window value as: 'PartiesList.png'.
> bounds := window fullBounds.
> exporter writeMorph: window value rectangle: (bounds insetBy: 20@20) as: 'PartOfPartiesList.png'.
> window close.
>  
Now what is the best way to associate such code with a Pillar source file.
1. Put screenshot generation script inline?
2. Put screenshot generation script in a separate file with same
basename as the produced bitmap file?
   2a. Have a command line handler to manually invoke snapshot generation?
   2b. Have a Pillar notation that references the script rather than the
produced file, and generate snapshot each time? (maybe good for CI, but
slows user down)

cheers -ben

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Ben Coman
5447 posts
Ben Coman wrote:

> Stephan Eggermont wrote:
>> This code allows me to generate some screenshots.
>> The exporter deletes the old picture, if it exists.
>>
>> |directory exporter window bounds |
>> directory := FileSystem workingDirectory / 'pictures' .
>> directory ensureCreateDirectory.
>> exporter := DOScreenshotExporter new.
>> exporter directory: directory.
>> exporter writeWorldAs: 'world.png'.
>> window := DOPartiesList new openWithSpec window.
>> exporter writeMorph: window value as: 'PartiesList.png'.
>> bounds := window fullBounds.
>> exporter writeMorph: window value rectangle: (bounds insetBy: 20@20)
>> as: 'PartOfPartiesList.png'.
>> window close.
>>  
> Now what is the best way to associate such code with a Pillar source
> file.
> 1. Put screenshot generation script inline?
> 2. Put screenshot generation script in a separate file with same
> basename as the produced bitmap file?
>   2a. Have a command line handler to manually invoke snapshot generation?
>   2b. Have a Pillar notation that references the script rather than
> the produced file, and generate snapshot each time? (maybe good for
> CI, but slows user down)
>
> cheers -ben
>
>
Thinking further on this, it could be useful when Pillar processes a
source file to mark code to be executed in the image running Pillar.  
For instance when the reader is asked to do something, sometimes a
snapshot taken manually might be done out of order and something
not-yet-done (in the sequence of the tutorial) slips into the snapshot.  
For example, if the reader is asked to add a class, Pillar source might
hypothetically look like this...
    [[[
    Object subclass: #BlankCell
           instanceVariableNames: ''
           classVariableNames: ''
           category: 'LaserGame-Model'
    ]]] executeInImage
    +First class
created>generateFrom://figures/firstClass.st>file://figures/firstClass.png|width=50|label=firstClass+

This would ensure the snapshots a synchronised with the narrative.

That is how it might work for code blocks that are shown in the
narrative, but you might also want to be able to execute support code in
the background.  Probably you would want to save the image to a new file
to avoid accidentally corrupting the Pillar program.

This is not something I'd want to play with right now, but just
interested in feedback while its fresh in my mind.

cheers -ben

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Making screenshots programmatically for book

Stephan Eggermont-3
2807 posts
In reply to this post by Stephan Eggermont-3
I haven't given the way to integrate this in the Pillar workflow enough thought. I need new pictures when:
- I don't have any yet;
- Possibly when the text changed;
- When the image changed;
- With a different UITheme.

For web applications, I need to integrate with something like Selenium Webdriver to get browser screenshots

Stephan

Verstuurd vanaf mijn iPhone