load("draw")$
docdraw(name,[contents]):=
(
    draw(
	append(
		[
			terminal=gif,
			dimensions=[800,600],
	                file_name=name
		],
		contents
	)
    ),
    draw(
	append(
		[
			terminal=pdf,
		        dimensions=[1200,800],
	                file_name=name
		],
		contents
	)
    )
)$
docdraw2d(name,[contents]):=docdraw(name,gr2d(contents))$
docdraw3d(name,[contents]):=docdraw(name,gr3d(contents))$
docplot(name,[contents]):=
(
    apply(
	plot,
	append(
		[
			[png_file, name]
		],
		contents
	)
    ),
    apply(
	plot,
	append(
		[
			[pdf_file, name]
		],
		contents
	)
    )
)$

doc_contour_plot(name,[contents]):=
(
    apply(
	contour_plot,
	append(
		contents,
		[
			[png_file, sconcat(name,".png")]
		]
	)
    ),
    apply(
	contour_plot,
	append(
		contents,
		[
			[pdf_file, sconcat(name,".pdf")]
		]
	)
    )
)$

load(implicit_plot)$
doc_implicit_plot(name,[contents]):=
(
    apply(
	implicit_plot,
	append(
		contents,
		[
			[png_file, sconcat(name,".png")]
		]
	)
    ),
    apply(
	implicit_plot,
	append(
		contents,
		[
			[pdf_file, sconcat(name,".pdf")]
		]
	)
    )
)$

doc_julia(name,[contents]):=
(
    apply(
	julia,
	append(
		contents,
		[
			[png_file, sconcat(name,".png")]
		]
	)
    ),
    apply(
	julia,
	append(
		contents,
		[
			[pdf_file, sconcat(name,".pdf")]
		]
	)
    )
)$

doc_mandelbrot(name,[contents]):=
(
    apply(
	mandelbrot,
	append(
		contents,
		[
			[png_file, sconcat(name,".png")]
		]
	)
    ),
    apply(
	mandelbrot,
	append(
		contents,
		[
			[pdf_file, sconcat(name,".pdf")]
		]
	)
    )
)$

doc_plot2d(name,[contents]):=
(
    apply(
	plot2d,
	append(
		contents,
		[
			[png_file, sconcat(name,".png")]
		]
	)
    ),
    apply(
	plot2d,
	append(
		contents,
		[
			[pdf_file, sconcat(name,".pdf")]
		]
	)
    )
)$

doc_plot3d(name,[contents]):=
(
    apply(
	plot3d,
	append(
		contents,
		[
			[png_file, sconcat(name,".png")]
		]
	)
    ),
    apply(
	plot3d,
	append(
		contents,
		[
			[pdf_file, sconcat(name,".pdf")]
		]
	)
    )
)$
