Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
COBREXA.jl
Commits
6721c6d7
Unverified
Commit
6721c6d7
authored
Jan 11, 2022
by
Laurent Heirendt
✈
Committed by
GitHub
Jan 11, 2022
Browse files
Merge pull request #557 from LCSB-BioCore/mk-codeloc-macros
improve macro-related documentation
parents
50434513
26b01daf
Pipeline
#51215
failed with stages
in 10 minutes and 25 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/base/macros/change_bounds.jl
View file @
6721c6d7
"""
@_change_bounds_fn ModelType IdxType [plural] [inplace] begin ... end
A helper for creating simple bounds-changing function similar to
[`change_bounds`](@ref).
"""
macro
_change_bounds_fn
(
model_type
,
idx_type
,
args
...
)
body
=
last
(
args
)
typeof
(
body
)
==
Expr
||
throw
(
DomainError
(
body
,
"missing function body"
))
...
...
@@ -41,10 +47,18 @@ macro _change_bounds_fn(model_type, idx_type, args...)
```
"""
return
:
(
@doc
$
docstring
$
fname
(
model
::$
model_type
,
$
idx_var
::$
idx_type
;
lower
=
$
missing_default
,
upper
=
$
missing_default
,
)
=
$
body
)
Expr
(
:
macrocall
,
Symbol
(
"@doc"
),
__source__
,
docstring
,
:
(
$
fname
(
model
::$
model_type
,
$
idx_var
::$
idx_type
;
lower
=
$
missing_default
,
upper
=
$
missing_default
,
)
=
$
body
),
)
end
src/base/macros/remove_item.jl
View file @
6721c6d7
"""
@ _remove_fn objname ModelType IndexType [plural] [inplace] begin ... end
A helper for creating functions that follow the `remove_objname` template, such
as [`remove_metabolites`](@ref) and [`remove_reaction`](@ref).
"""
macro
_remove_fn
(
objname
,
model_type
,
idx_type
,
args
...
)
body
=
last
(
args
)
typeof
(
body
)
==
Expr
||
throw
(
DomainError
(
body
,
"missing function body"
))
...
...
@@ -24,5 +31,11 @@ macro _remove_fn(objname, model_type, idx_type, args...)
$
(inplace ? "
in
-
place
" : "
and
return
the
modified
model
").
"""
return
:
(
@doc
$
docstring
$
fname
(
model
::$
model_type
,
$
idx_var
::$
idx_type
)
=
$
body
)
Expr
(
:
macrocall
,
Symbol
(
"@doc"
),
__source__
,
docstring
,
:
(
$
fname
(
model
::$
model_type
,
$
idx_var
::$
idx_type
)
=
$
body
),
)
end
src/base/macros/serialized.jl
View file @
6721c6d7
"""
_serialized_change_unwrap
(fn::Symbol)
@
_serialized_change_unwrap
function
Creates a simple wrapper structure that calls
a
function transparently on
the
internal precached model. Internal type is returned (because this would
break
the consistency of serialization).
Creates a simple wrapper structure that calls
the `
function
`
transparently on
the
internal precached model. Internal type is returned (because this would
break
the consistency of serialization).
"""
macro
_serialized_change_unwrap
(
fn
::
Symbol
)
docstring
=
"""
...
...
@@ -12,6 +12,14 @@ macro _serialized_change_unwrap(fn::Symbol)
Calls [`
$
fn`](@ref) of the internal serialized model type.
Returns the modified un-serialized model.
"""
:
(
@doc
$
docstring
$
fn
(
model
::
Serialized
,
args
...
;
kwargs
...
)
=
$
fn
(
unwrap_serialized
(
model
),
args
...
;
kwargs
...
))
Expr
(
:
macrocall
,
Symbol
(
"@doc"
),
__source__
,
docstring
,
:
(
$
fn
(
model
::
Serialized
,
args
...
;
kwargs
...
)
=
$
fn
(
unwrap_serialized
(
model
),
args
...
;
kwargs
...
)
),
)
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment