Internals
These functions, types etc. are internal to DocStringExtensions and not part of the public API. They may change or be removed arbitrarily from version to version.
DocStringExtensions.AbbreviationDocStringExtensions.DocStringTemplateDocStringExtensions.FunctionNameDocStringExtensions.LicenseDocStringExtensions.MethodListDocStringExtensions.MethodSignaturesDocStringExtensions.ModuleExportsDocStringExtensions.ModuleImportsDocStringExtensions.ReadmeDocStringExtensions.TemplateDocStringExtensions.TypeDefinitionDocStringExtensions.TypeFieldsDocStringExtensions.TypedMethodSignaturesDocStringExtensions.alltypesigsDocStringExtensions.argumentsDocStringExtensions.cleanpathDocStringExtensions.comparemethodsDocStringExtensions.find_tuplesDocStringExtensions.formatDocStringExtensions.getmethodsDocStringExtensions.getmethods!DocStringExtensions.groupbyDocStringExtensions.groupby!DocStringExtensions.hook!DocStringExtensions.hook!DocStringExtensions.interpolationDocStringExtensions.keywordsDocStringExtensions.method_length_over_limitDocStringExtensions.methodgroupsDocStringExtensions.parsedocsDocStringExtensions.printmethodDocStringExtensions.printmethodDocStringExtensions.url
DocStringExtensions.alltypesigs — Method
alltypesigs(sig)
Returns a Vector of the Tuple types contained in sig.
DocStringExtensions.arguments — Method
arguments(m)
Returns the list of arguments for a particular method m.
Examples
f(x; a = 1, b...) = x
args = arguments(first(methods(f)))DocStringExtensions.cleanpath — Method
cleanpath(path)
Remove the Pkg.dir part of a file path if it exists.
DocStringExtensions.comparemethods — Method
comparemethods(a, b)
Compare methods a and b by file and line number.
DocStringExtensions.find_tuples — Method
find_tuples(typesig)
Converts a method signature (or a union of several signatures) in a vector of (single) signatures.
This is used for decoding the method signature that a docstring is paired with. In the case when the docstring applies to multiple methods (e.g. when default positional argument values are used and define multiple methods at once), they are combined together as union of Tuple types.
julia> DocStringExtensions.find_tuples(Tuple{String,Number,Int})
1-element Vector{DataType}:
Tuple{String, Number, Int64}
julia> DocStringExtensions.find_tuples(Tuple{T} where T <: Integer)
1-element Vector{UnionAll}:
Tuple{T} where T<:Integer
julia> s = Union{
Tuple{Int64},
Tuple{U},
Tuple{T},
Tuple{Int64,T},
Tuple{Int64,T,U}
} where U where T;
julia> DocStringExtensions.find_tuples(s)
5-element Vector{Type}:
Tuple{Int64}
Tuple{U} where U
Tuple{T} where T
Tuple{Int64, T} where T
Tuple{Int64, T, U} where {T, U}DocStringExtensions.format — Method
format(abbr, buf, doc)
Expand the Abbreviation abbr in the context of the DocStr doc and write the resulting markdown-formatted text to the IOBuffer buf.
DocStringExtensions.getmethods! — Method
getmethods!(results, f, sig)
A helper method for getmethods that collects methods in results.
DocStringExtensions.getmethods — Method
getmethods(f, sig)
Collect and return all methods of function f matching signature sig.
This is similar to methods(f, sig), but handles type signatures found in DocStr objects more consistently that methods.
DocStringExtensions.groupby! — Method
groupby!(f, groups, data)
A helper method for groupby that uses a pre-allocated groups Dict.
DocStringExtensions.groupby — Method
groupby(f, K, V, data)
Group data using function f where key type is specified by K and group type by V.
The function f takes a single argument, an element of data, and should return a 2-tuple of (computed_key, element). See the example below for details.
Examples
groupby(Int, Vector{Int}, collect(1:10)) do num
mod(num, 3), num
endDocStringExtensions.hook! — Method
hook!(func)
Set the docstring expander function to first call func before calling the default expander.
To remove a hook that has been applied using this method call hook!().
DocStringExtensions.hook! — Method
hook!()
Reset the docstring expander to only call the default expander function. This clears any 'hook' that has been set using hook!(func).
DocStringExtensions.interpolation — Method
interpolation(object::T, captured::Expr) -> new_objectInterface method for hooking into interpolation within docstrings to change the behaviour of the interpolation. object is the interpolated object within a docstring and captured is the raw expression that is documented by the docstring in which the interpolated object has been included.
To define custom behaviour for your own object types implement a method of interpolation(::T, captured) for type T and return a new_object to be interpolated into the final docstring. Note that you must own the definition of type T. new_object does not need to be of type T.
DocStringExtensions.keywords — Method
keywords(func, m)
Returns the list of keywords for a particular method m of a function func.
Examples
f(x; a = 1, b...) = x
kws = keywords(f, first(methods(f)))DocStringExtensions.method_length_over_limit — Method
method_length_over_limit(len)
Decides whether a length of method is too big to be visually appealing.
DocStringExtensions.methodgroups — Method
methodgroups(func, typesig, modname; exact)
Group all methods of function func with type signatures typesig in module modname. Keyword argument exact = true matches signatures "exactly" with == rather than <:.
Examples
groups = methodgroups(f, Union{Tuple{Any}, Tuple{Any, Integer}}, Main; exact = false)DocStringExtensions.parsedocs — Method
parsedocs(mod)
Parse all docstrings defined within a module mod.
DocStringExtensions.printmethod — Method
printmethod(
buffer::IOBuffer,
binding::Base.Docs.Binding,
func,
method::Method,
typesig;
print_return_types
) -> IOBuffer
Print a simplified representation of a method signature to buffer. Some of these simplifications include:
- no
TypeVars; - no types;
- no keyword default values;
Examples
f(x::Int; a = 1, b...) = x
sig = printmethod(Docs.Binding(Main, :f), f, first(methods(f)))DocStringExtensions.printmethod — Method
printmethod(buffer, binding, func, method)
Print a simplified representation of a method signature to buffer. Some of these simplifications include:
- no
TypeVars; - no types;
- no keyword default values;
_printed where#unused#arguments are found.
Examples
f(x; a = 1, b...) = x
sig = printmethod(Docs.Binding(Main, :f), f, first(methods(f)))DocStringExtensions.url — Method
url(m)
Get the URL (file and line number) where a method m is defined.
Note that this is based on the implementation of Base.url, but handles URLs correctly on TravisCI as well.
DocStringExtensions.Abbreviation — Type
Abbreviation objects are used to automatically generate context-dependent markdown content within documentation strings. Objects of this type interpolated into docstrings will be expanded automatically before parsing the text to markdown.
DocStringExtensions.DocStringTemplate — Type
The singleton type for DOCSTRING abbreviations.
DocStringExtensions.FunctionName — Type
The singleton type for FUNCTIONNAME abbreviations.
DocStringExtensions.License — Type
The singleton type for LICENSE abbreviations.
DocStringExtensions.MethodList — Type
The singleton type for METHODLIST abbreviations.
DocStringExtensions.MethodSignatures — Type
The singleton type for SIGNATURES abbreviations.
DocStringExtensions.ModuleExports — Type
The singleton type for EXPORTS abbreviations.
DocStringExtensions.ModuleImports — Type
The singleton type for IMPORTS abbreviations.
DocStringExtensions.Readme — Type
The singleton type for README abbreviations.
DocStringExtensions.Template — Type
Internal abbreviation type used to wrap templated docstrings.
Location is a Symbol, either :before or :after. dict stores a reference to a module's templates.
DocStringExtensions.TypeDefinition — Type
The singleton type for TYPEDEF abbreviations.
DocStringExtensions.TypeFields — Type
The type for FIELDS abbreviations.
types
DocStringExtensions.TypedMethodSignatures — Type
The type for TYPEDSIGNATURES abbreviations.
return_types