Skip to content

Commit e817d20

Browse files
authored
Enable doctests and correct previously untested errors (jump-dev#1219)
* Enable doctests and correct previously untested errors * Add codecov to documentation build * Update documentation.yml
1 parent 230c9f3 commit e817d20

File tree

4 files changed

+60
-34
lines changed

4 files changed

+60
-34
lines changed

docs/make.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
using Documenter, MathOptInterface
22

3+
"""
4+
Pass `julia docs/make.jl --fix` to rebuild the doctests.
5+
"""
6+
const _FIX = findfirst(isequal("--fix"), ARGS) !== nothing
7+
38
makedocs(
49
sitename = "MathOptInterface",
510
format = Documenter.HTML(
@@ -8,8 +13,10 @@ makedocs(
813
mathengine = Documenter.MathJax2(),
914
collapselevel = 1,
1015
),
11-
# See https://github.com/jump-dev/JuMP.jl/issues/1576
1216
strict = true,
17+
modules = [MathOptInterface],
18+
checkdocs = :exports,
19+
doctest = _FIX ? :fix : true,
1320
pages = [
1421
"Introduction" => "index.md",
1522
"Manual" => [

docs/src/apireference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ UserCut
9595

9696
```@docs
9797
ModelLike
98-
isempty
98+
is_empty
9999
empty!
100100
write_to_file
101101
read_from_file

src/Bridges/Constraint/bridge.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ function MOIB.added_constraint_types(
9292
end
9393

9494
"""
95-
concrete_bridge_type(BT::Type{<:AbstractBridge},
96-
F::Type{<:MOI.AbstractFunction},
97-
S::Type{<:MOI.AbstractSet})::DataType
95+
concrete_bridge_type(
96+
BT::Type{<:AbstractBridge},
97+
F::Type{<:MOI.AbstractFunction},
98+
S::Type{<:MOI.AbstractSet}
99+
)::DataType
98100
99101
Return the concrete type of the bridge supporting `F`-in-`S` constraints. This
100102
function can only be called if `MOI.supports_constraint(BT, F, S)` is `true`.
@@ -106,16 +108,18 @@ constraint is bridged into a
106108
[`MathOptInterface.SingleVariable`](@ref)-in-[`MathOptInterface.GreaterThan`](@ref)
107109
and a
108110
[`MathOptInterface.SingleVariable`](@ref)-in-[`MathOptInterface.LessThan`](@ref)
109-
by the [`SplitIntervalBridge`](@ref),
110-
```jldoctest
111-
BT = MOI.Bridges.Constraint.SplitIntervalBridge{Float64}
112-
F = MOI.SingleVariable
113-
S = MOI.Interval{Float64}
114-
MOI.Bridges.Constraint.concrete_bridge_type(BT, F, S)
111+
by the [`SplitIntervalBridge`](@ref):
112+
113+
```jldoctest; setup=:(using MathOptInterface; const MOI = MathOptInterface)
114+
MOI.Bridges.Constraint.concrete_bridge_type(
115+
MOI.Bridges.Constraint.SplitIntervalBridge{Float64},
116+
MOI.SingleVariable,
117+
MOI.Interval{Float64},
118+
)
115119
116120
# output
117121
118-
MOI.Bridges.Constraint.SplitIntervalBridge{Float64,MOI.SingleVariable}
122+
MathOptInterface.Bridges.Constraint.SplitIntervalBridge{Float64,MathOptInterface.SingleVariable,MathOptInterface.Interval{Float64},MathOptInterface.GreaterThan{Float64},MathOptInterface.LessThan{Float64}}
119123
```
120124
"""
121125
function concrete_bridge_type(

src/Bridges/Variable/bridge.jl

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ function supports_constrained_variable(
107107
end
108108

109109
"""
110-
added_constrained_variable_types(BT::Type{<:MOI.Bridges.Variable.AbstractBridge},
111-
S::Type{<:MOI.AbstractSet})
110+
added_constrained_variable_types(
111+
BT::Type{<:MOI.Bridges.Variable.AbstractBridge},
112+
S::Type{<:MOI.AbstractSet},
113+
)
112114
113115
Return a list of the types of constrained variables that bridges of type `BT`
114116
add for bridging constrained variabled in `S`. This falls back to
@@ -120,14 +122,17 @@ so bridges should not implement this.
120122
As a variable in [`MathOptInterface.GreaterThan`](@ref) is bridged into
121123
variables in [`MathOptInterface.Nonnegatives`](@ref) by the
122124
[`VectorizeBridge`](@ref):
123-
```jldoctest
124-
BT = MOI.Bridges.Variable.VectorizeBridge{Float64}
125-
S = MOI.GreaterThan{Float64}
126-
MOI.Bridges.added_constrained_variable_types(BT, S)
125+
126+
```jldoctest; setup=:(using MathOptInterface; const MOI = MathOptInterface)
127+
MOI.Bridges.added_constrained_variable_types(
128+
MOI.Bridges.Variable.VectorizeBridge{Float64},
129+
MOI.GreaterThan{Float64},
130+
)
127131
128132
# output
129133
130-
[(MOI.Nonnegatives,)]
134+
1-element Array{Tuple{DataType},1}:
135+
(MathOptInterface.Nonnegatives,)
131136
```
132137
"""
133138
function MOIB.added_constrained_variable_types(
@@ -138,8 +143,10 @@ function MOIB.added_constrained_variable_types(
138143
end
139144

140145
"""
141-
added_constraint_types(BT::Type{<:MOI.Bridges.Variable.AbstractBridge},
142-
S::Type{<:MOI.AbstractSet})
146+
added_constraint_types(
147+
BT::Type{<:MOI.Bridges.Variable.AbstractBridge},
148+
S::Type{<:MOI.AbstractSet},
149+
)
143150
144151
Return a list of the types of constraints that bridges of type `BT` add for
145152
for bridging constrained variabled in `S`. This falls back to
@@ -154,14 +161,18 @@ In addition to creating variables in
154161
[`MathOptInterface.SingleVariable`](@ref)-in-[`MathOptInterface.EqualTo`](@ref) and
155162
[`MathOptInterface.ScalarAffineFunction`](@ref)-in-[`MathOptInterface.EqualTo`](@ref)
156163
constraints:
157-
```jldoctest
158-
BT = MOI.Bridges.Variable.RSOCtoPSDBridge{Float64}
159-
S = MOI.RotatedSecondOrderCone{
160-
MOI.Bridges.added_constraint_types(BT, S)
164+
165+
```jldoctest; setup=:(using MathOptInterface; const MOI = MathOptInterface)
166+
MOI.Bridges.added_constraint_types(
167+
MOI.Bridges.Variable.RSOCtoPSDBridge{Float64},
168+
MOI.RotatedSecondOrderCone,
169+
)
161170
162171
# output
163172
164-
[(MOI.SingleVariable, MOI.EqualTo{Float64}), (MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64})]
173+
2-element Array{Tuple{DataType,DataType},1}:
174+
(MathOptInterface.SingleVariable, MathOptInterface.EqualTo{Float64})
175+
(MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64})
165176
```
166177
"""
167178
function MOIB.added_constraint_types(
@@ -172,8 +183,10 @@ function MOIB.added_constraint_types(
172183
end
173184

174185
"""
175-
concrete_bridge_type(BT::Type{<:AbstractBridge},
176-
S::Type{<:MOI.AbstractSet})::DataType
186+
concrete_bridge_type(
187+
BT::Type{<:AbstractBridge},
188+
S::Type{<:MOI.AbstractSet},
189+
)::DataType
177190
178191
Return the concrete type of the bridge supporting variables in `S` constraints.
179192
This function can only be called if `MOI.supports_constrained_variable(BT, S)`
@@ -183,15 +196,17 @@ is `true`.
183196
184197
As a variable in [`MathOptInterface.GreaterThan`](@ref) is bridged into
185198
variables in [`MathOptInterface.Nonnegatives`](@ref) by the
186-
[`VectorizeBridge`](@ref),
187-
```jldoctest
188-
BT = MOI.Bridges.Variable.VectorizeBridge{Float64}
189-
S = MOI.GreaterThan{Float64}
190-
MOI.Bridges.Variable.concrete_bridge_type(BT, S)
199+
[`VectorizeBridge`](@ref):
200+
201+
```jldoctest; setup=:(using MathOptInterface; const MOI = MathOptInterface)
202+
MOI.Bridges.Variable.concrete_bridge_type(
203+
MOI.Bridges.Variable.VectorizeBridge{Float64},
204+
MOI.GreaterThan{Float64},
205+
)
191206
192207
# output
193208
194-
MOI.Bridges.Variable.VectorizeBridge{Float64,MOI.Nonnegatives}
209+
MathOptInterface.Bridges.Variable.VectorizeBridge{Float64,MathOptInterface.Nonnegatives}
195210
```
196211
"""
197212
function concrete_bridge_type(bridge_type::DataType, ::Type{<:MOI.AbstractSet})

0 commit comments

Comments
 (0)