Skip to content

Commit

Permalink
Minor documentation fixes, bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmatson committed Sep 16, 2020
1 parent 0d22c0f commit 51d8bba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ArgMacros"
uuid = "dbc42088-9de8-42a0-8ec8-2cd114e1ea3e"
authors = ["zachmatson"]
version = "0.2.0"
version = "0.2.1"

[deps]
TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d"
Expand Down
11 changes: 6 additions & 5 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ end
A `Dict{Symbol, Any}` is returned containing all of the argument variables, keyed by the argument names as *`Symbol`s*. You can use
this version from any scope. The `Dict` type is mutable, and any type can be stored in any of its fields. Therefore, this version
does not provide as strong of a guarantee about types to the compuler when argument values are used later. However, the values
are guaranteed to be of the correct types when the `Dict` is first returned.
will always be of the correct types when the `Dict` is first returned.

```julia
function main()
Expand Down Expand Up @@ -288,7 +288,7 @@ in a macro:
```julia
macro handleargs()
return esc(quote
@beginarguments begin
@inlinearguments begin
...
end
end)
Expand All @@ -301,6 +301,7 @@ function main()
end
```

The [`@structarguments`](@ref) must be used in a global scope, but its constructor can then be used anywhere.
The other forms which directly return an object can be placed into an external function because they don't rely
on being in the same namespace as the point where the arguments are used, as [`@inlinearguments`](@ref) does.
The other formats provide more flexibility. The argument code for [`@tuplearguments`](@ref) and [`@dictarguments`](@ref)
can be placed anywhere, including in a separate function which returns their result. [`@structarguments`](@ref) requires
that you declare your arguments in the global namespace (not inside a function, loop, or `let` block), but this will automatically
produce the zero-argument constructor function that you can then call wherever you like.
16 changes: 9 additions & 7 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ which will generate an instance of the struct based on the parsed arguments.
# Example
```julia
function handleargs()
@structarguments false Args begin
...
@argumentrequired Int foo "-f" "--foo"
@argumentdefault Int 5 bar "-b" "--bar"
...
end
@structarguments false Args begin
...
@argumentrequired Int foo "-f" "--foo"
@argumentdefault Int 5 bar "-b" "--bar"
...
end
function julia_main()
args = Args()
...
end
```
Expand Down

2 comments on commit 51d8bba

@zachmatson
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:
Minor documentation updates

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/21485

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 51d8bba36e7c25dbca61d3470448af7e70470c2d
git push origin v0.2.1

Please sign in to comment.