Difference between revisions of "Template:ListEdgesWIP"

From AtlasWiki
Jump to: navigation, search
(a second attempt at inheritance)
(Now uses a separate template to generate tables, all tables are being generated for permitted and specified edges, whether inherited or not)
 
(12 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 {{PAGENAME}}::+]]
+
</noinclude>{{#ask: [[permitted edge to {{PAGENAME}}::+]]
| ?edge to {{PAGENAME}}
+
| ?permitted edge to {{PAGENAME}}
 
| format=array
 
| format=array
 
| headers=hide
 
| headers=hide
| propsep=$SEP$
+
| name=permittedInEdges
| name=inEdges
+
}}{{#ask: [[specified edge to {{PAGENAME}}::+]]
 +
| ?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><!--
 
}}<noinclude><!--
  
Above, we've stored all the in edges in an array named "inEdges".
+
Above, we've stored all the in edges in an arrays named "permittedInEdges", "specifiedInEdges", "permittedOutEdges", and "specifiedOutEdges".
  
Each entry in the array is in this format:
+
Each entry in each 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}} {{!}}{{!}} {{ReconstructLinks|{{#explode:var|$SEP$|3}}}} }}
+
{{!}}}
+
}}<noinclude><!--
+
 
+
Now we need to find, then print inherited edges, starting with one step up the inheritance hierarchy:
+
 
+
--></noinclude>{| class="xcsgtable"
+
|-
+
! Inherited From!! In Edge  !! Predecessor (Comes From) !! Multiplicity !! Description
+
{{InheritEdgesTo|{{#show:{{PAGENAME}}|?extends}}}}
+
{{InheritEdgesTo|{{#show:{{ParentOf|{{PAGENAME}}}}|?extends}}}}
+
|}<noinclude><!--
+
 
+
Next we get the out edges:
+
 
+
--></noinclude>{{#ask: [[edge from {{PAGENAME}}::+]]
+
| ?edge from {{PAGENAME}}
+
| 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.
+
[name of edge]<PROP>[name of predecessor]$SEP$[multiplicity]$SEP$[edge description]
  
--></noinclude>{{#switch:{{#arraysize:inEdges}}| 0 = | #default = {{#switch:{{#arraysize:outEdges}}| 0 = |
+
...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:
  
}} }}<noinclude><!--
+
[name of edge]<PROP>[name of predecessor]$SEP$[multiplicity]$SEP$[edge description]<MANY>[name of other predecessor]$SEP$[multiplicity]
  
Finally, we print the out edges table:
+
...now we want similar information about inherited in edges:
  
--></noinclude>{{#switch:{{#arraysize:outEdges}}| 0 = | #default =
+
--></noinclude>{{#arraydefine:parentsArray|{{{parents|}}}|,|}}<noinclude><!--
{{{!}} class="xcsgtable"
+
! Out Edge !! Successor (Points To) !! Multiplicity !! Description
+
We gather the information on inherited edges as well, then defer to a helper template to print the actual tables
{{!}}-
+
{{!}}{{#arrayprint:outEdges|{{!}}-
+
--></noinclude>{{ListEdges.generateTable
{{!}}|var|[[{{#explode:var|$SEP$|0}}]] {{!}}{{!}} [[{{#explode:var|$SEP$|1}}]] {{!}}{{!}} {{#explode:var|$SEP$|2}} {{!}}{{!}} {{ReconstructLinks|{{#explode:var|$SEP$|3}}}} }}
+
| 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 = {{#arrayprint:parentsArray|<PARENT_SEP>|@@@@|{{#if:{{EdgesTo|@@@@|specified}}|@@@@<PARENT>{{EdgesTo|@@@@|specified}} }} }}
 +
}}{{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 = {{#arrayprint:parentsArray|<PARENT_SEP>|@@@@|{{#if:{{EdgesFrom|@@@@|specified}}|@@@@<PARENT>{{EdgesFrom|@@@@|specified}} }} }}
 +
}}{{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 = {{#arrayprint:parentsArray|<PARENT_SEP>|@@@@|{{#if:{{EdgesTo|@@@@|permitted}}|@@@@<PARENT>{{EdgesTo|@@@@|permitted}} }} }}
 +
}}{{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 = {{#arrayprint:parentsArray|<PARENT_SEP>|@@@@|{{#if:{{EdgesFrom|@@@@|permitted}}|@@@@<PARENT>{{EdgesFrom|@@@@|permitted}} }} }}
 
}}
 
}}

Latest revision as of 12:12, 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.