Skip to content

Commit

Permalink
omc - Symbol Reference - sort aggregation information, support multip…
Browse files Browse the repository at this point in the history
…le 'to' aggregations
  • Loading branch information
esseff committed Apr 18, 2024
1 parent f333f58 commit cccaca2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions openm/omc/omc_model_doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClassificationSymbol*>(s);
assert(c);
/// aggregations to this classification
std::list<AggregationSymbol*> 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;
Expand Down Expand Up @@ -1453,6 +1456,7 @@ void do_model_doc(
mdStream << "|<table\n"; // maddy-specific end table
theTable.clear();
}
alist.clear();
}

// table showing aggregations of this classification
Expand All @@ -1466,6 +1470,8 @@ void do_model_doc(
clist.push_back(a->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 << "<strong>" + LTA(lang, "Aggregations of") + " <code>" + s->name + "</code>:</strong>\n\n";
mdStream << "|table>\n"; // maddy-specific begin table
Expand Down

0 comments on commit cccaca2

Please sign in to comment.