Difference between revisions of "Template:Edge"

From AtlasWiki
Jump to: navigation, search
(Added properties to allow auto-discovery of edges by node kind pages.)
 
(29 intermediate revisions by 2 users not shown)
Line 8: Line 8:
  
 
<nowiki>{{</nowiki>Edge
 
<nowiki>{{</nowiki>Edge
 +
| extends = Another Type of Edge, Yet Another Type of Edge
 
| description = Connects a Foo to a Bar or a Baz
 
| description = Connects a Foo to a Bar or a Baz
| connects = Foo,Bar,1,*;Foo,Baz,0..1,*
+
| references = ...
<nowiki>}}</nowiki>
+
| permitted = F,B,*,*
 +
| specified = Foo,Bar,1,*;Foo,Baz,0..1,*
 +
<nowiki>}}</nowiki>  
  
The visible output of this will be a metaclass table describing the edge, plus a table summarizing the connections:
+
As with the Metaclass template, the extends and references parameters are optional.
 +
 
 +
The visible output of this will be a metaclass table describing the edge, plus two tables summarizing the generally possible and explicitly specified connections:
  
 
{{Metaclass
 
{{Metaclass
 +
| extends = Another Type of Edge, Yet Another Type of Edge
 
| description = Connects a Foo to a Bar or a Baz  
 
| description = Connects a Foo to a Bar or a Baz  
 +
| references = ...
 
}}
 
}}
  
 
{| class="xcsgtable"
 
{| class="xcsgtable"
 +
! colspan="3" | Permitted Connections
 +
|-
 +
! Predecessor !! Multiplicity !! Successor
 +
|-
 +
|[[F]] || &#10033; &#10142; &#10033; || [[B]]
 +
|}
 +
 +
{| class="xcsgtable"
 +
! colspan="3" | Specified Connections
 +
|-
 
! Predecessor !! Multiplicity !! Successor
 
! Predecessor !! Multiplicity !! Successor
 
|-  
 
|-  
Line 28: Line 45:
 
In addition, the following properties will be created:
 
In addition, the following properties will be created:
  
edge from [predecessor]::[successor],[multiplicity],[description of this edge]
+
edge from [predecessor]::[successor]$SEP$[multiplicity]$SEP$[description of this edge]
  
edge to [successor]::[predecessor],[multiplicity],[description of this edge]
+
edge to [successor]::[predecessor]$SEP$[multiplicity]$SEP$[description of this edge]
  
 +
Note that $SEP$ is literal; when retrieving these properties, they can be split into the three separate values using $SEP$ as the separator argument of #explode, #arraymap, or #arraydefine.
  
 
For the above example, the properies will be:
 
For the above example, the properies will be:
  
edge from Foo::Bar,*,Connects a Foo to a Bar or a Baz
+
edge from Foo::Bar$SEP$*$SEP$Connects a Foo to a Bar or a Baz
  
edge to Bar::Foo,1,Connects a Foo to a Bar or a Baz
+
edge to Bar::Foo$SEP$1$SEP$Connects a Foo to a Bar or a Baz
  
edge from Foo::Baz,*,Connects a Foo to a Bar or a Baz
+
edge from Foo::Baz$SEP$*$SEP$Connects a Foo to a Bar or a Baz
  
edge to Baz::Foo,0..1,Connects a Foo to a Bar or a Baz
+
edge to Baz::Foo$SEP$0..1$SEP$Connects a Foo to a Bar or a Baz
  
 
</noinclude><noinclude><!--
 
</noinclude><noinclude><!--
Line 47: Line 65:
 
First, generate the necessary table:
 
First, generate the necessary table:
  
Notes: the hairiest thing going on here is replacing asterisks with heavy asterisks, which we do for two reasons: they're centered better (meaning we don't get the awkward look of *->*, with the stars too high), and they
+
Notes: the hardest piece of this is that the Metaclass template is very sensitive to its variables being defined; the fix used here is supplying a different named variable if the variable we're interested in is undefined; i.e. we pass our "extends" variable to "extends" if it's present, but if it's not present, we pass it to a variable "extendsNULL" instead, so that the variable "extends" is never defined.
  
 
--></noinclude>{{Metaclass
 
--></noinclude>{{Metaclass
 +
| extends{{#if:{{{extends|}}}||NULL}}={{{extends}}}
 
| description = {{{description}}}
 
| description = {{{description}}}
}}
+
| references{{#if:{{{references|}}}||NULL}}={{{references}}}
 +
}} {{#if:{{{permitted|}}}|
  
{| class="xcsgtable"
+
{{{!}} class="xcsgtable"
 +
! colspan="3" {{!}} Permitted Connections
 +
{{!}}-
 
! Predecessor !! Multiplicity !! Successor
 
! Predecessor !! Multiplicity !! Successor
|-  
+
{{!}}-  
|{{#arraymap:{{{connects|Node Kind,Node Kind,1,*;Node Kind,Node Kind,*,1}}}| ; | PredSuccMult | [[{{#explode:PredSuccMult|,|0}}]] {{!}}{{!}} {{ReplaceAsterisks|{{#explode:PredSuccMult|,|2}}}} &#10142; {{ReplaceAsterisks|{{#explode:PredSuccMult|,|3}}}} {{!}}{{!}} [[{{#explode:PredSuccMult|,|1}}]] | \n{{!}}-\n{{!}}}}
+
{{!}}{{#arraymap:{{{permitted|}}}| ; | PredSuccMult | [[ComesFrom::{{EnsureNamespace|{{#explode:PredSuccMult|,|0}}}}{{!}} ]]{{NameTrick|{{EnsureNamespace|{{#explode:PredSuccMult|,|0}}}}}} {{!}}{{!}} {{ReplaceAsterisks|{{#explode:PredSuccMult|,|2}}}} &#10142; {{ReplaceAsterisks|{{#explode:PredSuccMult|,|3}}}} {{!}}{{!}} [[GoesTo::{{EnsureNamespace|{{#explode:PredSuccMult|,|0}}}}{{!}} ]]{{NameTrick|{{EnsureNamespace|{{#explode:PredSuccMult|,|1}}}}}} | \n{{!}}-\n{{!}}}}
|}<noinclude><!--
+
{{!}}} }} {{#if:{{{specified|{{{connects|}}}}}}|{{{!}} class="xcsgtable"
 +
! colspan="3" {{!}} Specified Connections
 +
{{!}}-
 +
! Predecessor !! Multiplicity !! Successor
 +
{{!}}-
 +
{{!}}{{#arraymap:{{{specified|{{{connects|}}}}}}| ; | PredSuccMult | [[ComesFrom::{{EnsureNamespace|{{#explode:PredSuccMult|,|0}}}}{{!}} ]]{{NameTrick|{{EnsureNamespace|{{#explode:PredSuccMult|,|0}}}}}} {{!}}{{!}} {{ReplaceAsterisks|{{#explode:PredSuccMult|,|2}}}} &#10142; {{ReplaceAsterisks|{{#explode:PredSuccMult|,|3}}}} {{!}}{{!}} [[GoesTo::{{EnsureNamespace|{{#explode:PredSuccMult|,|0}}}}{{!}} ]]{{NameTrick|{{EnsureNamespace|{{#explode:PredSuccMult|,|1}}}}}} | \n{{!}}-\n{{!}}}}
 +
{{!}}} }}<includeonly>[[Category:XCSG Edge Kinds]][[Category:XCSG Tags]]</includeonly><noinclude><!--
  
  
Line 65: Line 93:
 
Knowing only the origin node, we want to be able to discover this edge, the destination node, the multiplicity from the origin node, and the short description of this edge.
 
Knowing only the origin node, we want to be able to discover this edge, the destination node, the multiplicity from the origin node, and the short description of this edge.
  
--></noinclude>{{#arraymap:{{{connects|}}}| ; | PredSuccMult | [[edge from {{#explode:PredSuccMult|,|0}}::{{#explode:PredSuccMult|,|1}},{{#explode:PredSuccMult|,|3}},{{{description|}}}| ]] | }}<noinclude><!--
+
--></noinclude>{{#arraymap:{{{permitted|}}}| ; | PredSuccMult | {{#set:permitted edge from {{#explode:PredSuccMult|,|0}} = {{#explode:PredSuccMult|,|1}}$SEP${{ReplaceAsterisks|{{#explode:PredSuccMult|,|3}}}}$SEP${{{description|}}} }} }}<noinclude>
 
+
</noinclude>{{#arraymap:{{{specified|{{{connects|}}}}}}| ; | PredSuccMult | {{#set:specified edge from {{#explode:PredSuccMult|,|0}} = {{#explode:PredSuccMult|,|1}}$SEP${{ReplaceAsterisks|{{#explode:PredSuccMult|,|3}}}}$SEP${{{description|}}} }} }}<noinclude><!--
  
  
 
Knowing only the destination node, we want to be able to discover this edge, the predecessor node, the multiplicity of incoming edges of this type, and the short description of this edge.
 
Knowing only the destination node, we want to be able to discover this edge, the predecessor node, the multiplicity of incoming edges of this type, and the short description of this edge.
  
--></noinclude>{{#arraymap:{{{connects|}}}| ; | PredSuccMult | [[edge to {{#explode:PredSuccMult|,|1}}::{{#explode:PredSuccMult|,|0}},{{#explode:PredSuccMult|,|2}},{{{description|}}}| ]] | }}
+
--></noinclude>{{#arraymap:{{{permitted|}}}| ; | PredSuccMult | {{#set:permitted edge to {{#explode:PredSuccMult|,|1}} = {{#explode:PredSuccMult|,|0}}$SEP${{ReplaceAsterisks|{{#explode:PredSuccMult|,|2}}}}$SEP${{{description|}}} }} }}<noinclude>
 +
</noinclude>{{#arraymap:{{{specified|{{{connects|}}}}}}| ; | PredSuccMult | {{#set:specified edge to {{#explode:PredSuccMult|,|1}} = {{#explode:PredSuccMult|,|0}}$SEP${{ReplaceAsterisks|{{#explode:PredSuccMult|,|2}}}}$SEP${{{description|}}} }} }}<noinclude>[[Category:XCSG Templates]]</noinclude>

Latest revision as of 11:09, 24 November 2015


This template, for use on edge kind pages, takes in a short description of this edge, and a list of the kinds of connections this edge can form (the predecessor node kind, successor node kind, and multiplicities at each end), and stores that information in properties so it can be retrieved by knowing either the edge kind, the predecessor kind, or the successor kind, using a single query.

It also produces a table summarizing this information.

For example, this is the template call that would be used on a page "Edge" to indicate that "Edge" is an edge kind, that connects either a "Foo" node kind to a "Bar" node kind, or to a "Baz" node kind, with each "Bar" node being associated with exactly one "Foo" node, and each "Baz" node optionally being associated with exactly one "Foo" node:

{{Edge | extends = Another Type of Edge, Yet Another Type of Edge | description = Connects a Foo to a Bar or a Baz | references = ... | permitted = F,B,*,* | specified = Foo,Bar,1,*;Foo,Baz,0..1,* }}

As with the Metaclass template, the extends and references parameters are optional.

The visible output of this will be a metaclass table describing the edge, plus two tables summarizing the generally possible and explicitly specified connections:

Metaclass Edge
Extends Another Type of EdgeYet Another Type of Edge
Description Connects a Foo to a Bar or a Baz
References ...
Permitted Connections
Predecessor Multiplicity Successor
F ✱ ➞ ✱ B
Specified Connections
Predecessor Multiplicity Successor
Foo 1 ➞ ✱ Bar
Foo 0..1 ➞ ✱ Baz

In addition, the following properties will be created:

edge from [predecessor]::[successor]$SEP$[multiplicity]$SEP$[description of this edge]

edge to [successor]::[predecessor]$SEP$[multiplicity]$SEP$[description of this edge]

Note that $SEP$ is literal; when retrieving these properties, they can be split into the three separate values using $SEP$ as the separator argument of #explode, #arraymap, or #arraydefine.

For the above example, the properies will be:

edge from Foo::Bar$SEP$*$SEP$Connects a Foo to a Bar or a Baz

edge to Bar::Foo$SEP$1$SEP$Connects a Foo to a Bar or a Baz

edge from Foo::Baz$SEP$*$SEP$Connects a Foo to a Bar or a Baz

edge to Baz::Foo$SEP$0..1$SEP$Connects a Foo to a Bar or a Baz


Metaclass Edge
Description {{{description}}}