Difference between revisions of "Template:ListEdges"

From AtlasWiki
Jump to: navigation, search
(first attempt, probably won't work this way)
 
(updated to improved version from ListEdgesWIP (one minor issue with links to the predecessor/successor being bold instead of links))
Line 3: Line 3:
 
Currently lists just the node/edge pairs that point explicitly to/from this kind of node, ignoring superkinds.
 
Currently lists just the node/edge pairs that point explicitly to/from this kind of node, ignoring superkinds.
 
</noinclude>{{#ask: [[edge to {{FULLPAGENAME}}::+]]
 
</noinclude>{{#ask: [[edge to {{FULLPAGENAME}}::+]]
| mainlabel = In Edge
+
| ?edge to {{FULLPAGENAME}}
| [[{{explode:?|,|0}}]] = Predecessor (Comes From)
+
| format=array
| [[{{explode:?|,|1}}]] = Multiplicity
+
| headers=hide
| [[{{explode:?|,|2}}]] = Description
+
| propsep=$SEP$
| class=xcsgtable
+
| name=inEdges
| headers=plain
+
}}<noinclude><!--
 +
 
 +
Above, we've stored all the in edges in an array named "inEdges".
 +
 
 +
Each entry in the array is in this format:
 +
 
 +
[link to edge]$SEP$[name of predecessor]$SEP$[multiplicity]$SEP$[edge description])
 +
 
 +
...now we parse those into an "In Edge" table, if and only if there is at least one in edge:
 +
 
 +
--></noinclude>{{#switch:{{#arraysize:inEdges}}| 0 = | #default =
 +
{{{!}} class="xcsgtable"
 +
! In Edge !! Predecessor (Comes From) !! Multiplicity !! Description
 +
{{!}}-
 +
{{!}}{{#arrayprint:inEdges|{{!}}-
 +
{{!}}|var|[[{{#explode:var|$SEP$|0}}]] {{!}}{{!}} [[{{#explode:var|$SEP$|1}}]] {{!}}{{!}} {{#explode:var|$SEP$|2}} {{!}}{{!}} {{#explode:var|$SEP$|3}} }}
 +
{{!}}}
 +
}}<noinclude><!--
 +
 
 +
Next we get the out edges:
 +
 
 +
--></noinclude>{{#ask: [[edge from {{FULLPAGENAME}}::+]]
 +
| ?edge from {{FULLPAGENAME}}
 +
| format=array
 +
| headers=hide
 +
| propsep=$SEP$
 +
| name=outEdges
 +
}}<noinclude><!--
 +
 
 +
If both arrays have values, then we need to add the whitespace that goes between the two tables.
 +
 
 +
--></noinclude>{{#switch:{{#arraysize:inEdges}}| 0 = | #default = {{#switch:{{#arraysize:outEdges}}| 0 = |
 +
 
 +
}} }}<noinclude><!--
 +
 
 +
Finally, we print the out edges table:
 +
 
 +
--></noinclude>{{#switch:{{#arraysize:outEdges}}| 0 = | #default =
 +
{{{!}} class="xcsgtable"
 +
! Out Edge !! Successor (Points To) !! Multiplicity !! Description
 +
{{!}}-
 +
{{!}}{{#arrayprint:outEdges|{{!}}-
 +
{{!}}|var|[[{{#explode:var|$SEP$|0}}]] {{!}}{{!}} [[{{#explode:var|$SEP$|1}}]] {{!}}{{!}} {{#explode:var|$SEP$|2}} {{!}}{{!}} {{#explode:var|$SEP$|3}} }}
 +
{{!}}}
 
}}
 
}}

Revision as of 12:54, 27 March 2014

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.

Currently lists just the node/edge pairs that point explicitly to/from this kind of node, ignoring superkinds.