User:DavidJCobb/Function table syntax

From the CreationKit Wiki
Jump to navigation Jump to search

It may be possible to create a nicer look for the function tables. I've written up some sample templates, but I haven't saved them since I can't delete them if we decide not to use them.

I've based my work on the table styles created by User:Arocide. The base look is as follows:

  Function Description Syntax
Activate Have the passed in reference activate this object. Activate()
Int  CountLinkedRefChain Counts the number of linked refs that are in a linked Ref chain Int CountLinkedRefChain()

Some details:

  • All table cells except for the type column are sized in em, so they'll scale with the page's font size rather than with the size of the window/page.
  • The (unmarked) type column is right-aligned. If you have an ObjectReference function listed, the word "Int" will still be right up against the function name.
    • The column has no default size; it'll collapse to (almost) nothing if it's empty.
    • The column is also forced to contain a single space, so users should be able to copy the function definition properly ("Int CountLinkedRefChain" instead of "IntCountLinkedRefChain").
  • The syntax column is sized with a min-width, so it'll expand if needed to accommodate its contents.
  • Firefox will shrink the entire table (starting with the description column first) to fit the width of the page. I don't know if this happens gracefully (or at all) in other browsers.
  • Regarding the template syntax, the use of named parameters is deliberate. You cannot include "=" in a value unless you are specifying that value as a named parameter. You can specify unnamed parameters as named parameters (e.g. "1=This is a test with an = in it") but if we let people use unnamed syntax, they will. And then they'll wonder why their equal signs are breaking.

Usage example[edit | edit source]

Code; untested;

{{FunctionTableStart}}
{{FunctionTableRow
|odd=true
|name=Activate
|text=Have the passed in reference activate this object.
|args=(ObjectReference akActivator)
|link=Activate - ObjectReference}}

{{FunctionTableRow
|name=CountLinkedRefChain
|type=Int
|text=Counts the number of linked refs that are in a linked Ref chain 
|args=(Keyword apKeyword, Int maxExpectedLinkedRefs)
|link=CountLinkedRefChain - ObjectReference}}

{{FunctionTableEnd}}

Expected result.

  Function Description Syntax
  Activate Have the passed in reference activate this object. Activate(ObjectReference akActivator)
Int  CountLinkedRefChain Counts the number of linked refs that are in a linked Ref chain Int CountLinkedRefChain(Keyword apKeyword, Int maxExpectedLinkedRefs)


Template code[edit | edit source]

Template: FunctionTableColor

{{{2{{{odd|}}}|{{{3}}}}}}

Template: FunctionTableStart

{|cellpadding="6" cellspacing="0"
|-
|style="background:#E8E8E8;border-bottom:1px solid #000;vertical-align:top;padding-right:0"| 
|style="background:#E8E8E8;border-bottom:1px solid #000;vertical-align:top;padding-left:0;width:14em"|'''Function'''
|style="background:#E8E8E8;border-bottom:1px solid #000;vertical-align:top;width:40em"|'''Description'''
|style="background:#E8E8E8;border-bottom:1px solid #000;vertical-align:top;min-width:14em"|'''Syntax'''<noinclude>
|}

Use this to begin a function table.
</noinclude>

Template: FunctionTableRow

<noinclude>{|cellpadding="6" cellspacing="0"
</noinclude>|-
|style="background:#{{FunctionTableColor|{{{odd}}}|F7F7F7|FFFFFF}};vertical-align:top;text-align:right;padding-right:0"|'''{{{type|}}} '''
|style="background:#{{FunctionTableColor|{{{odd}}}|F7F7F7|FFFFFF}};vertical-align:top;padding-left:0"|'''[[{{{link}}}|{{{name}}}]]'''
|style="background:#{{FunctionTableColor|{{{odd}}}|F7F7F7|FFFFFF}};vertical-align:top"|{{{text}}}
|style="background:#{{FunctionTableColor|{{{odd}}}|F7F7F7|FFFFFF}};vertical-align:top"|'''{{{type|}}} {{{name}}}'''<nowiki></nowiki>''{{{args}}}''
<noinclude>|}

I'm not aware of any rule against creating templates. Apologies if this isn't permitted.

Parameters
;name
:The name of the function.
;text
:The description.
;type
:The return type for the function.
;code
:The function's name and arguments, e.g. ''MoveTo(ObjectReference kTarget, ...)''
;odd
:Set this parameter to any value to alternate the row's color.</noinclude>

Template: FunctionTableEnd

|}<noinclude>

Use this to end a function table; see FunctionTableBegin and FunctionTableRow.
</noinclude>