Difference between revisions of "Template:ListEdges"

From AtlasWiki
Jump to: navigation, search
(first attempt, probably won't work this way)
 
(removing the trailing empty line from the tables)
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>For use on node kind pages; will eventually automatically lists all known kinds of in and out edges to/from this kind of node, and the kinds of nodes those edges come from.
+
<noinclude>For use on node kind pages, automatically lists edges declared on the current page.
  
Currently lists just the node/edge pairs that point explicitly to/from this kind of node, ignoring superkinds.
+
If the parameter "parents" is given a comma-separated list of the parents of the node, inherited edges will also be listed.
</noinclude>{{#ask: [[edge to {{FULLPAGENAME}}::+]]
+
</noinclude>{{#ask: [[permitted edge to {{PAGENAME}}::+]]
| mainlabel = In Edge
+
| ?permitted edge to {{PAGENAME}}
| [[{{explode:?|,|0}}]] = Predecessor (Comes From)
+
| format=array
| [[{{explode:?|,|1}}]] = Multiplicity
+
| headers=hide
| [[{{explode:?|,|2}}]] = Description
+
| name=permittedInEdges
| class=xcsgtable
+
}}{{#ask: [[specified edge to {{PAGENAME}}::+]]
| headers=plain
+
| ?specified edge to {{PAGENAME}}
 +
| format=array
 +
| headers=hide
 +
| name=specifiedInEdges
 +
}}{{#ask: [[permitted edge from {{PAGENAME}}::+]]
 +
| ?permitted edge from {{PAGENAME}}
 +
| format=array
 +
| headers=hide
 +
| name=permittedOutEdges
 +
}}{{#ask: [[specified edge from {{PAGENAME}}::+]]
 +
| ?specified edge from {{PAGENAME}}
 +
| format=array
 +
| headers=hide
 +
| name=specifiedOutEdges
 +
}}<noinclude><!--
 +
 
 +
Above, we've stored all the in edges in an arrays named "permittedInEdges", "specifiedInEdges", "permittedOutEdges", and "specifiedOutEdges".
 +
 
 +
Each entry in each array is in this format:
 +
 
 +
[name of edge]<PROP>[name of predecessor]$SEP$[multiplicity]$SEP$[edge description]
 +
 
 +
...except that, if there are multiple entries from the same edge, they will be separated by "<MANY>",
 +
and the name of the edge will not be repeated, i.e., if there are two possible predecessors for a specific
 +
edge type, the format will be:
 +
 
 +
[name of edge]<PROP>[name of predecessor]$SEP$[multiplicity]$SEP$[edge description]<MANY>[name of other predecessor]$SEP$[multiplicity]
 +
 
 +
...now we want similar information about inherited in edges:
 +
 
 +
--></noinclude>{{#arraydefine:parentsArray|{{{parents|}}}|,|}}<noinclude><!--
 +
 +
We gather the information on inherited edges as well, then defer to a helper template to print the actual tables
 +
 
 +
There's one tricky bit here: we need to have a <PARENT_SEP> separator if and only if a parent actually contributes connections. We do that by not using the separator argument of the #arrayprint:parentsArray, and instead printing <PARENT_SEP> after each one...which results in one small problem: there's an extra <PARENT_SEP> on the end that we need to remove...so we parse the result into an array again, slice off the final element with #arrayslice, and re-print it using <PARENT_SEP> as the separator.
 +
 +
--></noinclude>{{ListEdges.generateTable
 +
| title = Specified In Edges
 +
| edgeTitle = In Edge
 +
| nodeTitle = <abbr title="The node that the edge comes from">Predecessor</abbr>
 +
| uninheritedEdges = {{#arrayprint:specifiedInEdges|<EDGE_SEP>}}
 +
| inheritedEdges = {{#arraydefine:temp|{{#arrayprint:parentsArray||@@@@|{{#if:{{EdgesTo|@@@@|specified}}|@@@@<PARENT>{{EdgesTo|@@@@|specified}}<PARENT_SEP>}} }}|<PARENT_SEP>|}}{{#arrayslice:temp|temp|0|{{#expr:{{#arraysize:temp}}-1}}}}{{#arrayprint:temp|<PARENT_SEP>|@@@@|@@@@}}
 +
}}{{ListEdges.generateTable
 +
| title = Specified Out Edges
 +
| edgeTitle = Out Edge
 +
| nodeTitle = <abbr title="The node that the edge points to">Successor</abbr>
 +
| uninheritedEdges = {{#arrayprint:specifiedOutEdges|<EDGE_SEP>}}
 +
| inheritedEdges = {{#arraydefine:temp|{{#arrayprint:parentsArray||@@@@|{{#if:{{EdgesFrom|@@@@|specified}}|@@@@<PARENT>{{EdgesFrom|@@@@|specified}}<PARENT_SEP>}} }}|<PARENT_SEP>|}}{{#arrayslice:temp|temp|0|{{#expr:{{#arraysize:temp}}-1}}}}{{#arrayprint:temp|<PARENT_SEP>|@@@@|@@@@}}
 +
}}{{ListEdges.generateTable
 +
| title = Known Possible In Edges
 +
| edgeTitle = In Edge
 +
| nodeTitle = <abbr title="The node that the edge comes from">Predecessor</abbr>
 +
| uninheritedEdges = {{#arrayprint:permittedInEdges|<EDGE_SEP>}}
 +
| inheritedEdges = {{#arraydefine:temp|{{#arrayprint:parentsArray||@@@@|{{#if:{{EdgesTo|@@@@|permitted}}|@@@@<PARENT>{{EdgesTo|@@@@|permitted}}<PARENT_SEP>}} }}|<PARENT_SEP>|}}{{#arrayslice:temp|temp|0|{{#expr:{{#arraysize:temp}}-1}}}}{{#arrayprint:temp|<PARENT_SEP>|@@@@|@@@@}}
 +
}}{{ListEdges.generateTable
 +
| title = Known Possible Out Edges
 +
| edgeTitle = Out Edge
 +
| nodeTitle = <abbr title="The node that the edge points to">Successor</abbr>
 +
| uninheritedEdges = {{#arrayprint:permittedOutEdges|<EDGE_SEP>}}
 +
| inheritedEdges = {{#arraydefine:temp|{{#arrayprint:parentsArray||@@@@|{{#if:{{EdgesFrom|@@@@|permitted}}|@@@@<PARENT>{{EdgesFrom|@@@@|permitted}}<PARENT_SEP>}} }}|<PARENT_SEP>|}}{{#arrayslice:temp|temp|0|{{#expr:{{#arraysize:temp}}-1}}}}{{#arrayprint:temp|<PARENT_SEP>|@@@@|@@@@}}
 
}}
 
}}

Latest revision as of 14:03, 12 May 2014

For use on node kind pages, automatically lists edges declared on the current page.

If the parameter "parents" is given a comma-separated list of the parents of the node, inherited edges will also be listed.