Skip to content

Commit

Permalink
docs: small fixes for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lfenzo committed Nov 13, 2023
1 parent 078f7f2 commit 9577989
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
2 changes: 0 additions & 2 deletions docs/src/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ Order = [:function]

```@index
Pages = [
"utilities/impostor_template.md",
"utilities/templatization.md",
"utilities/utility_functions.md",
]
Depth = 1
Order = [:function]
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ In order to facilitate naming and referencing later on the major concepts implem
| Implementation | Method Signature | Desctiption |
|:---------------|:-----------------|:------------|
| *Value-based* | `func(n::Int)` | Simply generate an output with `n` entries produced by `func`. |
| *Option-based* | `func(v::Vector, n::Int)` | Generates an output with `n` entries produced by `func` but **restricting the generated entries to specified options in `v`**, which specific contents will depend on `func`. Generator functions taking on options in different levels accept the `optionlevel` kwarg, when that is the case, docstrings will explain each specific behavior. |
| *Mask-based* | `func(v::Vector)` | Generates an output with `length(v)` entries produced by `func`. **The contents of `v` specify element-wise options to restrict the output of `func`.** Equivalent *in terms of output* with calling `[func(opt, 1) for opt in v]` (*i.e.* the option-based generation), but sub-optimal in terms of performance. Generator functions taking on masks in different levels accept the `masklevel` kwarg, when it is the case, docstrings will explain each specific behavior.|
| *Option-based* | `func(v::Vector, n::Int)` | Generates an output with `n` entries produced by `func` but **restricting the generated entries to specified options in `v`**, which specific contents will depend on `func`. Generator functions taking on options in different levels accept the `level` kwarg, when that is the case, docstrings will explain each specific behavior. |
| *Mask-based* | `func(v::Vector)` | Generates an output with `length(v)` entries produced by `func`. **The contents of `v` specify element-wise options to restrict the output of `func`.** Equivalent *in terms of output* with calling `[func(opt, 1) for opt in v]` (*i.e.* the option-based generation), but sub-optimal in terms of performance. Generator functions taking on masks in different levels accept the `level` kwarg, when it is the case, docstrings will explain each specific behavior.|

```@repl
using Impostor # hide
Expand Down
51 changes: 24 additions & 27 deletions src/providers/identity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ end


"""
prefix(n::Integer = 1; kwargs...)
prefix(options::Vector{String}, n::Integer; kwargs...)
prefix(mask::Vector{<:AbstractString}; kwargs...)
prefix(n::Integer = 1; kws...)
prefix(options::Vector{String}, n::Integer; kws...)
prefix(mask::Vector{<:AbstractString}; kws...)
Generate `n` name prefixes, *e.g.* `"Mr."` and `"Ms."`, from a given locale.
Expand All @@ -70,7 +70,7 @@ The valid options values for `options` and `mask` are:
# Example
```@juliarepl
julia> prefix(["female", "male", "female"])
julia> prefix(["F", "M", "F"])
3-element Vector{String}:
"Ms."
"Mr."
Expand Down Expand Up @@ -105,9 +105,9 @@ end


"""
firstname(n::Integer = 1; kwargs...)
firstname(sexes::Vector{<:AbstractString}, n::Integer; kwargs...)
firstname(sexes::Vector{<:AbstractString}; kargs...))
firstname(n::Integer = 1; kws...)
firstname(sexes::Vector{<:AbstractString}, n::Integer; kws...)
firstname(sexes::Vector{<:AbstractString}; kws...))
Generate `n` or `length(mask)` first names.
Expand Down Expand Up @@ -170,7 +170,7 @@ end


"""
surname(n::Integer = 1; kwargs...)
surname(n::Integer = 1; kws...)
Generate a `surname` using the provided `locale` as source.
Expand All @@ -188,9 +188,9 @@ end


"""
complete_name(n::Integer = 1; kwargs...)
complete_name(sexes::Vector{<:AbstractString}, n::Integer; kwargs...)
complete_name(sexes::Vector{<:AbstractString}; kwargs...)
complete_name(n::Integer = 1; kws...)
complete_name(options::Vector{<:AbstractString}, n::Integer; kws...)
complete_name(mask::Vector{<:AbstractString}; kws...)
Generate `n` or `length(mask)` full (complete) names from a given locale.
Expand All @@ -203,8 +203,8 @@ The valid options values for `options` and `mask` are:
- `"F"` for "female"
# Kwargs
- `max_surnames::Integer = 3`: maximum number of surnames in each of the generated entries, note that the actual number may be smaller than `max_surnames`.
- `locale::Vector{String}`: locale(s) from which entries are sampled. If no `locale` is provided, the current session locale is used.
- `max_surnames::Integer = 3`: maximum number of surnames in each of the generated entries, note that the actual number may be smaller than `max_surnames`.
# Examples
```@juliarepl
Expand All @@ -225,10 +225,7 @@ julia> complete_name(["F", "M", "F", "F", "M"])
"Alfred Fraser Collins"
```
"""
function complete_name(n::Integer = 1;
max_surnames::Integer = 3,
locale = session_locale()
)
function complete_name(n::Integer = 1; locale = session_locale(), max_surnames::Integer = 3)
complete_names = Vector{String}()
for _ in 1:n
fname = Impostor.firstname(; locale = locale)
Expand All @@ -242,8 +239,8 @@ function complete_name(n::Integer = 1;
end

function complete_name(sexes::Vector{<:AbstractString}, n::Integer;
locale = session_locale(),
max_surnames::Integer = 3,
locale = session_locale()
)
complete_names = Vector{String}()
for _ in 1:n
Expand All @@ -258,8 +255,8 @@ function complete_name(sexes::Vector{<:AbstractString}, n::Integer;
end

function complete_name(mask::Vector{<:AbstractString};
locale = session_locale(),
max_surnames::Integer = 3,
locale = session_locale()
)
complete_names = Vector{String}()
for value in mask
Expand All @@ -276,9 +273,9 @@ end


"""
occupation(n::Integer = 1; kwargs...)
occupation(options::Vector{<:AbstractString}, n::Integer; kwargs...)
occupation(mask::Vector{<:AbstractString}; kwargs...)
occupation(n::Integer = 1; kws...)
occupation(options::Vector{<:AbstractString}, n::Integer; kws...)
occupation(mask::Vector{<:AbstractString}; kws...)
Generate `n` or `length(mask)` occupation entries.
Expand Down Expand Up @@ -328,9 +325,9 @@ end


"""
university(n::Integer = 1; kwargs...)
university(fields::Vector{<:AbstractString}, n::Integer; kwargs...)
university(field_mask::Vector{<:AbstractString}; kwargs...)
university(n::Integer = 1; kws...)
university(fields::Vector{<:AbstractString}, n::Integer; kws...)
university(field_mask::Vector{<:AbstractString}; kws...)
# Parameters
- `n::Integer = 1`: number of university entries to generate.
Expand Down Expand Up @@ -378,9 +375,9 @@ end


"""
nationality(n::Integer = 1; kwargs...)
nationality(options::Vector{<:AbstractString}, n::Integer; level::Symbol, kwargs...)
nationality(mask::Vector{<:AbstractString}; level::Symbol, kwargs...)
nationality(n::Integer = 1; kws...)
nationality(options::Vector{<:AbstractString}, n::Integer; level::Symbol, kws...)
nationality(mask::Vector{<:AbstractString}; level::Symbol, kws...)
# Parameters
- `n::Integer = 1`: number of nationality entries to generate.
Expand Down

0 comments on commit 9577989

Please sign in to comment.