Skip to content

Commit

Permalink
added constants to help make docstring generation clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
stelmo committed Jul 9, 2021
1 parent 2f13056 commit 0a94f77
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
5 changes: 5 additions & 0 deletions src/base/docstrings/docstrings.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const is_inplace = true
const not_inplace = false
const is_plural = true
const not_plural = false

macro _change_bound_s_bang(model_type, index_name, index_type, example, isplural, isinplace)
if isplural
if isinplace
Expand Down
16 changes: 8 additions & 8 deletions src/reconstruction/CoreModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function remove_reactions(m::CoreModel, rxns::Vector{String})
end
end

@doc @_change_bound_s_bang("CoreModel", "rxn_idxs", "Vector{Int}", "[2, 43]", true, true)
@doc @_change_bound_s_bang("CoreModel", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, is_inplace)
function change_bounds!(
model::CoreModel,
reaction_idxs::Vector{Int};
Expand All @@ -387,7 +387,7 @@ function change_bounds!(
end
end

@doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", false, true)
@doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", not_plural, is_inplace)
function change_bound!(
model::CoreModel,
rxn::Int;
Expand All @@ -399,7 +399,7 @@ function change_bound!(
return nothing # so that nothing gets printed
end

@doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", true, true)
@doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, is_inplace)
function change_bounds!(
model::CoreModel,
rxn_ids::Vector{String};
Expand All @@ -409,7 +409,7 @@ function change_bounds!(
change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

@doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", false, true)
@doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", not_plural, is_inplace)
function change_bound!(
model::CoreModel,
rxn_id::String;
Expand All @@ -419,7 +419,7 @@ function change_bound!(
change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end

@doc @_change_bound_s_bang("CoreModel", "rxn_idxs", "Vector{Int}", "[2, 43]", true, false)
@doc @_change_bound_s_bang("CoreModel", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, not_inplace)
function change_bounds(
model::CoreModel,
rxns::Vector{Int};
Expand All @@ -434,7 +434,7 @@ function change_bounds(
return m
end

@doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", false, false)
@doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", not_plural, not_inplace)
function change_bound(
model::CoreModel,
rxn::Int;
Expand All @@ -449,7 +449,7 @@ function change_bound(
return m
end

@doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", true, false)
@doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, not_inplace)
function change_bounds(
model::CoreModel,
rxn_ids::Vector{String};
Expand All @@ -459,7 +459,7 @@ function change_bounds(
change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

@doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", false, false)
@doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", not_plural, not_inplace)
function change_bound(
model::CoreModel,
rxn_id::String;
Expand Down
16 changes: 8 additions & 8 deletions src/reconstruction/CoreModelCoupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function change_coupling_bounds!(
end
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", true, true)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, is_inplace)
function change_bounds!(
model::CoreModelCoupled,
reaction_idxs::Vector{Int};
Expand All @@ -374,7 +374,7 @@ function change_bounds!(
end
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", false, true)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", not_plural, is_inplace)
function change_bound!(
model::CoreModelCoupled,
rxn::Int;
Expand All @@ -386,7 +386,7 @@ function change_bound!(
return nothing # so that nothing gets printed
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", true, true)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, is_inplace)
function change_bounds!(
model::CoreModelCoupled,
rxn_ids::Vector{String};
Expand All @@ -396,7 +396,7 @@ function change_bounds!(
change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", false, true)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", not_plural, is_inplace)
function change_bound!(
model::CoreModelCoupled,
rxn_id::String;
Expand All @@ -406,7 +406,7 @@ function change_bound!(
change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", true, false)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, not_inplace)
function change_bounds(
model::CoreModelCoupled,
rxns::Vector{Int};
Expand All @@ -421,7 +421,7 @@ function change_bounds(
return m
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", false, false)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", not_plural, not_inplace)
function change_bound(
model::CoreModelCoupled,
reaction_idx::Int;
Expand All @@ -436,7 +436,7 @@ function change_bound(
return m
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", true, false)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, not_inplace)
function change_bounds(
model::CoreModelCoupled,
rxn_ids::Vector{String};
Expand All @@ -446,7 +446,7 @@ function change_bounds(
change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", false, false)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", not_plural, not_inplace)
function change_bound(
model::CoreModelCoupled,
rxn_id::String;
Expand Down
8 changes: 4 additions & 4 deletions src/reconstruction/StandardModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ remove_gene!(model, "g1")
remove_gene!(model::StandardModel, gid::String; knockout_reactions::Bool = false) =
remove_genes!(model, [gid]; knockout_reactions = knockout_reactions)

@doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", false, true)
@doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", not_plural, is_inplace)
function change_bound!(
model::StandardModel,
reaction_id::String;
Expand All @@ -226,7 +226,7 @@ function change_bound!(
return nothing # so that nothing gets printed
end

@doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", true, true)
@doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, is_inplace)
function change_bounds!(
model::StandardModel,
reaction_ids::Vector{String};
Expand All @@ -238,7 +238,7 @@ function change_bounds!(
end
end

@doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", false, false)
@doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", not_plural, not_inplace)
function change_bound(
model::StandardModel,
reaction_id::String;
Expand All @@ -253,7 +253,7 @@ function change_bound(
return m
end

@doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", true, false)
@doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, not_inplace)
function change_bounds(
model::StandardModel,
reaction_ids::Vector{String};
Expand Down

0 comments on commit 0a94f77

Please sign in to comment.