GameTheory.jl icon indicating copy to clipboard operation
GameTheory.jl copied to clipboard

Doc style

Open oyamad opened this issue 7 years ago • 6 comments

See https://github.com/QuantEcon/Games.jl/pull/1#issuecomment-185396785.

oyamad avatar Mar 08 '17 04:03 oyamad

Documenter.jl is actually using what JuliaLang suggests.

To adopt this style, change

"""
Constructor of an N-player NormalFormGame, consisting of payoffs all 0.

##### Arguments

- `T::Type` : Type of payoff values; defaults to `Float64` if not specified.
- `nums_actions::NTuple{N,Int}` : Numbers of actions of the N players.

"""
function NormalFormGame{N}(T::Type, nums_actions::NTuple{N,Int})
    # TODO: can we still get inference to work but avoid the `::NTuple` below?
    players::NTuple{N,Player{N,T}} =
        ntuple(i -> Player(zeros(tuple(nums_actions[i:end]...,
                                       nums_actions[1:i-1]...))),
               N)
    return NormalFormGame{N,T}(players, nums_actions)
end

to

"""
    NormalFormGame{N}(T::Type, nums_actions::NTuple{N,Int})

Constructor of an N-player NormalFormGame, consisting of payoffs all 0.

# Arguments
* `T::Type`: Type of payoff values; defaults to `Float64` if not specified.
* `nums_actions::NTuple{N,Int}`: Numbers of actions of the N players.
"""
function NormalFormGame{N}(T::Type, nums_actions::NTuple{N,Int})
    # TODO: can we still get inference to work but avoid the `::NTuple` below?
    players::NTuple{N,Player{N,T}} =
        ntuple(i -> Player(zeros(tuple(nums_actions[i:end]...,
                                       nums_actions[1:i-1]...))),
               N)
    return NormalFormGame{N,T}(players, nums_actions)
end

shizejin avatar Mar 17 '17 10:03 shizejin

That style looks good to me.

I would vote that we add a new line between the header # Arguments and the list.

Also, I prefer - to *, but since they are equivalent in markdown I'm happy either way

sglyon avatar Mar 17 '17 11:03 sglyon

+1 for adding a new line between the header # Arguments and the list.

oyamad avatar Mar 17 '17 12:03 oyamad

I agree. We don't need to follow the Julia suggested style strictly, as it won't make difference to the output of Documenter.jl, while make the raw docstrings much nicer.

shizejin avatar Mar 17 '17 12:03 shizejin

This all looks really good. Thanks @shizejin!

cc7768 avatar Mar 17 '17 15:03 cc7768

Two modifications to the doc style (discussed with @oyamad and @QBatista):

  1. Change * to - following Julia manual.
  2. Remove the type declarations from the header.
"""
    NormalFormGame{N}(T, nums_actions)

Constructor of an N-player NormalFormGame, consisting of payoffs all 0.

# Arguments
- `T::Type`: Type of payoff values; defaults to `Float64` if not specified.
- `nums_actions::NTuple{N,Int}`: Numbers of actions of the N players.
"""
function NormalFormGame{N}(T::Type, nums_actions::NTuple{N,Int})
    # TODO: can we still get inference to work but avoid the `::NTuple` below?
    players::NTuple{N,Player{N,T}} =
        ntuple(i -> Player(zeros(tuple(nums_actions[i:end]...,
                                       nums_actions[1:i-1]...))),
               N)
    return NormalFormGame{N,T}(players, nums_actions)
end

shizejin avatar Sep 25 '17 09:09 shizejin