X-Git-Url: http://nitlanguage.org diff --git a/src/metrics/model_hyperdoc.nit b/src/metrics/model_hyperdoc.nit index 8d8a10e..9e66e73 100644 --- a/src/metrics/model_hyperdoc.nit +++ b/src/metrics/model_hyperdoc.nit @@ -17,28 +17,73 @@ # Dump of Nit model into hypertext human-readable format. module model_hyperdoc -import model import metrics_base +redef class ToolContext + var model_hyperdoc_phase: Phase = new ModelHyperdocPhase(self, null) +end + +private class ModelHyperdocPhase + super Phase + redef fun process_mainmodule(mainmodule, given_mmodules) + do + if not toolcontext.opt_generate_hyperdoc.value and not toolcontext.opt_all.value then return + generate_model_hyperdoc(toolcontext, toolcontext.modelbuilder.model) + end +end + # Genetate a HTML file for the model. # The generated file contains the description of each entity of the model fun generate_model_hyperdoc(toolcontext: ToolContext, model: Model) do - var buf = new Buffer + var buf = new FlatBuffer buf.append("\n\n") buf.append("

Model

\n") + buf.append("

Projects

\n") + for mproject in model.mprojects do + buf.append("

Project {mproject}

\n") + buf.append("
\n") + buf.append("
groups
\n") + for x in mproject.mgroups do + buf.append("
{linkto(x)}
\n") + end + buf.append("
\n") + end + + buf.append("

Groups

\n") + for mproject in model.mprojects do + for mgroup in mproject.mgroups do + buf.append("

Group {mgroup}

\n") + buf.append("
\n") + buf.append("
project
\n") + buf.append("
{linkto(mproject)}
\n") + buf.append("
filepath
\n") + buf.append("
{mgroup.filepath.to_s}
\n") + var p = mgroup.parent + if p != null then + buf.append("
parent group
\n") + buf.append("
{linkto(p)}
\n") + end + buf.append("
nested groups
\n") + for x in mgroup.in_nesting.direct_smallers do + buf.append("
{linkto(x)}
\n") + end + buf.append("
modules
\n") + for x in mgroup.mmodules do + buf.append("
{linkto(x)}
\n") + end + end + buf.append("
\n") + end + buf.append("

Modules

\n") for mmodule in model.mmodules do buf.append("

{mmodule}

\n") buf.append("
\n") - buf.append("
direct owner
\n") - var own = mmodule.direct_owner - if own != null then buf.append("
{linkto(own)}
\n") - buf.append("
nested
\n") - for x in mmodule.in_nesting.direct_greaters do - buf.append("
{linkto(x)}
\n") - end + buf.append("
group
\n") + var grp = mmodule.mgroup + if grp != null then buf.append("
{linkto(grp)}
\n") buf.append("
direct import
\n") for x in mmodule.in_importation.direct_greaters do buf.append("
{linkto(x)}
\n") @@ -141,14 +186,18 @@ do end end buf.append("\n") - var f = new OFStream.open(toolcontext.output_dir.join_path("model.html")) + var f = new FileWriter.open(toolcontext.output_dir.join_path("model.html")) f.write(buf.to_s) f.close end private fun linkto(o: Object): String do - if o isa MModule then + if o isa MProject then + return "{o}" + else if o isa MGroup then + return "{o}" + else if o isa MModule then return "{o}" else if o isa MClass then return "{o}"