Documentation targets fail completely if there's no jpeg support
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=2689
Reported by Martin Stjernholm mast@roxen.com
I think better error handling is needed here; an external lib shouldn't be required to get any documentation at all.
mkxml: Image.Color.Color-> : Image.Color.Color->grey
mkxml: Image.Color.Color-> :
Image.Color.Color->name,Image.Color.Color->html,Image.Color.Color->hex
mkxml: Image.Color.Color-> : Image.Color.Color->`==
mkxml: Image.Color colors : Image.Color colors
-:32:Index 'encode' not present in module 'JPEG'.
"file='/home/mast/Pike/devel/refdoc/../src/modules/Image/colors.c'
first-line='89'"
******
0000:
0001: class Interceptor {
0002: string buffer = "";
0003:
0004: void `()(string in) {
0005: buffer += in;
0006: }
0007:
0008: string get() {
0009: return buffer;
0010: }
0011: }
0012:
0013: Interceptor write = Interceptor();
0014:
0015: int img_counter;
0016: string prefix;
0017: void create(int _img_counter, string _prefix) {
0018: img_counter = _img_counter;
0019: prefix = _prefix;
0020: }
0021:
0022: string illustration(string|Image.Image img, mapping extra,
void|string suffix) {
0023: string fn = prefix + "." + (img_counter++) + (suffix||".png");
0024: if(!stringp(img)) img = Image.PNG.encode(img);
0025: Stdio.write_file(fn, img);
0026: werror("Wrote %s from execute.\n", fn);
0027: return "<image>"+fn+"</image>";
0028: }
0029:
0030: string illustration_jpeg(Image.Image img, mapping extra) {
0031: return illustration(Image.JPEG.encode(img, extra), extra,
".jpeg");
0032: }
0033:
0034: string mktag(string name, void|mapping args, void|string c) {
0035: if(!args) args = ([]);
0036: if(!c)
0037: return sprintf("<%s%{ %s='%s'%} />", name, (array)args);
0038: return sprintf("<%s%{ %s='%s'%}>%s</%s>", name, (array)args, c,
name);
0039: }
0040:
0041: array(string) tag_stack = ({});
0042:
0043: string begin_tag(string name, void|mapping args) {
0044: if(!args) args = ([]);
0045: tag_stack += ({ name });
0046: return sprintf("<%s%{ %s='%s'%}>", name, (array)args);
0047: }
0048:
0049: string end_tag() {
0050: if(!sizeof(tag_stack)) throw( ({ "Tag stack underflow.\n",
backtrace() }) );
0051: string name = tag_stack[-1];
0052: tag_stack = tag_stack[..sizeof(tag_stack)-2];
0053: return "</" + name + ">";
0054: }
0055:
0056: string fix_image_path(string name) {
0057: return "/home/mast/Pike/devel/refdoc/src_images/" + name;
0058: }
0059:
0060:
0061:
0062: import Image;
0063:
0064: array modifiers=({"neon","light","dark","bright","dull"});
0065:
0066: object F=Font();
0067:
0068: mixed color_info(array(object) ac)
0069: {
0070:
0071: #define YZ 14
0072: #define YZz (YZ+1)
0073: #define MODX 32
0074: #define CXZ 64
0075: #define CSP 8
0076: #define MSP 4
0077: #define LSP 4
0078: #define XTEXT 100
0079: #define XSP 4
0080: #define cPOS (XTEXT+XSP)
0081: #define tPOS 0
0082: #define txPOS(t) (XSP*2)
0083: #define XZ (CXZ+CSP+(MSP+MODX)*sizeof(modifiers)-MSP)
0084:
0085: object i=Image(XZ+XTEXT,YZz*sizeof(ac),Color.black);
0086: object a=Image(XZ+XTEXT,YZz*sizeof(ac),Color.black);
0087:
0088: int y=0;
0089: foreach (ac,object c)
0090: {
0091: i->box(cPOS+0, y, cPOS+CXZ-1,y+YZ-1,c);
0092: i->box(cPOS+CXZ,y+YZ-LSP,cPOS+XZ, y+YZ-1,c);
0093: a->box(cPOS+0, y, cPOS+CXZ-1,y+YZ-1,Color.white);
0094: a->box(cPOS+CXZ,y+YZ-LSP,cPOS+XZ, y+YZ-1,Color.white);
0095:
0096: int x=CXZ+CSP+cPOS;
0097: foreach (modifiers,string mod)
0098: {
0099: i->box(x,y,x+MODX-1,y+YZ-LSP-1,c[mod]());
0100: a->box(x,y,x+MODX-1,y+YZ-LSP-1,Color.white);
0101: x+=MSP+MODX;
0102: }
0103: i->box(tPOS,y,tPOS+XTEXT-XSP-1,y+YZ-1,
0104: c->neon()->dark()->dark()->dark());
0105: a->box(tPOS,y,tPOS+XTEXT-XSP-1,y+YZ-1,Color.white);
0106: i->paste_alpha_color(F->write(c->name()), Color.white,
0107: txPOS(c->name()),y+1);
0108: y+=YZz;
0109: }
0110:
0111: write(illustration(i,(["alpha":a])));
0112: write(mktag("br")+"\n");
0113: }
0114:
0115: void main()
0116: {
0117: array cs=values(Color);
0118:
0119: array orig=({Color.black,Color.red,Color.green,Color.yellow,
0120: Color.blue,Color.violet,Color.cyan,Color.white});
0121: cs-=orig;
0122: cs-=({Color.pikegreen,Color.avantgardepikegreen,Color.roxenorange,
0123: Color.pikeblue}); // Lame sort of easter egg.
0124:
0125: array grey=Array.filter(cs,lambda(object c) { return c->s==0; });
0126: array colored=cs-grey;
0127:
0128: sort(grey->v,grey);
0129: sort(Array.map(colored,lambda(object c)
0130: {
0131: return (c->h*50-c->s)*10+c->v;
0132: }),colored);
0133:
0134: Array.map(({orig}),color_info);
0135: // write("\240");
0136: Array.map(({grey}),color_info);
0137: // write("\240");
0138: Array.map(colored/8.0,color_info);
0139: }
0140:
0141:
******
Compilation failed.
/home/mast/Pike/devel/build/linux-2.4.14-i686/master.pike:224:
master()->compile_string("\n class Interceptor {\n string buffer =
\"\";\n\n void `()(str
ing in) {\n buffer += in;\n }\n\n string get() {\n
return buffer;\n }\n }\n\
n Interceptor write = Interceptor();\n\n
in"+[3470],0,0)
/home/mast/Pike/devel/refdoc/bin/mirardoc.pike:917:
__lambda_65603_27_line_906(/home/mast/Pike/devel/build/linux-2.4.14-i686/lib/modules/Parser.pmod /_parser.so.HTML(),([]),"\n\nimport Image;\n\narray modifiers=({"neon","light","+[2045],"fil
e='/home/mast/Pike/devel/refdoc/../src/modules/"+[32])
/home/mast/Pike/devel/build/linux-2.4.14-i686/lib/modules/Parser.pmod/_parser.so.HTML:
finish("\nThis table lists all the different named colors available in
Image.Color.\nThe first c
olumn shows the actual color while the five following
columns\ndemonstrates the modifiers neon,
light, dark,
br"+[2314])
/home/mast/Pike/devel/refdoc/bin/mirardoc.pike:245:
fixdesc("\nThis table lists all the different named colors available in
Image.Color.\nThe first
column shows the actual
co"+[2399],"","file='/home/mast/Pike/devel/refdoc/../src/modules/Image/c
olors.c'
first-line='89'")
/home/mast/Pike/devel/refdoc/bin/mirardoc.pike:595:
document("appendix",mapping[2],"Image.Color
colors","",/home/mast/Pike/devel/refdoc/bin/mirardoc
.pike.__class_65603_24_line_778())
/home/mast/Pike/devel/refdoc/bin/mirardoc.pike:794:
make_doc_files("../../../images")
/home/mast/Pike/devel/refdoc/bin/extract.pike:54:
main(3,({"/home/mast/Pike/devel/refdoc/../src/modules/Image/colors.c","../../../images"}))