From cccaca20aa485bb767d40979e36dad77e5ff778e Mon Sep 17 00:00:00 2001 From: esseff Date: Thu, 18 Apr 2024 10:53:34 -0400 Subject: [PATCH] omc - Symbol Reference - sort aggregation information, support multiple 'to' aggregations --- openm/omc/omc_model_doc.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/openm/omc/omc_model_doc.cpp b/openm/omc/omc_model_doc.cpp index f3120049..af9994fa 100644 --- a/openm/omc/omc_model_doc.cpp +++ b/openm/omc/omc_model_doc.cpp @@ -1374,20 +1374,23 @@ void do_model_doc( } } - // table showing aggregation if this classification is an aggregation + // sections showing aggregation if this classification is an aggregation of another if (s->is_classification()) { auto c = dynamic_cast(s); assert(c); + /// aggregations to this classification + std::list alist; AggregationSymbol* aggr = nullptr; for (auto a : Symbol::pp_all_aggregations) { if (c == a->pp_to) { - // the current classification is an aggregation of another classification - aggr = a; - break; + alist.push_back(a); } } - if (aggr) { + // sort matching aggregations by name of 'from' classification + alist.sort([](AggregationSymbol* a, AggregationSymbol* b) { return a->pp_from->name < b->pp_from->name; }); + for (auto& aggr : alist) { // alist is possibly empty auto c_from = aggr->pp_from; + assert(c_from); // read the aggregation and turn it into a list of rows struct row { int from_ord; @@ -1453,6 +1456,7 @@ void do_model_doc( mdStream << "|pp_to); } } + // sort classification list by name of 'to' classification + clist.sort([](ClassificationSymbol* a, ClassificationSymbol* b) { return a->name < b->name; }); if (clist.size() > 0) { mdStream << "" + LTA(lang, "Aggregations of") + " " + s->name + ":\n\n"; mdStream << "|table>\n"; // maddy-specific begin table