howdy

2009/12/10 Simon Loic <simon1l...@gmail.com>

>
>
>> The other one is to develop a simple script, let's say sample_to_html.py
>> that parses the python sample, run it to generate the screenshot and create
>> the html page.
>>
>
> The idea could be used with sphinx also. I mean instead of directly
> creating plain Html, we could generate 
> reStructuredText<http://docutils.sf.net/rst.html>
> files which might be easier to produce from a script. Then the script
> (sample_to_html.py) would just call sphinx to create final html pages.
>

Or you could just include a bit of javascript:
http://google-code-prettify.googlecode.com/svn/trunk/README.html or
more<http://www.1stwebdesigner.com/resources/16-free-javascript-code-syntax-highlighters-for-better-programming/>


> Anyway, what is not clear to me is how to parse the sample.
> I mean I see how we can get an  html page that only contains the source
> code (syntax higlighted). But what if we are to generate a page with more
> information (like the purpose of the sample, what is illustrated)? Honnestly
> I don't find my examples very convincing, so the code + screenshots should
> be a good starting point.
>
> Also about the screenshot, besides the offscreen rendering issue, do you
> think the external script (sample_to_html.py) should know what to take a
> screenshots? I personally see things differently, like having a custom
> function in each sample with always the same name (like getScreenShots, that
> will be called by sample_to_html.py. Or if we want to minimize editing the
> samples, we could simply add too each sample a custom variable storing the
> list of shapes we want to take a screenshot. This list would then be pass to
> sample_to_tmpl.py which will handle taking the screenshots (in offscreen
> mode soon ;-)) . Any comments?
>

Instead of addings somthting to the samples, you could just read in the
file, modify it with a script and write it to a temp file to be executed.
Think you could automate quite a lot of them with some some regular
expressions a bit more complex than this:

for line in source.readlines():
    line = re.sub("display.DisplayShape\(([.\ ]*)\)", lambda m:
"offscreen.add_shape(%s)" % m.group(1), line)
    line = re.sub("start_display\((.*)\)", lambda m: "offscreen_render(%s)"
% m.group(1), line)
    line = re.sub("add_function_to_menu\((.+),(.+)\)", lambda m:
"clear_display()\n%s(filename)\noffscreen_render()" % m.group(2).strip(),
line)
    #
    tmp.write(line)


Henrik
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to