Module:Ref: Difference between revisions

From Halopedia, the Halo wiki

No edit summary
No edit summary
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
local utils = require( 'Module:Utils' )
local utils = require( 'Module:Utils' )
local arguments = require( 'Module:Arguments' )


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 5: Line 6:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


--[[[
Constructs a reference with the given text, using the provided parser frame, ref
id and group.
@param frame - object - The current parser frame
@param id - string - The id to give to the reference
@param group - string - The group to include the reference in
@param text - string - The text of the reference
@return wikitext - the constructed reference
]]
function makeRef( frame, id, group, text )
function makeRef( frame, id, group, text )
if text == nil or text == '' then
if utils.empty( text ) then
return utils.error(
return utils.error(
'No reference text was specified!',
'No reference text was specified!',
Line 14: Line 26:
text = tostring( text )
text = tostring( text )
local args = {}
local args = {}
if id ~= nil and id ~= '' then
if not utils.empty( id ) then
args.name = tostring( id )
args.name = tostring( id )
end
end
if group ~= nil and group ~= '' then
if not utils.empty( group ) then
args.group = tostring( group )
args.group = tostring( group )
end
end
Line 24: Line 36:
end
end


function makeGenericRef( frame, id, group )
--[[[
return 'TODO: Implement this'
Constructs a standard format reference using the given parameters, with the
provided content. Content table supports unlimited numeric arguments, in
addition to Subheading, Detail, Quote, Quotee and Suffix arguments.
 
@param frame - object - The current parser frame
@param id - string - The id to give to the reference
@param group - string - The group to include the reference in
@param content - table - The content of the reference
 
@return wikitext - the constructed reference
]]
function makeStandardRef( frame, id, group, content )
local text = makeRefText( content )
return makeRef( frame, id, group, text )
end
end


--[[[
Generates the text content of a standard format reference from the provided
arguments. Content table supports unlimited numeric arguments, in
addition to subheading, detail, quote, quotee and suffix arguments.
@param content - table - The content of the reference
@return wikitext - the constructed reference text
]]
function makeRefText( content )
local text = "''" .. tostring( content[ 1 ] or '' ) .. "''"
if not utils.empty( content.subheading ) then
text = text .. ': ' .. tostring( content.subheading )
end
content[ 1 ] = ''
for i, v in ipairs( content or {} ) do
if not utils.empty( v ) then
text = text .. ', ' .. tostring( v )
end
end
if not utils.empty( content.detail ) or not utils.empty( content.quote ) then
text = text .. ':'
if not utils.empty( content.detail ) then
text = text .. ' ' .. tostring( content.detail )
end
if not utils.empty( content.quote ) then
text = text .. " ''\"" .. tostring( content.quote ) .. "\"''"
if not utils.empty( content.quotee ) then
text = text .. ' - '
text = text .. uniqueLinkIfExists( content.quotee, content.quoteetext, 'ref' )
end
end
end
if not utils.empty( content.suffix ) then
text = text .. ' <small>' .. tostring( content.suffix ) .. '</small>'
end
return text
end
--[[[
Constructs wikitext to reuse an existing reference with the given id, in the
given group.
@param frame - object - The current parser frame
@param id - string - The id to give to the reference
@param group - string - The group to include the reference in
@return wikitext - the constructed reference reuse wikitext
]]
function makeReuse( frame, id, group )
function makeReuse( frame, id, group )
local args = {}
local args = {}
Line 44: Line 118:
end
end


--[[[
Constructs the list of references in a given group.
@param frame - object - The current parser frame
@param group - string - The reference group to list
@param colNum - int - The number of columns to use in the list
@param colWidth - int - The width list columns should be
@param colGap - int - The size of the gap between list columns
@return wikitext - the constructed reference
]]
function makeList( frame, group, colNum, colWidth, colGap )
function makeList( frame, group, colNum, colWidth, colGap )
local warnings = ''
local args = {}
if not utils.empty( group ) then
args.group = tostring( group )
end
return frame:extensionTag( 'references', '', args )
end
 
function uniqueLink( page, text, category )
local frame = mw.getCurrentFrame()
local listArgs = {}
if utils.empty( text ) then
if group ~= nil and group ~= '' then
text = page
listArgs.group = tostring( group )
end
end
local divArgs = {}
return frame:callParserFunction( '#uniquelink', page, text, category )
if colNum ~= nil and colNum ~= '' then
end
if tonumber( colNum ) == nil then
 
warnings = warnings .. utils.warning(
function uniqueLinkIfExists( page, text, category )
'Column amount must be a number! Instead, it was: "' .. colNum .. '"!',
local frame = mw.getCurrentFrame()
'ref list',
'Pages containing invalid template parameter warnings' )
if utils.empty( text ) then
else
text = page
colNum = tostring( tonumber( colNum ) )
divArgs[ '-moz-column-count' ] = colNum
divArgs[ '-moz-webkit-count' ] = colNum
divArgs[ 'column-count' ] = colNum
end
end
if colWidth ~= nil and colWidth ~= '' then
colWidth = tostring( colWidth )
if string.find( colWidth, '[:;"\']') then
warnings = warnings .. utils.warning(
'Column width cannot contain any of the following characters: \' " ; :',
'ref list',
'Pages containing invalid template parameter warnings' )
else
divArgs[ '-moz-column-width' ] = colWidth
divArgs[ '-webkit-column-width' ] = colWidth
divArgs[ 'column-width' ] = colWidth
end
end
if colGap ~= nil and colGap ~= '' then
colGap = tostring( colGap )
if string.find( colGap, '[:;"\']') then
warnings = warnings .. utils.warning(
'Column gap cannot contain any of the following characters: \' " ; :',
'ref list',
'Pages containing invalid template parameter warnings' )
else
divArgs[ '-moz-column-gap' ] = colGap
divArgs[ '-webkit-column-gap' ] = colGap
divArgs[ 'column-gap' ] = colGap
end
end
end
local wikitext = frame:extensionTag( 'references', '', listArgs )
return frame:callParserFunction( '#uniquelinkifexists', page, text, category )
local html = mw.html.create( 'div' )
end
--:attr( divArgs )
 
:wikitext( wikitext )
function acronym( category, acronym, target, default )
:allDone()
local frame = mw.getCurrentFrame()
local debug_str = ''
for k, v in pairs( divArgs ) do
if utils.empty( default ) then
debug_str = debug_str ..'\n\n' .. k .. '=>' .. v .. ','
default = acronym
end
for i, v in ipairs( divArgs ) do
debug_str = debug_str ..'\n\n' .. tostring( i ) .. '=>' .. v .. ','
end
end
return debug_str .. tostring( html ) .. warnings
return frame:callParserFunction( '#acronym', category, acronym, target, default )
end
end


Line 117: Line 174:
local ref = {}
local ref = {}


--[[[
Invocation entry point for Template:Ref. Takes arguments Id, Name, Group and
Text from the template parser frame and constructs the appropriate reference.
@param frame - object - The current parser frame
@return wikitext - the constructed reference
]]
function ref.ref( frame )
function ref.ref( frame )
local templateFrame = frame:getParent()
local templateFrame = frame:getParent()
Line 125: Line 190:
end
end


--[[[
Invocation entry point for Template:Ref/List. Takes argument Group from the
template parser frame and constructs the appropriate reference list.
@param frame - object - The current parser frame
@return wikitext - the constructed reference list
]]
function ref.list( frame )
function ref.list( frame )
local templateFrame = frame:getParent()
local templateFrame = frame:getParent()
local group = templateFrame.args['Group']
local group = templateFrame.args['Group']
local colNum = templateFrame.args['Columns']
local colWidth = templateFrame.args['ColWidth']
local colGap = templateFrame.args['ColGap']
return makeList( frame, group, colNum, colWidth, colGap )
return makeList( frame, group, colNum, colWidth, colGap )
end
end


--[[[
Invocation entry point for Template:Ref/Generic.
@param frame - object - The current parser frame
@return wikitext - the constructed reference
]]
function ref.generic( frame )
function ref.generic( frame )
return 'TODO: Implement this'
local args, out = arguments.preprocess( frame, {
[ 'required' ] = { 'heading' },
[ 'recommended' ] = { 2 },
[ 'valid' ] = { 'id', 'subheading', 3, 4, 5, 6, 7, 'detail', 'quote',
'quotee', 'quoteelinktext', 'suffix' },
[ 'aliases' ] = { [ 1 ] = 'heading' }
} )
local content = {
args.heading, args[2], args[3], args[4], args[5], args[6], args[7],
[ 'subheading' ] = args.subheading,
[ 'detail' ] = args.detail,
[ 'quote' ] = args.quote,
[ 'quotee' ] = args.quotee,
[ 'suffix' ] = args.suffix
}
return out .. makeStandardRef( frame, args.id, nil, content)
end
 
--[[[
Invocation entry point for Template:Ref/Game.
 
@param frame - object - The current parser frame
 
@return wikitext - the constructed reference
]]
function ref.game( frame )
local args, out = arguments.preprocess( frame, {
[ 'required' ] = { 'game' },
[ 'recommended' ] = { 'what' },
[ 'valid' ] = { 'whattext', 'id', 'part', 'parttext', 'detail', 'quote',
'quotee', 'quoteetext', 'suffix' },
[ 'deprecated' ] = { 'gamelinktext', 'whatlinktext', 'partlinktext',
'quoteelinktext' },
[ 'aliases' ] = { [ 1 ] = 'game', [ 'gamelink' ] = 'game',
[ 2 ] = 'what', [ 'whatlink' ] = 'what', [ 3 ] = 'whattext',
[ 'whatlinktext' ] = 'whattext', [ 'partlink' ] = 'part',
[ 'expansion' ] = 'part',
[ 'dlc' ] = 'part', [ 'edition' ] = 'part', [ 'partlink' ] = 'part',
[ 'expansionlink' ] = 'part', [ 'dlclink' ] = 'part',
[ 'editionlink' ] = 'part',
[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
[ 'quoteelinktext' ] = 'quoteetext' }
} )
 
local game = uniqueLinkIfExists(
acronym( 'game', args.game, 'page', args.game ),
args.gameLinkText or acronym( 'game', args.game, 'title', args.game ),
'ref'
)
local part
if not utils.empty( args.part ) then
part = uniqueLinkIfExists(
args.part,
args.parttext or args.part,
'ref'
)
end
local what
if not utils.empty( args.what ) then
what = uniqueLinkIfExists(
args.what,
args.whattext or args.what,
'ref'
)
end
local content = {
game, what,
[ 'subheading' ] = part or args.part,
[ 'detail' ] = args.detail,
[ 'quote' ] = args.quote,
[ 'quotee' ] = args.quotee,
[ 'quoteetext' ] = args.quoteetext or args.quotee,
[ 'suffix' ] = args.suffix
}
return out .. makeStandardRef( frame, args.id, nil, content)
end
 
--[[[
Invocation entry point for Template:Ref/File.
 
@param frame - object - The current parser frame
 
@return wikitext - the constructed reference
]]
function ref.file( frame )
local args, out = arguments.preprocess( frame, {
[ 'required' ] = { 'game', 'file' },
[ 'valid' ] = { 'gametext', 'excerpt', 'id', 'part', 'parttext',
'detail', 'quote', 'quotee', 'quoteetext', 'suffix' },
[ 'deprecated' ] = { 'gamelinktext' },
[ 'aliases' ] = { [ 1 ] = 'game', [ 'gamelink' ] = 'game',
[ 2 ] = 'file', [ 3 ] = 'excerpt',
[ 'gamelinktext' ] = 'gametext', [ 'partlink' ] = 'part',
[ 'expansion' ] = 'part',
[ 'dlc' ] = 'part', [ 'edition' ] = 'part', [ 'partlink' ] = 'part',
[ 'expansionlink' ] = 'part', [ 'dlclink' ] = 'part',
[ 'editionlink' ] = 'part',
[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
[ 'quoteelinktext' ] = 'quoteetext' }
} )
 
local game = uniqueLinkIfExists(
acronym( 'game', args.game, 'page', args.game ),
args.gameLinkText or acronym( 'game', args.game, 'title', args.game ),
'ref'
)
local part
if not utils.empty( args.part ) then
part = uniqueLinkIfExists(
args.part,
args.parttext or args.part,
'ref'
)
end
local file = args.file or 'unspecified file'
file = 'game file <code>' .. file .. '</code>'
local excerpt = args.excerpt
if not utils.empty( excerpt ) then
excerpt = 'excerpt <code>' .. excerpt .. '</code>'
end
local content = {
game, file, excerpt,
[ 'subheading' ] = part or args.part,
[ 'detail' ] = args.detail,
[ 'quote' ] = args.quote,
[ 'quotee' ] = args.quotee,
[ 'quoteetext' ] = args.quoteetext or args.quotee,
[ 'suffix' ] = args.suffix
}
return out .. makeStandardRef( frame, args.id, nil, content)
end
end


return ref
return ref

Latest revision as of 13:06, September 24, 2022

vde
Lua Module Documentation

This module provides the backend implementations of the Ref templates.

Public Functions

ref.ref

Invocation entry point for Template:Ref. Takes arguments Id, Name, Group and Text from the template parser frame and constructs the appropriate reference.

Parameters:

  • frame (object) - The current parser frame

Returns:

wikitext - the constructed reference

ref.list

Invocation entry point for Template:Ref/List. Takes argument Group from the template parser frame and constructs the appropriate reference list.

Parameters:

  • frame (object) - The current parser frame

Returns:

wikitext - the constructed reference list

ref.generic

Invocation entry point for Template:Ref/Generic.

Parameters:

  • frame (object) - The current parser frame

Returns:

wikitext - the constructed reference

ref.game

Invocation entry point for Template:Ref/Game.

Parameters:

  • frame (object) - The current parser frame

Returns:

wikitext - the constructed reference

ref.file

Invocation entry point for Template:Ref/File.

Parameters:

  • frame (object) - The current parser frame

Returns:

wikitext - the constructed reference


Private Functions

makeRef

Constructs a reference with the given text, using the provided parser frame, ref id and group.

Parameters:

  • frame (object) - The current parser frame
  • id (string) - The id to give to the reference
  • group (string) - The group to include the reference in
  • text (string) - The text of the reference

Returns:

wikitext - the constructed reference

makeStandardRef

Constructs a standard format reference using the given parameters, with the provided content. Content table supports unlimited numeric arguments, in addition to Subheading, Detail, Quote, Quotee and Suffix arguments.

Parameters:

  • frame (object) - The current parser frame
  • id (string) - The id to give to the reference
  • group (string) - The group to include the reference in
  • content (table) - The content of the reference

Returns:

wikitext - the constructed reference

makeRefText

Generates the text content of a standard format reference from the provided arguments. Content table supports unlimited numeric arguments, in addition to subheading, detail, quote, quotee and suffix arguments.

Parameters:

  • content (table) - The content of the reference

Returns:

wikitext - the constructed reference text

makeReuse

Constructs wikitext to reuse an existing reference with the given id, in the given group.

Parameters:

  • frame (object) - The current parser frame
  • id (string) - The id to give to the reference
  • group (string) - The group to include the reference in

Returns:

wikitext - the constructed reference reuse wikitext

makeList

Constructs the list of references in a given group.

Parameters:

  • frame (object) - The current parser frame
  • group (string) - The reference group to list
  • colNum (int) - The number of columns to use in the list
  • colWidth (int) - The width list columns should be
  • colGap (int) - The size of the gap between list columns

Returns:

wikitext - the constructed reference

uniqueLink

uniqueLinkIfExists

acronym

Code

A copy of the code for this module follows:


local utils = require( 'Module:Utils' )
local arguments = require( 'Module:Arguments' )

--------------------------------------------------------------------------------
------------------------------- PRIVATE FUNCTIONS ------------------------------
--------------------------------------------------------------------------------

--[[[
Constructs a reference with the given text, using the provided parser frame, ref
id and group.

@param frame - object - The current parser frame
@param id - string - The id to give to the reference
@param group - string - The group to include the reference in
@param text - string - The text of the reference

@return wikitext - the constructed reference
]]
function makeRef( frame, id, group, text )
	if utils.empty( text ) then
		return utils.error(
			'No reference text was specified!',
			'ref',
			'Pages with empty citations' )
	end
	text = tostring( text )
	local args = {}
	if not utils.empty( id ) then
		args.name = tostring( id )
	end
	if not utils.empty( group ) then
		args.group = tostring( group )
	end
	
	return frame:extensionTag( 'ref', text, args )
end

--[[[
Constructs a standard format reference using the given parameters, with the
provided content. Content table supports unlimited numeric arguments, in
addition to Subheading, Detail, Quote, Quotee and Suffix arguments.

@param frame - object - The current parser frame
@param id - string - The id to give to the reference
@param group - string - The group to include the reference in
@param content - table - The content of the reference

@return wikitext - the constructed reference
]]
function makeStandardRef( frame, id, group, content )
	local text = makeRefText( content )
	return makeRef( frame, id, group, text )
end

--[[[
Generates the text content of a standard format reference from the provided
arguments. Content table supports unlimited numeric arguments, in
addition to subheading, detail, quote, quotee and suffix arguments.

@param content - table - The content of the reference

@return wikitext - the constructed reference text
]]
function makeRefText( content )
	local text = "''" .. tostring( content[ 1 ] or '' ) .. "''"
	if not utils.empty( content.subheading ) then
		text = text .. ': ' .. tostring( content.subheading )
	end
	content[ 1 ] = ''
	for i, v in ipairs( content or {} ) do
		if not utils.empty( v ) then
			text = text .. ', ' .. tostring( v )
		end
	end
	if not utils.empty( content.detail ) or not utils.empty( content.quote ) then
		text = text .. ':'
		if not utils.empty( content.detail ) then
			text = text .. ' ' .. tostring( content.detail )
		end
		if not utils.empty( content.quote ) then
			text = text .. " ''\"" .. tostring( content.quote ) .. "\"''"
			if not utils.empty( content.quotee ) then
				text = text .. ' - '
				text = text .. uniqueLinkIfExists( content.quotee, content.quoteetext, 'ref' )
			end
		end
	end
	if not utils.empty( content.suffix ) then
		text = text .. ' <small>' .. tostring( content.suffix ) .. '</small>'
	end
	return text
end

--[[[
Constructs wikitext to reuse an existing reference with the given id, in the
given group.

@param frame - object - The current parser frame
@param id - string - The id to give to the reference
@param group - string - The group to include the reference in

@return wikitext - the constructed reference reuse wikitext
]]
function makeReuse( frame, id, group )
	local args = {}
	if id == nil or id == '' then
		return utils.error(
			'No id was specified for ref reuse!',
			'ref',
			'Pages containing missing template parameter errors' )
	else
		args.name = tostring( id )
	end
	if group ~= nil and group ~= '' then
		args.group = tostring( group )
	end
	return frame:extensionTag( 'ref', '', args )
end

--[[[
Constructs the list of references in a given group.

@param frame - object - The current parser frame
@param group - string - The reference group to list
@param colNum - int - The number of columns to use in the list
@param colWidth - int - The width list columns should be
@param colGap - int - The size of the gap between list columns

@return wikitext - the constructed reference
]]
function makeList( frame, group, colNum, colWidth, colGap )
	local args = {}
	if not utils.empty( group ) then
		args.group = tostring( group )
	end
	
	return frame:extensionTag( 'references', '', args )
end

function uniqueLink( page, text, category )
	local frame = mw.getCurrentFrame()
	
	if utils.empty( text ) then
		text = page
	end
	
	return frame:callParserFunction( '#uniquelink', page, text, category )
end

function uniqueLinkIfExists( page, text, category )
	local frame = mw.getCurrentFrame()
	
	if utils.empty( text ) then
		text = page
	end
	
	return frame:callParserFunction( '#uniquelinkifexists', page, text, category )
end

function acronym( category, acronym, target, default )
	local frame = mw.getCurrentFrame()
	
	if utils.empty( default ) then
		default = acronym
	end
	
	return frame:callParserFunction( '#acronym', category, acronym, target, default )
end

--------------------------------------------------------------------------------
------------------------------- PUBLIC FUNCTIONS -------------------------------
--------------------------------------------------------------------------------

local ref = {}

--[[[
Invocation entry point for Template:Ref. Takes arguments Id, Name, Group and
Text from the template parser frame and constructs the appropriate reference.

@param frame - object - The current parser frame

@return wikitext - the constructed reference
]]
function ref.ref( frame )
	local templateFrame = frame:getParent()
	local id = templateFrame.args['Id'] or templateFrame.args['Name']
	local group = templateFrame.args['Group']
	local text = templateFrame.args[1] or templateFrame.args['Text']
	return makeRef( frame, text, id, group )
end

--[[[
Invocation entry point for Template:Ref/List. Takes argument Group from the
template parser frame and constructs the appropriate reference list.

@param frame - object - The current parser frame

@return wikitext - the constructed reference list
]]
function ref.list( frame )
	local templateFrame = frame:getParent()
	local group = templateFrame.args['Group']
	return makeList( frame, group, colNum, colWidth, colGap )
end

--[[[
Invocation entry point for Template:Ref/Generic.

@param frame - object - The current parser frame

@return wikitext - the constructed reference
]]
function ref.generic( frame )
	local args, out = arguments.preprocess( frame, {
		[ 'required' ] = { 'heading' },
		[ 'recommended' ] = { 2 },
		[ 'valid' ] = { 'id', 'subheading', 3, 4, 5, 6, 7, 'detail', 'quote',
			'quotee', 'quoteelinktext', 'suffix' },
		[ 'aliases' ] = { [ 1 ] = 'heading' }
	} )
	local content = {
		args.heading, args[2], args[3], args[4], args[5], args[6], args[7],
		[ 'subheading' ] = args.subheading,
		[ 'detail' ] = args.detail,
		[ 'quote' ] = args.quote,
		[ 'quotee' ] = args.quotee,
		[ 'suffix' ] = args.suffix
	}
	return out .. makeStandardRef( frame, args.id, nil, content)
end

--[[[
Invocation entry point for Template:Ref/Game.

@param frame - object - The current parser frame

@return wikitext - the constructed reference
]]
function ref.game( frame )
	local args, out = arguments.preprocess( frame, {
		[ 'required' ] = { 'game' },
		[ 'recommended' ] = { 'what' },
		[ 'valid' ] = { 'whattext', 'id', 'part', 'parttext', 'detail', 'quote',
			'quotee', 'quoteetext', 'suffix' },
		[ 'deprecated' ] = { 'gamelinktext', 'whatlinktext', 'partlinktext',
			'quoteelinktext' },
		[ 'aliases' ] = { [ 1 ] = 'game', [ 'gamelink' ] = 'game',
			[ 2 ] = 'what', [ 'whatlink' ] = 'what', [ 3 ] = 'whattext',
			[ 'whatlinktext' ] = 'whattext', [ 'partlink' ] = 'part',
			[ 'expansion' ] = 'part',
			[ 'dlc' ] = 'part', [ 'edition' ] = 'part', [ 'partlink' ] = 'part',
			[ 'expansionlink' ] = 'part', [ 'dlclink' ] = 'part',
			[ 'editionlink' ] = 'part',
			[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
			[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
			[ 'quoteelinktext' ] = 'quoteetext' }
	} )

	local game = uniqueLinkIfExists(
		acronym( 'game', args.game, 'page', args.game ),
		args.gameLinkText or acronym( 'game', args.game, 'title', args.game ),
		'ref'
	)
	
	local part
	if not utils.empty( args.part ) then
		part = uniqueLinkIfExists(
			args.part,
			args.parttext or args.part,
			'ref'
		)
	end
	
	local what
	if not utils.empty( args.what ) then
		what = uniqueLinkIfExists(
			args.what,
			args.whattext or args.what,
			'ref'
		)
	end
	
	local content = {
		game, what,
		[ 'subheading' ] = part or args.part,
		[ 'detail' ] = args.detail,
		[ 'quote' ] = args.quote,
		[ 'quotee' ] = args.quotee,
		[ 'quoteetext' ] = args.quoteetext or args.quotee,
		[ 'suffix' ] = args.suffix
	}
	return out .. makeStandardRef( frame, args.id, nil, content)
end

--[[[
Invocation entry point for Template:Ref/File.

@param frame - object - The current parser frame

@return wikitext - the constructed reference
]]
function ref.file( frame )
	local args, out = arguments.preprocess( frame, {
		[ 'required' ] = { 'game', 'file' },
		[ 'valid' ] = { 'gametext', 'excerpt', 'id', 'part', 'parttext',
			'detail', 'quote', 'quotee', 'quoteetext', 'suffix' },
		[ 'deprecated' ] = { 'gamelinktext' },
		[ 'aliases' ] = { [ 1 ] = 'game', [ 'gamelink' ] = 'game',
			[ 2 ] = 'file', [ 3 ] = 'excerpt',
			[ 'gamelinktext' ] = 'gametext', [ 'partlink' ] = 'part',
			[ 'expansion' ] = 'part',
			[ 'dlc' ] = 'part', [ 'edition' ] = 'part', [ 'partlink' ] = 'part',
			[ 'expansionlink' ] = 'part', [ 'dlclink' ] = 'part',
			[ 'editionlink' ] = 'part',
			[ 'partlinktext' ] = 'parttext', [ 'expansiontext' ] = 'parttext',
			[ 'dlctext' ] = 'parttext', [ 'editiontext' ] = 'parttext',
			[ 'quoteelinktext' ] = 'quoteetext' }
	} )

	local game = uniqueLinkIfExists(
		acronym( 'game', args.game, 'page', args.game ),
		args.gameLinkText or acronym( 'game', args.game, 'title', args.game ),
		'ref'
	)
	
	local part
	if not utils.empty( args.part ) then
		part = uniqueLinkIfExists(
			args.part,
			args.parttext or args.part,
			'ref'
		)
	end
	
	local file = args.file or 'unspecified file'
	file = 'game file <code>' .. file .. '</code>'
	
	local excerpt = args.excerpt
	if not utils.empty( excerpt ) then
		excerpt = 'excerpt <code>' .. excerpt .. '</code>'
	end
	
	local content = {
		game, file, excerpt,
		[ 'subheading' ] = part or args.part,
		[ 'detail' ] = args.detail,
		[ 'quote' ] = args.quote,
		[ 'quotee' ] = args.quotee,
		[ 'quoteetext' ] = args.quoteetext or args.quotee,
		[ 'suffix' ] = args.suffix
	}
	return out .. makeStandardRef( frame, args.id, nil, content)
end

return ref