Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce duplication when constructing docstrings #153

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions src/requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ end
return URIs.resolvereference(base_url, _path)
end

const _common_docstring_request = """
- `headers::AbstractDict = Dict{String, String}()`: headers of the request.
- `query::Union{AbstractDict, Nothing} = nothing`: query parameters.
- `require_base_url::Symbol = :strict`: to what extent the requested URL has to match the base URL of the `client`. Possible values are:
- `:strict` (requested URL has to start with the base URL),
- `:host` (host and scheme of the requested URL and base URL have to be equal),
- `:scheme` (scheme of the requested URL and base URL have to be equal),
- `:no` (requested URL does not have to match the base URL).
"""

"""
request_raw(
client::Client, verb::AbstractString, path::AbstractString;
Expand All @@ -82,13 +92,7 @@ for the FHIR `client`, and return the body of the response as `String`.
# Arguments

- `body::Union{AbstractString, Nothing} = nothing`: body of the request.
- `headers::AbstractDict = Dict{String, String}()`: headers of the request.
- `query::Union{AbstractDict, Nothing} = nothing`: query parameters.
- `require_base_url::Symbol = :strict`: to what extent the requested URL has to match the base URL of the `client`.
Possible values are `:strict` (requested URL has to start with the base URL),
`:host` (host and scheme of the requested URL and base URL have to be equal),
`:scheme` (scheme of the requested URL and base URL have to be equal),
and `:no` (requested URL does not have to match the base URL).
$(_common_docstring_request)

See also [`request_json`](@ref) and [`request`](@ref).
"""
Expand Down Expand Up @@ -196,13 +200,7 @@ for the FHIR `client`, and parse the JSON response with JSON3.
# Arguments

- `body::Union{JSON3.Object, Nothing} = nothing`: JSON body of the request.
- `headers::AbstractDict = Dict{String, String}()`: headers of the request.
- `query::Union{AbstractDict, Nothing} = nothing`: query parameters.
- `require_base_url::Symbol = :strict`: to what extent the requested URL has to match the base URL of the `client`.
Possible values are `:strict` (requested URL has to start with the base URL),
`:host` (host and scheme of the requested URL and base URL have to be equal),
`:scheme` (scheme of the requested URL and base URL have to be equal),
and `:no` (requested URL does not have to match the base URL).
$(_common_docstring_request)

See also [`request`](@ref) and [`request_raw`](@ref).
"""
Expand Down Expand Up @@ -250,13 +248,7 @@ for the FHIR `client`, and parse the JSON response with JSON3 as an object of ty
# Arguments

- `body = nothing`: JSON body of the request.
- `headers::AbstractDict = Dict{String, String}()`: headers of the request.
- `query::Union{AbstractDict, Nothing} = nothing`: query parameters.
- `require_base_url::Symbol = :strict`: to what extent the requested URL has to match the base URL of the `client`.
Possible values are `:strict` (requested URL has to start with the base URL),
`:host` (host and scheme of the requested URL and base URL have to be equal),
`:scheme` (scheme of the requested URL and base URL have to be equal),
and `:no` (requested URL does not have to match the base URL).
$(_common_docstring_request)
- `kwargs...`: remaining keyword arguments that are forwarded to `JSON3.read` for parsing the JSON response.

See also [`request_json`](@ref) and [`request_raw`](@ref).
Expand Down
Loading