On Fri, May 2, 2014 at 12:07 PM, Laurent Laffont <[email protected]>
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 via email to