I manually generated the See also
section in the docstring below:
"""
update_lgTble!(lg_table, comms, idx1, idx2)
Updates the lg_table vector based on game results stored in Comms.
# Arguments
- `lg_table :: MVector{nteams::Int, TeamStats}` : The league table (Place, Team Names, Wins, etc) for this league
- `comms :: Tuple{Comms, Comms}` : Pair of Comms structs containing results of the last game
- `idx1 :: Int` : Index of league table for the home team
- `idx2 :: Int` : Index of league table for the away team
# See also
- Uses : [`Comms`](@ref)
- Used by : [`playgames!`](@ref)
- Similar : [`init_lgtble`](@ref), [`lgrank!`](@ref)
"""
function update_lgTble!(lg_table, comms, idx1, idx2)
gls = SVector{2}(sum(comms[1].Gls), sum(comms[2].Gls))
gdiff = gls[1] - gls[2]
idx = SVector(idx1, idx2)
if gdiff == 0
lg_table[idx1] = @set $(lg_table[idx1]).D += Int16(1)
lg_table[idx2] = @set $(lg_table[idx2]).D += Int16(1)
elseif gdiff > 0
lg_table[idx1] = @set $(lg_table[idx1]).W += Int16(1)
lg_table[idx2] = @set $(lg_table[idx2]).L += Int16(1)
else
lg_table[idx1] = @set $(lg_table[idx1]).L += Int16(1)
lg_table[idx2] = @set $(lg_table[idx2]).W += Int16(1)
end
lg_table[idx1] = @set $(lg_table[idx1]).GA += gls[2]
lg_table[idx2] = @set $(lg_table[idx2]).GA += gls[1]
for i in 1:2
lg_table[idx[i]] = @set $(lg_table[idx[i]]).P += Int16(1)
lg_table[idx[i]] = @set $(lg_table[idx[i]]).GF += gls[i]
lg_table[idx[i]] = @set $(lg_table[idx[i]]).GD = lg_table[idx[i]].GF - lg_table[idx[i]].GA
lg_table[idx[i]] = @set $(lg_table[idx[i]]).Pts = 3*lg_table[idx[i]].W + lg_table[idx[i]].D
end
end
Is there a way to autofill a template like that? I only want to include functions/structs directly called and found in the same /src
directory. Eg, I wouldn’t expect Comms
or the Similar
functions to show up automatically. Then find any other functions that directly call this function.
Bonus, is there a way to autofill the names + types of the Arguments
section as well?
Edit
Here is another example:
"""
TeamStats(Pl, Team, P, W, D, L, GF, GA, GD, Pts)
Immutable struct containing the league table values for a single team.
# Fields
- `Pl :: Int16 ` : Place
- `Team :: String15` : Team Name
- `P :: Int16 ` : Games Played
- `W :: Int16 ` : Wins
- `D :: Int16 ` : Draws
- `L :: Int16 ` : Losses
- `GF :: Int16 ` : Goals For
- `GA :: Int16 ` : Goals Against
- `GD :: Int16 ` : Goal Difference
- `Pts :: Int16 ` : Points (3*W + D)
# See also
- Used by : [`init_lgtble`](@ref)
"""
@with_kw struct TeamStats
Pl :: Int16 = 0
Team :: String15 = ""
P :: Int16 = 0
W :: Int16 = 0
D :: Int16 = 0
L :: Int16 = 0
GF :: Int16 = 0
GA :: Int16 = 0
GD :: Int16 = 0
Pts :: Int16 = 0
end
"""
init_lgtble(teams)
Initializes a league table based on the team names
# Arguments
- `teams :: Vector{String}` : Vector of team names
# See also
- Uses : [`TeamStats`](@ref)
- Similar : [`update_lgtble!`](@ref), [`lgrank!`](@ref)
"""
function init_lgtble(teams)
nteams = length(teams)
lg_table = MVector{nteams}((TeamStats() for i in eachindex(teams)))
for i in eachindex(lg_table)
lg_table[i] = @set $(lg_table[i]).Team = teams[i]
end
return lg_table
end
Edit 2
Fixed some copy/paste, etc typos in the docs. But that just kind of proves the point it would be nice to automate this.