From: Alexandre Terrasa Date: Thu, 11 Jun 2015 06:57:32 +0000 (-0400) Subject: nitdoc: convert dot to svg instead of png X-Git-Tag: v0.7.6~3^2~1 X-Git-Url: http://nitlanguage.org nitdoc: convert dot to svg instead of png Signed-off-by: Alexandre Terrasa --- diff --git a/src/doc/doc_phases/doc_html.nit b/src/doc/doc_phases/doc_html.nit index 6532a1d..afeba88 100644 --- a/src/doc/doc_phases/doc_html.nit +++ b/src/doc/doc_phases/doc_html.nit @@ -585,15 +585,19 @@ end redef class GraphArticle redef fun init_html_render(v, doc, page) do - var output_dir = v.ctx.output_dir - var path = output_dir / graph_id - var path_sh = path.escape_to_sh + var path = v.ctx.output_dir / graph_id var file = new FileWriter.open("{path}.dot") file.write(dot) file.close - sys.system("\{ test -f {path_sh}.png && test -f {path_sh}.s.dot && diff -- {path_sh}.dot {path_sh}.s.dot >/dev/null 2>&1 ; \} || \{ cp -- {path_sh}.dot {path_sh}.s.dot && dot -Tpng -o{path_sh}.png -Tcmapx -o{path_sh}.map {path_sh}.s.dot ; \}") - var fmap = new FileReader.open("{path}.map") - self.map = fmap.read_all - fmap.close + var proc = new ProcessReader("dot", "-Tsvg", "-Tcmapx", "{path}.dot") + var svg = new Buffer + var i = 0 + while not proc.eof do + i += 1 + if i < 6 then continue # skip dot default header + svg.append proc.read_line + end + proc.close + self.svg = svg.write_to_string end end diff --git a/src/doc/html_templates/html_templates.nit b/src/doc/html_templates/html_templates.nit index ecff87f..bf14d90 100644 --- a/src/doc/html_templates/html_templates.nit +++ b/src/doc/html_templates/html_templates.nit @@ -559,16 +559,15 @@ end redef class GraphArticle redef var html_title = null - # HTML map used to display link. + # Graph in SVG with clickable map. # # This attribute is set by the `doc_render` phase who knows the context. - var map: String is noinit, writable + var svg: nullable String = null is writable redef fun render_body do addn "
" - addn " {title or else ""}" - add map + var svg = self.svg + if svg != null then add svg addn "
" end end