Skip to content

Commit 51d8bba

Browse files
committed
Minor documentation fixes, bump version.
1 parent 0d22c0f commit 51d8bba

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArgMacros"
22
uuid = "dbc42088-9de8-42a0-8ec8-2cd114e1ea3e"
33
authors = ["zachmatson"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d"

docs/src/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ end
196196
A `Dict{Symbol, Any}` is returned containing all of the argument variables, keyed by the argument names as *`Symbol`s*. You can use
197197
this version from any scope. The `Dict` type is mutable, and any type can be stored in any of its fields. Therefore, this version
198198
does not provide as strong of a guarantee about types to the compuler when argument values are used later. However, the values
199-
are guaranteed to be of the correct types when the `Dict` is first returned.
199+
will always be of the correct types when the `Dict` is first returned.
200200

201201
```julia
202202
function main()
@@ -288,7 +288,7 @@ in a macro:
288288
```julia
289289
macro handleargs()
290290
return esc(quote
291-
@beginarguments begin
291+
@inlinearguments begin
292292
...
293293
end
294294
end)
@@ -301,6 +301,7 @@ function main()
301301
end
302302
```
303303

304-
The [`@structarguments`](@ref) must be used in a global scope, but its constructor can then be used anywhere.
305-
The other forms which directly return an object can be placed into an external function because they don't rely
306-
on being in the same namespace as the point where the arguments are used, as [`@inlinearguments`](@ref) does.
304+
The other formats provide more flexibility. The argument code for [`@tuplearguments`](@ref) and [`@dictarguments`](@ref)
305+
can be placed anywhere, including in a separate function which returns their result. [`@structarguments`](@ref) requires
306+
that you declare your arguments in the global namespace (not inside a function, loop, or `let` block), but this will automatically
307+
produce the zero-argument constructor function that you can then call wherever you like.

src/macros.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ which will generate an instance of the struct based on the parsed arguments.
6767
6868
# Example
6969
```julia
70-
function handleargs()
71-
@structarguments false Args begin
72-
...
73-
@argumentrequired Int foo "-f" "--foo"
74-
@argumentdefault Int 5 bar "-b" "--bar"
75-
...
76-
end
70+
@structarguments false Args begin
71+
...
72+
@argumentrequired Int foo "-f" "--foo"
73+
@argumentdefault Int 5 bar "-b" "--bar"
74+
...
75+
end
76+
77+
function julia_main()
78+
args = Args()
7779
...
7880
end
7981
```

0 commit comments

Comments
 (0)