Module:Sharpness documentation: Difference between revisions

Dave Keenan (talk | contribs)
Change the if-then-else nesting so that the See Also section works for sharpness zero.
Dave Keenan (talk | contribs)
Further modifications to make sharpness-0 documentation behave more like others.
Line 48: Line 48:


result = result .. "."
result = result .. "."
end


if notation == "" then
if notation == "" then
result = result .. " This symbol set "
result = result .. " This symbol set "


if math.abs(s) == 1 then
if math.abs(s) == 1 then
result = result .. "is identical to standard notation."
result = result .. "is identical to standard notation."
else
else
if extension == "" then
if extension == "" then
if math.abs(s) == 2 then
if math.abs(s) == 2 then
-- If a sharp raises by two steps
-- If a sharp raises by two steps
result = result
.. "comprises sharps, flats, and Stein–Zimmermann [[24edo #Notation|quartertone]] accidentals."
else
if s == 0 then
result = result
result = result
.. "comprises sharps, flats, and Stein–Zimmermann [[24edo #Notation|quartertone]] accidentals."
.. "is based on [[ups and downs notation]] and comprises naturals "
.. "with arrows from [[Helmholtz–Ellis notation]]."
else
else
-- Otherwise (if a sharp raises by three or more steps)
-- Otherwise (if a sharp raises by three or more steps)
Line 67: Line 73:
.. "with arrows from [[Helmholtz–Ellis notation]]."
.. "with arrows from [[Helmholtz–Ellis notation]]."
end
end
elseif extension == "a" or extension == "A" then
-- Extension for modern-style ups and downs
result = result .. "is based on [[ups and downs notation]] using separate up and down chevrons."
end
end
elseif extension == "a" or extension == "A" then
-- Extension for modern-style ups and downs
result = result .. "is based on [[ups and downs notation]] using separate up and down chevrons."
end
end
else
result = result .. string.format(" It is based on %s.", notation)
end
end
else
result = result .. string.format(" It is based on %s.", notation)
end


-- display custom notes
-- display custom notes
if note or aux_note then
if note or aux_note then
result = result .. " " .. note ..(aux_note ~= "" and "\n\n" .. aux_note or "")
result = result .. " " .. note ..(aux_note ~= "" and "\n\n" .. aux_note or "")
end
end


-- Display the note about supersets of 12edo for sharpness-1 and above and set the edo number for supersets of 12edo
-- Display the note about supersets of 12edo for sharpness-1 and above and set the edo number for supersets of 12edo
if s >= 1 then
if s >= 1 then
local n_edo = s * 12
local n_edo = s * 12


result = result
result = result
.. "\n\n<h3>Parameters</h3>\n"
.. "\n\n<h3>Parameters</h3>\n"
.. string.format("Passing in <code>%d</code> as a single unnamed parameter will change "
.. string.format("Passing in <code>%d</code> as a single unnamed parameter will change "
.. "'''Step offset''' to '''Semitones''' in the case of [[%dedo]]", n_edo, n_edo)
.. "'''Step offset''' to '''Semitones''' in the case of [[%dedo]]", n_edo, n_edo)
if s >= 2 then
if s >= 2 then
result = result .. string.format(", since %dedo is a superset of [[12edo]]", n_edo)
result = result .. string.format(", since %dedo is a superset of [[12edo]]", n_edo)
end
result = result .. "."
end
end
result = result .. "."
end
end
-- Display a "see also" section for sharpness-2 and above, and sharpness-0
-- Display a "see also" section for sharpness-2 and above, and sharpness-0
if s >= 2 or s <= -2 or s == 0 then
if s >= 2 or s <= -2 or s == 0 then